3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2008, 2009, StatusNet, Inc.
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.
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.
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/>.
20 if (!defined('STATUSNET') && !defined('LACONICA')) {
24 require_once INSTALLDIR.'/lib/profilelist.php';
28 define('AVATARS_PER_PAGE', 80);
30 // @todo FIXME: Class documentation missing.
31 class GalleryAction extends ProfileAction
37 function prepare($args)
39 parent::prepare($args);
41 // FIXME very similar code below
43 $nickname_arg = $this->arg('nickname');
44 $nickname = common_canonical_nickname($nickname_arg);
46 // Permanent redirect on non-canonical nickname
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'];
53 common_redirect(common_local_url($this->trimmed('action'), $args), 301);
57 $this->user = User::staticGet('nickname', $nickname);
60 // TRANS: Client error displayed when trying to perform a gallery action with an unknown user.
61 $this->clientError(_('No such user.'), 404);
65 $this->profile = $this->user->getProfile();
67 if (!$this->profile) {
68 // TRANS: Error message displayed when referring to a user without a profile.
69 $this->serverError(_('User has no profile.'));
73 $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
75 $this->tag = $this->trimmed('tag');
76 $this->q = $this->trimmed('q');
81 function isReadOnly($args)
86 function handle($args)
88 parent::handle($args);
90 // Post from the tag dropdown; redirect to a GET
92 if ($_SERVER['REQUEST_METHOD'] == 'POST') {
93 common_redirect($this->selfUrl(), 303);
100 function showContent()
102 $this->showTagsDropdown();
105 function showTagsDropdown()
107 $tag = $this->trimmed('tag');
109 $tags = $this->getAllTags();
113 foreach ($tags as $t) {
117 $this->elementStart('dl', array('id' => 'filter_tags'));
118 $this->element('dt', null, _('Tags'));
119 $this->elementStart('dd');
120 $this->elementStart('ul');
121 $this->elementStart('li', array('id' => 'filter_tags_all',
122 'class' => 'child_1'));
125 common_local_url($this->trimmed('action'),
127 $this->user->nickname))),
128 // TRANS: List element on gallery action page to show all tags.
130 $this->elementEnd('li');
131 $this->elementStart('li', array('id'=>'filter_tags_item'));
132 $this->elementStart('form', array('name' => 'bytag',
133 'id' => 'form_filter_bytag',
134 'action' => common_path('?action=' . $this->trimmed('action')),
135 'method' => 'post'));
136 $this->elementStart('fieldset');
137 // TRANS: Fieldset legend on gallery action page.
138 $this->element('legend', null, _('Select tag to filter'));
139 // TRANS: Dropdown field label on gallery action page for a list containing tags.
140 $this->dropdown('tag', _('Tag'), $content,
141 // TRANS: Dropdown field title on gallery action page for a list containing tags.
142 _('Choose a tag to narrow list.'), false, $tag);
143 $this->hidden('nickname', $this->user->nickname);
144 // TRANS: Submit button text on gallery action page.
145 $this->submit('submit', _m('BUTTON','Go'));
146 $this->elementEnd('fieldset');
147 $this->elementEnd('form');
148 $this->elementEnd('li');
149 $this->elementEnd('ul');
150 $this->elementEnd('dd');
151 $this->elementEnd('dl');
155 // Get list of tags we tagged other users with
156 function getTags($lst, $usr)
158 $profile_tag = new Notice_tag();
159 $profile_tag->query('SELECT DISTINCT(tag) ' .
160 'FROM profile_tag, subscription ' .
161 'WHERE tagger = ' . $this->profile->id . ' ' .
162 'AND ' . $usr . ' = ' . $this->profile->id . ' ' .
163 'AND ' . $lst . ' = tagged ' .
164 'AND tagger != tagged');
166 while ($profile_tag->fetch()) {
167 $tags[] = $profile_tag->tag;
169 $profile_tag->free();
173 function getAllTags()
178 function showProfileBlock()
180 $block = new AccountProfileBlock($this, $this->profile);