3 * StatusNet, the distributed open-source microblogging tool
5 * People tags for a user
9 * LICENCE: This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * @author Shashi Gowda <connect2shashi@gmail.com>
25 * @copyright 2008-2009 StatusNet, Inc.
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27 * @link http://status.net/
30 if (!defined('STATUSNET') && !defined('LACONICA')) {
34 require_once INSTALLDIR.'/lib/peopletaglist.php';
36 class PeopletagsforuserAction extends OwnerDesignAction
41 function isReadOnly($args)
48 if ($this->page == 1) {
49 // Page title. %s is a tagged user's nickname.
50 return sprintf(_('People tags for %s'), $this->tagged->nickname);
52 // Page title. %1$s is a tagged user's nickname, %2$s is a page number.
53 return sprintf(_('People tags for %1$s, page %2$d'), $this->tagged->nickname, $this->page);
57 function prepare($args)
59 parent::prepare($args);
61 $nickname_arg = $this->arg('nickname');
62 $nickname = common_canonical_nickname($nickname_arg);
64 // Permanent redirect on non-canonical nickname
66 if ($nickname_arg != $nickname) {
67 $args = array('nickname' => $nickname);
68 if ($this->arg('page') && $this->arg('page') != 1) {
69 $args['page'] = $this->arg['page'];
71 common_redirect(common_local_url('peopletagsforuser', $args), 301);
75 $this->user = User::staticGet('nickname', $nickname);
78 // TRANS: Client error displayed trying to perform an action related to a non-existing user.
79 $this->clientError(_('No such user.'), 404);
83 $this->tagged = $this->user->getProfile();
86 // TRANS: Server error displayed when a user has no profile.
87 $this->serverError(_('User has no profile.'));
91 $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
96 function handle($args)
98 parent::handle($args);
102 function showAnonymousMessage()
105 // TRANS: Message displayed for anonymous users on page that displays people tags for a user.
106 // TRANS: This message contains Markdown links in the form [description](links).
107 // TRANS: %s is a tagger nickname.
108 sprintf(_('These are people tags for **%s**. ' .
109 'People tags are how you sort similar ' .
110 'people on %%%%site.name%%%%, a [micro-blogging]' .
111 '(http://en.wikipedia.org/wiki/Micro-blogging) service ' .
112 'based on the Free Software [StatusNet](http://status.net/) tool. ' .
113 'You can easily keep track of what they ' .
114 'are doing by subscribing to the tag\'s timeline.' ), $this->tagged->nickname);
115 $this->elementStart('div', array('id' => 'anon_notice'));
116 $this->raw(common_markup_to_html($notice));
117 $this->elementEnd('div');
120 function showPageNotice()
122 $this->elementStart('dl', 'filter_tags');
123 $this->elementStart('dd', array('id' => 'filter_tags_for',
124 'class' => 'child_1'));
126 $user = common_current_user();
127 // TRANS: Page notice.
128 $text = ($this->tagged->id == @$user->id) ? _('People tags by you') :
129 // TRANS: Page notice. %s is a tagger's nickname.
130 sprintf(_('People tags by %s'), $this->tagged->nickname);
133 common_local_url('peopletagsbyuser',
134 array('nickname' => $this->tagged->nickname))),
136 $this->elementEnd('dd');
137 $this->elementEnd('dl');
141 function showContent()
143 #TODO: controls here.
145 $offset = ($this->page-1) * PEOPLETAGS_PER_PAGE;
146 $limit = PEOPLETAGS_PER_PAGE + 1;
148 $ptags = $this->tagged->getOtherTags(common_current_user(), $offset, $limit);
150 $pl = new PeopletagList($ptags, $this);
154 $this->showEmptyListMessage();
156 $this->pagination($this->page > 1, $cnt > PEOPLETAGS_PER_PAGE,
157 $this->page, 'peopletagsforuser', array('nickname' => $this->tagged->id));
160 function showEmptyListMessage()
162 // TRANS: Message displayed on page that displays people tags for a user when there are none.
163 // TRANS: This message contains Markdown links in the form [description](links).
164 // TRANS: %s is a tagger nickname.
165 $message = sprintf(_('%s has not been [tagged](%%%%doc.tags%%%%) by anyone yet.'), $this->tagged->nickname);
166 $this->elementStart('div', 'guide');
167 $this->raw(common_markup_to_html($message));
168 $this->elementEnd('div');
171 function showSections()
173 #TODO: tags with most subscribers
174 #TODO: tags with most "members"