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);
56 $this->user = User::getKV('nickname', $nickname);
59 // TRANS: Client error displayed when trying to perform a gallery action with an unknown user.
60 $this->clientError(_('No such user.'), 404);
63 $this->profile = $this->user->getProfile();
65 if (!$this->profile) {
66 // TRANS: Error message displayed when referring to a user without a profile.
67 $this->serverError(_('User has no profile.'));
70 $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
72 $this->tag = $this->trimmed('tag');
73 $this->q = $this->trimmed('q');
78 function isReadOnly($args)
83 function handle($args)
85 parent::handle($args);
87 // Post from the tag dropdown; redirect to a GET
89 if ($_SERVER['REQUEST_METHOD'] == 'POST') {
90 common_redirect($this->selfUrl(), 303);
96 function showContent()
98 $this->showTagsDropdown();
101 function showTagsDropdown()
103 $tag = $this->trimmed('tag');
105 $tags = $this->getAllTags();
109 foreach ($tags as $t) {
113 $this->elementStart('dl', array('id' => 'filter_tags'));
114 $this->element('dt', null, _('Tags'));
115 $this->elementStart('dd');
116 $this->elementStart('ul');
117 $this->elementStart('li', array('id' => 'filter_tags_all',
118 'class' => 'child_1'));
121 common_local_url($this->trimmed('action'),
123 $this->user->nickname))),
124 // TRANS: List element on gallery action page to show all tags.
126 $this->elementEnd('li');
127 $this->elementStart('li', array('id'=>'filter_tags_item'));
128 $this->elementStart('form', array('name' => 'bytag',
129 'id' => 'form_filter_bytag',
130 'action' => common_path('?action=' . $this->trimmed('action')),
131 'method' => 'post'));
132 $this->elementStart('fieldset');
133 // TRANS: Fieldset legend on gallery action page.
134 $this->element('legend', null, _('Select tag to filter'));
135 // TRANS: Dropdown field label on gallery action page for a list containing tags.
136 $this->dropdown('tag', _('Tag'), $content,
137 // TRANS: Dropdown field title on gallery action page for a list containing tags.
138 _('Choose a tag to narrow list.'), false, $tag);
139 $this->hidden('nickname', $this->user->nickname);
140 // TRANS: Submit button text on gallery action page.
141 $this->submit('submit', _m('BUTTON','Go'));
142 $this->elementEnd('fieldset');
143 $this->elementEnd('form');
144 $this->elementEnd('li');
145 $this->elementEnd('ul');
146 $this->elementEnd('dd');
147 $this->elementEnd('dl');
151 // Get list of tags we tagged other users with
152 function getTags($lst, $usr)
154 $profile_tag = new Notice_tag();
155 $profile_tag->query('SELECT DISTINCT(tag) ' .
156 'FROM profile_tag, subscription ' .
157 'WHERE tagger = ' . $this->profile->id . ' ' .
158 'AND ' . $usr . ' = ' . $this->profile->id . ' ' .
159 'AND ' . $lst . ' = tagged ' .
160 'AND tagger != tagged');
162 while ($profile_tag->fetch()) {
163 $tags[] = $profile_tag->tag;
165 $profile_tag->free();
169 function getAllTags()
174 function showProfileBlock()
176 $block = new AccountProfileBlock($this, $this->profile);