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-2011 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 Action
41 function isReadOnly($args)
48 if ($this->page == 1) {
49 // TRANS: Page title. %s is a tagged user's nickname.
50 return sprintf(_('Lists with %s in them'), $this->tagged->nickname);
52 // TRANS: Page title. %1$s is a tagged user's nickname, %2$s is a page number.
53 return sprintf(_('Lists with %1$s, page %2$d'), $this->tagged->nickname, $this->page);
57 function prepare($args)
59 parent::prepare($args);
61 if (common_config('singleuser', 'enabled')) {
62 $nickname_arg = User::singleUserNickname();
64 $nickname_arg = $this->arg('nickname');
67 $nickname = common_canonical_nickname($nickname_arg);
69 // Permanent redirect on non-canonical nickname
71 if ($nickname_arg != $nickname) {
72 $args = array('nickname' => $nickname);
73 if ($this->arg('page') && $this->arg('page') != 1) {
74 $args['page'] = $this->arg['page'];
76 common_redirect(common_local_url('peopletagsforuser', $args), 301);
80 $this->user = User::getKV('nickname', $nickname);
83 // TRANS: Client error displayed trying to perform an action related to a non-existing user.
84 $this->clientError(_('No such user.'), 404);
88 $this->tagged = $this->user->getProfile();
91 // TRANS: Error message displayed when referring to a user without a profile.
92 $this->serverError(_('User has no profile.'));
96 $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
101 function handle($args)
103 parent::handle($args);
107 function showAnonymousMessage()
110 // TRANS: Message displayed for anonymous users on page that displays lists for a user.
111 // TRANS: This message contains Markdown links in the form [description](links).
112 // TRANS: %s is a tagger nickname.
113 sprintf(_('These are lists for **%s**. ' .
114 'lists are how you sort similar ' .
115 'people on %%%%site.name%%%%, a [micro-blogging]' .
116 '(http://en.wikipedia.org/wiki/Micro-blogging) service ' .
117 'based on the Free Software [StatusNet](http://status.net/) tool. ' .
118 'You can easily keep track of what they ' .
119 'are doing by subscribing to the list\'s timeline.' ), $this->tagged->nickname);
120 $this->elementStart('div', array('id' => 'anon_notice'));
121 $this->raw(common_markup_to_html($notice));
122 $this->elementEnd('div');
125 function showContent()
127 #TODO: controls here.
129 $offset = ($this->page-1) * PEOPLETAGS_PER_PAGE;
130 $limit = PEOPLETAGS_PER_PAGE + 1;
132 $ptags = $this->tagged->getOtherTags(common_current_user(), $offset, $limit);
134 $pl = new PeopletagList($ptags, $this);
138 $this->showEmptyListMessage();
140 $this->pagination($this->page > 1, $cnt > PEOPLETAGS_PER_PAGE,
141 $this->page, 'peopletagsforuser', array('nickname' => $this->tagged->id));
144 function showEmptyListMessage()
146 // TRANS: Message displayed on page that displays lists a user was added to when there are none.
147 // TRANS: This message contains Markdown links in the form [description](links).
148 // TRANS: %s is a user nickname.
149 $message = sprintf(_('%s has not been [listed](%%%%doc.lists%%%%) by anyone yet.'), $this->tagged->nickname);
150 $this->elementStart('div', 'guide');
151 $this->raw(common_markup_to_html($message));
152 $this->elementEnd('div');
155 function showObjectNav()
157 $nav = new PeopletagNav($this, $this->tagged);
161 function showProfileBlock()
163 $block = new AccountProfileBlock($this, $this->tagged);
167 function showSections()
169 #TODO: tags with most subscribers
170 #TODO: tags with most "members"