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('GNUSOCIAL')) { exit(1); }
24 define('AVATARS_PER_PAGE', 80);
26 // @todo FIXME: Class documentation missing.
27 class GalleryAction extends ProfileAction
29 protected function handle()
31 // Post from the tag dropdown; redirect to a GET
32 if ($this->isPost()) {
33 common_redirect($this->selfUrl(), 303);
39 protected function doPreparation()
41 // showstream requires a nickname
42 $nickname_arg = $this->arg('nickname');
43 $nickname = common_canonical_nickname($nickname_arg);
45 // Permanent redirect on non-canonical nickname
47 if ($nickname_arg != $nickname) {
48 $args = array('nickname' => $nickname);
49 if ($this->arg('page') && $this->arg('page') != 1) {
50 $args['page'] = $this->arg['page'];
52 common_redirect(common_local_url($this->getActionName(), $args), 301);
54 $this->user = User::getKV('nickname', $nickname);
57 $group = Local_group::getKV('nickname', $nickname);
58 if ($group instanceof Local_group) {
59 common_redirect($group->getProfile()->getUrl());
61 // TRANS: Client error displayed when calling a profile action without specifying a user.
62 $this->clientError(_('No such user.'), 404);
65 $this->target = $this->user->getProfile();
68 function showContent()
70 $this->showTagsDropdown();
73 function showTagsDropdown()
75 $tag = $this->trimmed('tag');
77 $tags = $this->getAllTags();
81 foreach ($tags as $t) {
85 $this->elementStart('dl', array('id' => 'filter_tags'));
86 $this->element('dt', null, _('Tags'));
87 $this->elementStart('dd');
88 $this->elementStart('ul');
89 $this->elementStart('li', array('id' => 'filter_tags_all',
90 'class' => 'child_1'));
93 common_local_url($this->trimmed('action'),
95 $this->target->getNickname()))),
96 // TRANS: List element on gallery action page to show all tags.
98 $this->elementEnd('li');
99 $this->elementStart('li', array('id'=>'filter_tags_item'));
100 $this->elementStart('form', array('name' => 'bytag',
101 'id' => 'form_filter_bytag',
102 'action' => common_path('?action=' . $this->getActionName()),
103 'method' => 'post'));
104 $this->elementStart('fieldset');
105 // TRANS: Fieldset legend on gallery action page.
106 $this->element('legend', null, _('Select tag to filter'));
107 // TRANS: Dropdown field label on gallery action page for a list containing tags.
108 $this->dropdown('tag', _('Tag'), $content,
109 // TRANS: Dropdown field title on gallery action page for a list containing tags.
110 _('Choose a tag to narrow list.'), false, $tag);
111 $this->hidden('nickname', $this->target->getNickname());
112 // TRANS: Submit button text on gallery action page.
113 $this->submit('submit', _m('BUTTON','Go'));
114 $this->elementEnd('fieldset');
115 $this->elementEnd('form');
116 $this->elementEnd('li');
117 $this->elementEnd('ul');
118 $this->elementEnd('dd');
119 $this->elementEnd('dl');
123 // Get list of tags we tagged other users with
124 function getTags($lst, $usr)
126 $profile_tag = new Notice_tag();
127 $profile_tag->query('SELECT DISTINCT(tag) ' .
128 'FROM profile_tag, subscription ' .
129 'WHERE tagger = ' . $this->target->id . ' ' .
130 'AND ' . $usr . ' = ' . $this->target->id . ' ' .
131 'AND ' . $lst . ' = tagged ' .
132 'AND tagger != tagged');
134 while ($profile_tag->fetch()) {
135 $tags[] = $profile_tag->tag;
137 $profile_tag->free();
141 function getAllTags()
146 function showProfileBlock()
148 $block = new AccountProfileBlock($this, $this->target);