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/>.
21 * @license GNU Affero General Public License http://www.gnu.org/licenses/
22 * @link http://status.net
25 if (!defined('GNUSOCIAL')) { exit(1); }
27 class ShowprofiletagAction extends Action
29 var $notice, $tagger, $peopletag, $userProfile;
31 function isReadOnly($args)
36 function prepare($args)
38 parent::prepare($args);
40 if (common_config('singleuser', 'enabled')) {
41 $tagger_arg = User::singleUserNickname();
43 $tagger_arg = $this->arg('tagger');
45 $tag_arg = $this->arg('tag');
46 $tagger = common_canonical_nickname($tagger_arg);
47 $tag = common_canonical_tag($tag_arg);
49 // Permanent redirect on non-canonical nickname
51 if ($tagger_arg != $tagger || $tag_arg != $tag) {
52 $args = array('tagger' => $nickname, 'tag' => $tag);
53 if ($this->page != 1) {
54 $args['page'] = $this->page;
56 common_redirect(common_local_url('showprofiletag', $args), 301);
60 // TRANS: Client error displayed when a tagger is expected but not provided.
61 $this->clientError(_('No tagger.'), 404);
64 $user = User::getKV('nickname', $tagger);
67 // TRANS: Client error displayed trying to perform an action related to a non-existing user.
68 $this->clientError(_('No such user.'), 404);
71 $this->tagger = $user->getProfile();
72 $this->peopletag = Profile_list::pkeyGet(array('tagger' => $user->id, 'tag' => $tag));
74 $current = common_current_user();
75 $can_see = !empty($this->peopletag) && (!$this->peopletag->private ||
76 ($this->peopletag->private && $this->peopletag->tagger === $current->id));
79 // TRANS: Client error displayed trying to reference a non-existing list.
80 $this->clientError(_('No such list.'), 404);
83 $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
84 $this->userProfile = Profile::current();
86 $stream = new PeopletagNoticeStream($this->peopletag, $this->userProfile);
88 $this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE,
89 NOTICES_PER_PAGE + 1);
91 if ($this->page > 1 && $this->notice->N == 0) {
92 // TRANS: Client error when page not found (404).
93 $this->clientError(_('No such page.'), 404);
99 function handle($args)
101 parent::handle($args);
103 if (!$this->peopletag) {
104 // TRANS: Client error displayed trying to perform an action related to a non-existing user.
105 $this->clientError(_('No such user.'));
113 if ($this->page > 1) {
114 if($this->peopletag->private) {
115 // TRANS: Title for private list timeline.
116 // TRANS: %1$s is a list, %2$s is a page number.
117 return sprintf(_('Private timeline for %1$s list by you, page %2$d'),
118 $this->peopletag->tag, $this->page);
121 $current = common_current_user();
122 if (!empty($current) && $current->id == $this->peopletag->tagger) {
123 // TRANS: Title for public list timeline where the viewer is the tagger.
124 // TRANS: %1$s is a list, %2$s is a page number.
125 return sprintf(_('Timeline for %1$s list by you, page %2$d'),
126 $this->peopletag->tag, $this->page);
129 // TRANS: Title for private list timeline.
130 // TRANS: %1$s is a list, %2$s is the tagger's nickname, %3$d is a page number.
131 return sprintf(_('Timeline for %1$s list by %2$s, page %3$d'),
132 $this->peopletag->tag,
133 $this->tagger->nickname,
137 if($this->peopletag->private) {
138 // TRANS: Title for private list timeline.
139 // TRANS: %s is a list.
140 return sprintf(_('Private timeline of %s list by you'),
141 $this->peopletag->tag);
144 $current = common_current_user();
145 if (!empty($current) && $current->id == $this->peopletag->tagger) {
146 // TRANS: Title for public list timeline where the viewer is the tagger.
147 // TRANS: %s is a list.
148 return sprintf(_('Timeline for %s list by you'),
149 $this->peopletag->tag);
152 // TRANS: Title for private list timeline.
153 // TRANS: %1$s is a list, %2$s is the tagger's nickname.
154 return sprintf(_('Timeline for %1$s list by %2$s'),
155 $this->peopletag->tag,
156 $this->tagger->nickname
163 #XXX: make these actually work
164 return array(new Feed(Feed::JSON,
166 'ApiTimelineList', array(
167 'user' => $this->tagger->id,
168 'id' => $this->peopletag->id,
172 // TRANS: Feed title.
173 // TRANS: %s is tagger's nickname.
174 sprintf(_('Feed for friends of %s (Activity Streams JSON)'), $this->tagger->nickname)),
177 'ApiTimelineList', array(
178 'user' => $this->tagger->id,
179 'id' => $this->peopletag->id,
183 // TRANS: Feed title.
184 // TRANS: %s is tagger's nickname.
185 sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->tagger->nickname)),
188 'ApiTimelineList', array(
189 'user' => $this->tagger->id,
190 'id' => $this->peopletag->id,
194 // TRANS: Feed title.
195 // TRANS: %1$s is a list, %2$s is tagger's nickname.
196 sprintf(_('Feed for %1$s list by %2$s (Atom)'),
197 $this->peopletag->tag, $this->tagger->nickname
203 function showObjectNav()
205 $nav = new PeopletagGroupNav($this);
209 function showEmptyListMessage()
211 // TRANS: Empty list message for list timeline.
212 // TRANS: %1$s is a list, %2$s is a tagger's nickname.
213 $message = sprintf(_('This is the timeline for %1$s list by %2$s but no one has posted anything yet.'),
214 $this->peopletag->tag,
215 $this->tagger->nickname) . ' ';
217 if (common_logged_in()) {
218 $current_user = common_current_user();
219 if ($this->tagger->id == $current_user->id) {
220 // TRANS: Additional empty list message for list timeline for currently logged in user tagged tags.
221 $message .= _('Try tagging more people.');
224 // TRANS: Additional empty list message for list timeline.
225 // TRANS: This message contains Markdown links in the form [description](link).
226 $message .= _('Why not [register an account](%%%%action.register%%%%) and start following this timeline!');
229 $this->elementStart('div', 'guide');
230 $this->raw(common_markup_to_html($message));
231 $this->elementEnd('div');
234 function showContent()
236 $this->showPeopletag();
237 $this->showNotices();
240 function showPeopletag()
242 $cur = common_current_user();
243 $tag = new Peopletag($this->peopletag, $cur, $this);
247 function showNotices()
249 if (Event::handle('StartShowProfileTagContent', array($this))) {
250 $nl = new PrimaryNoticeList($this->notice, $this, array('show_n'=>NOTICES_PER_PAGE));
255 $this->showEmptyListMessage();
258 $this->pagination($this->page > 1,
259 $cnt > NOTICES_PER_PAGE,
262 array('tag' => $this->peopletag->tag,
263 'tagger' => $this->tagger->nickname)
266 Event::handle('EndShowProfileTagContent', array($this));
270 function showSections()
273 if (!$this->peopletag->private) {
274 $this->showSubscribers();
276 # $this->showStatistics();
279 function showPageTitle()
281 $this->element('h1', null, $this->title());
284 function showTagged()
286 $profile = $this->peopletag->getTagged(0, PROFILES_PER_MINILIST + 1);
288 $this->elementStart('div', array('id' => 'entity_tagged',
289 'class' => 'section'));
290 if (Event::handle('StartShowTaggedProfilesMiniList', array($this))) {
293 // TRANS: Header on show list page.
294 $this->element('h2', null, _('Listed'));
298 if (!empty($profile)) {
299 $pml = new ProfileMiniList($profile, $this);
302 // TRANS: Content of "Listed" page if there are no listed users.
303 $this->element('p', null, _('(None)'));
307 if ($cnt > PROFILES_PER_MINILIST) {
308 $this->elementStart('p');
309 $this->element('a', array('href' => common_local_url('taggedprofiles',
310 array('nickname' => $this->tagger->nickname,
311 'profiletag' => $this->peopletag->tag)),
313 // TRANS: Link for more "People in list x by a user"
314 // TRANS: if there are more than the mini list's maximum.
316 $this->elementEnd('p');
319 Event::handle('EndShowTaggedProfilesMiniList', array($this));
321 $this->elementEnd('div');
324 function showSubscribers()
326 $profile = $this->peopletag->getSubscribers(0, PROFILES_PER_MINILIST + 1);
328 $this->elementStart('div', array('id' => 'entity_subscribers',
329 'class' => 'section'));
330 if (Event::handle('StartShowProfileTagSubscribersMiniList', array($this))) {
331 // TRANS: Header for tag subscribers.
332 $this->element('h2', null, _('Subscribers'));
336 if (!empty($profile)) {
337 $pml = new ProfileMiniList($profile, $this);
340 // TRANS: Content of "People following tag x" if there are no subscribed users.
341 $this->element('p', null, _('(None)'));
345 // FIXME: link to full list
347 Event::handle('EndShowProfileTagSubscribersMiniList', array($this));
349 $this->elementEnd('div');