3 * Laconica - a distributed open-source microblogging tool
4 * Copyright (C) 2008, Controlez-Vous, 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('LACONICA')) {
24 require_once INSTALLDIR.'/lib/profilelist.php';
28 define('AVATARS_PER_PAGE', 80);
30 class GalleryAction extends Action
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('subscriptions', $args), 301);
57 $this->user = User::staticGet('nickname', $nickname);
60 $this->clientError(_('No such user.'), 404);
64 $this->profile = $this->user->getProfile();
66 if (!$this->profile) {
67 $this->serverError(_('User has no profile.'));
71 $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
73 $this->tag = $this->trimmed('tag');
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(), 307);
97 function showLocalNav()
99 $nav = new SubGroupNav($this, $this->user);
103 function showContent()
105 $this->showTagsDropdown();
108 function showTagsDropdown()
110 $tag = $this->trimmed('tag');
112 $tags = $this->getAllTags();
116 foreach ($tags as $t) {
120 $this->elementStart('dl', array('id'=>'filter_tags'));
121 $this->element('dt', null, _('Filter tags'));
122 $this->elementStart('dd');
123 $this->elementStart('ul');
124 $this->elementStart('li', array('id' => 'filter_tags_all',
125 'class' => 'child_1'));
128 common_local_url($this->trimmed('action'),
130 $this->user->nickname))),
132 $this->elementEnd('li');
133 $this->elementStart('li', array('id'=>'filter_tags_item'));
134 $this->elementStart('form', array('name' => 'bytag',
136 'method' => 'post'));
137 $this->dropdown('tag', _('Tag'), $content,
138 _('Choose a tag to narrow list'), false, $tag);
139 $this->submit('go', _('Go'));
140 $this->elementEnd('form');
141 $this->elementEnd('li');
142 $this->elementEnd('ul');
143 $this->elementEnd('dd');
144 $this->elementEnd('dl');
148 // Get list of tags we tagged other users with
150 function getTags($lst, $usr)
152 $profile_tag = new Notice_tag();
153 $profile_tag->query('SELECT DISTINCT(tag) ' .
154 'FROM profile_tag, subscription ' .
155 'WHERE tagger = ' . $this->profile->id . ' ' .
156 'AND ' . $usr . ' = ' . $this->profile->id . ' ' .
157 'AND ' . $lst . ' = tagged ' .
158 'AND tagger != tagged');
160 while ($profile_tag->fetch()) {
161 $tags[] = $profile_tag->tag;
163 $profile_tag->free();
167 function getAllTags()