]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/galleryaction.php
Fix weird alignment of controls in subscriptions page. The dots are gone now
[quix0rs-gnu-social.git] / lib / galleryaction.php
1 <?php
2 /**
3  * StatusNet - the distributed open-source microblogging tool
4  * Copyright (C) 2008, 2009, StatusNet, Inc.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Affero General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU Affero General Public License for more details.
15  *
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 if (!defined('STATUSNET') && !defined('LACONICA')) {
21     exit(1);
22 }
23
24 require_once INSTALLDIR.'/lib/profilelist.php';
25
26 // 10x8
27
28 define('AVATARS_PER_PAGE', 80);
29
30 // @todo FIXME: Class documentation missing.
31 class GalleryAction extends OwnerDesignAction
32 {
33     var $profile = null;
34     var $page = null;
35     var $tag = null;
36
37     function prepare($args)
38     {
39         parent::prepare($args);
40
41         // FIXME very similar code below
42
43         $nickname_arg = $this->arg('nickname');
44         $nickname = common_canonical_nickname($nickname_arg);
45
46         // Permanent redirect on non-canonical nickname
47
48         if ($nickname_arg != $nickname) {
49             $args = array('nickname' => $nickname);
50             if ($this->arg('page') && $this->arg('page') != 1) {
51                 $args['page'] = $this->arg['page'];
52             }
53             common_redirect(common_local_url($this->trimmed('action'), $args), 301);
54             return false;
55         }
56
57         $this->user = User::staticGet('nickname', $nickname);
58
59         if (!$this->user) {
60             // TRANS: Client error displayed when trying to perform a gallery action with an unknown user.
61             $this->clientError(_('No such user.'), 404);
62             return false;
63         }
64
65         $this->profile = $this->user->getProfile();
66
67         if (!$this->profile) {
68             // TRANS: Server error displayed when trying to perform a gallery action with a user without a profile.
69             $this->serverError(_('User has no profile.'));
70             return false;
71         }
72
73         $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
74
75         $this->tag = $this->trimmed('tag');
76         $this->q   = $this->trimmed('q');
77
78         return true;
79     }
80
81     function isReadOnly($args)
82     {
83         return true;
84     }
85
86     function handle($args)
87     {
88         parent::handle($args);
89
90                 // Post from the tag dropdown; redirect to a GET
91
92                 if ($_SERVER['REQUEST_METHOD'] == 'POST') {
93                     common_redirect($this->selfUrl(), 303);
94             return;
95                 }
96
97         $this->showPage();
98     }
99
100     function showObjectNav()
101     {
102         $nav = new SubGroupNav($this, $this->user);
103         $nav->show();
104     }
105
106     function showContent()
107     {
108         $this->showTagsDropdown();
109     }
110
111     function showTagsDropdown()
112     {
113         $tag = $this->trimmed('tag');
114
115         $tags = $this->getAllTags();
116
117         $content = array();
118
119         foreach ($tags as $t) {
120             $content[$t] = $t;
121         }
122         if ($tags) {
123             $this->elementStart('dl', array('id' => 'filter_tags'));
124             $this->element('dt', null, _('Tags'));
125             $this->elementStart('dd');
126             $this->elementStart('ul');
127             $this->elementStart('li', array('id' => 'filter_tags_all',
128                                              'class' => 'child_1'));
129             $this->element('a',
130                            array('href' =>
131                                  common_local_url($this->trimmed('action'),
132                                                   array('nickname' =>
133                                                         $this->user->nickname))),
134                            // TRANS: List element on gallery action page to show all tags.
135                            _m('TAGS','All'));
136             $this->elementEnd('li');
137             $this->elementStart('li', array('id'=>'filter_tags_item'));
138             $this->elementStart('form', array('name' => 'bytag',
139                                                'id' => 'form_filter_bytag',
140                                               'action' => common_path('?action=' . $this->trimmed('action')),
141                                                'method' => 'post'));
142             $this->elementStart('fieldset');
143             // TRANS: Fieldset legend on gallery action page.
144             $this->element('legend', null, _('Select tag to filter'));
145             // TRANS: Dropdown field label on gallery action page for a list containing tags.
146             $this->dropdown('tag', _('Tag'), $content,
147                             // TRANS: Dropdown field title on gallery action page for a list containing tags.
148                             _('Choose a tag to narrow list.'), false, $tag);
149             $this->hidden('nickname', $this->user->nickname);
150             // TRANS: Submit button text on gallery action page.
151             $this->submit('submit', _m('BUTTON','Go'));
152             $this->elementEnd('fieldset');
153             $this->elementEnd('form');
154             $this->elementEnd('li');
155             $this->elementEnd('ul');
156             $this->elementEnd('dd');
157             $this->elementEnd('dl');
158         }
159     }
160
161     // Get list of tags we tagged other users with
162     function getTags($lst, $usr)
163     {
164         $profile_tag = new Notice_tag();
165         $profile_tag->query('SELECT DISTINCT(tag) ' .
166                             'FROM profile_tag, subscription ' .
167                             'WHERE tagger = ' . $this->profile->id . ' ' .
168                             'AND ' . $usr . ' = ' . $this->profile->id . ' ' .
169                             'AND ' . $lst . ' = tagged ' .
170                             'AND tagger != tagged');
171         $tags = array();
172         while ($profile_tag->fetch()) {
173             $tags[] = $profile_tag->tag;
174         }
175         $profile_tag->free();
176         return $tags;
177     }
178
179     function getAllTags()
180     {
181         return array();
182     }
183
184     function showProfileBlock()
185     {
186         $block = new AccountProfileBlock($this, $this->profile);
187         $block->show();
188     }
189 }