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('STATUSNET') && !defined('LACONICA')) {
29 require_once INSTALLDIR.'/lib/profileminilist.php';
30 require_once INSTALLDIR.'/lib/peopletaglist.php';
31 require_once INSTALLDIR.'/lib/noticelist.php';
32 require_once INSTALLDIR.'/lib/feedlist.php';
34 class ShowprofiletagAction extends Action
36 var $notice, $tagger, $peopletag, $userProfile;
38 function isReadOnly($args)
43 function prepare($args)
45 parent::prepare($args);
47 $tagger_arg = $this->arg('tagger');
48 $tag_arg = $this->arg('tag');
49 $tagger = common_canonical_nickname($tagger_arg);
50 $tag = common_canonical_tag($tag_arg);
52 // Permanent redirect on non-canonical nickname
54 if ($tagger_arg != $tagger || $tag_arg != $tag) {
55 $args = array('tagger' => $nickname, 'tag' => $tag);
56 if ($this->page != 1) {
57 $args['page'] = $this->page;
59 common_redirect(common_local_url('showprofiletag', $args), 301);
64 // TRANS: Client error displayed when a tagger is expected but not provided.
65 $this->clientError(_('No tagger.'), 404);
69 $user = User::staticGet('nickname', $tagger);
72 // TRANS: Client error displayed trying to perform an action related to a non-existing user.
73 $this->clientError(_('No such user.'), 404);
77 $this->tagger = $user->getProfile();
78 $this->peopletag = Profile_list::pkeyGet(array('tagger' => $user->id, 'tag' => $tag));
80 $current = common_current_user();
81 $can_see = !empty($this->peopletag) && (!$this->peopletag->private ||
82 ($this->peopletag->private && $this->peopletag->tagger === $current->id));
85 // TRANS: Client error displayed trying to reference a non-existing people tag.
86 $this->clientError(_('No such people tag.'), 404);
90 $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
91 $this->userProfile = Profile::current();
93 $stream = new PeopletagNoticeStream($this->peopletag, $this->userProfile);
95 $this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE,
96 NOTICES_PER_PAGE + 1);
98 if ($this->page > 1 && $this->notice->N == 0) {
99 // TRANS: Server error when page not found (404).
100 $this->serverError(_('No such page.'), $code = 404);
106 function handle($args)
108 parent::handle($args);
110 if (!$this->peopletag) {
111 // TRANS: Client error displayed trying to perform an action related to a non-existing user.
112 $this->clientError(_('No such user.'));
121 if ($this->page > 1) {
122 if($this->peopletag->private) {
123 // TRANS: Title for private list timeline.
124 // TRANS: %1$s is a people tag, %2$s is a page number.
125 return sprintf(_('Private timeline for %1$s list by you, page %2$d'),
126 $this->peopletag->tag, $this->page);
129 $current = common_current_user();
130 if (!empty($current) && $current->id == $this->peopletag->tagger) {
131 // TRANS: Title for public list timeline where the viewer is the tagger.
132 // TRANS: %1$s is a people tag, %2$s is a page number.
133 return sprintf(_('Timeline for %1$s list by you, page %2$d'),
134 $this->peopletag->tag, $this->page);
137 // TRANS: Title for private list timeline.
138 // TRANS: %1$s is a people tag, %2$s is the tagger's nickname, %3$d is a page number.
139 return sprintf(_('Timeline for %1$s list by %2$s, page %3$d'),
140 $this->peopletag->tag,
141 $this->tagger->nickname,
145 if($this->peopletag->private) {
146 // TRANS: Title for private list timeline.
147 // TRANS: %s is a list.
148 return sprintf(_('Private timeline of %s list by you'),
149 $this->peopletag->tag);
152 $current = common_current_user();
153 if (!empty($current) && $current->id == $this->peopletag->tagger) {
154 // TRANS: Title for public list timeline where the viewer is the tagger.
155 // TRANS: %s is a list.
156 return sprintf(_('Timeline for %s list by you'),
157 $this->peopletag->tag);
160 // TRANS: Title for private list timeline.
161 // TRANS: %1$s is a list, %2$s is the tagger's nickname.
162 return sprintf(_('Timeline for %1$s list by %2$s'),
163 $this->peopletag->tag,
164 $this->tagger->nickname
171 #XXX: make these actually work
172 return array(new Feed(Feed::RSS2,
174 'ApiTimelineList', array(
175 'user' => $this->tagger->id,
176 'id' => $this->peopletag->id,
180 // TRANS: Feed title.
181 // TRANS: %s is tagger's nickname.
182 sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->tagger->nickname)),
185 'ApiTimelineList', array(
186 'user' => $this->tagger->id,
187 'id' => $this->peopletag->id,
191 // TRANS: Feed title.
192 // TRANS: %1$s is a list, %2$s is tagger's nickname.
193 sprintf(_('Feed for %1$s list by %2$s (Atom)'),
194 $this->peopletag->tag, $this->tagger->nickname
200 function showObjectNav()
202 $nav = new PeopletagGroupNav($this);
206 function showEmptyListMessage()
208 // TRANS: Empty list message for list timeline.
209 // TRANS: %1$s is a list, %2$s is a tagger's nickname.
210 $message = sprintf(_('This is the timeline for %1$s list by %2$s but no one has posted anything yet.'),
211 $this->peopletag->tag,
212 $this->tagger->nickname) . ' ';
214 if (common_logged_in()) {
215 $current_user = common_current_user();
216 if ($this->tagger->id == $current_user->id) {
217 // TRANS: Additional empty list message for people tag timeline for currently logged in user tagged tags.
218 $message .= _('Try tagging more people.');
221 // TRANS: Additional empty list message for people tag timeline.
222 // TRANS: This message contains Markdown links in the form [description](link).
223 $message .= _('Why not [register an account](%%%%action.register%%%%) and start following this timeline!');
226 $this->elementStart('div', 'guide');
227 $this->raw(common_markup_to_html($message));
228 $this->elementEnd('div');
231 function showContent()
233 $this->showPeopletag();
234 $this->showNotices();
237 function showPeopletag()
239 $cur = common_current_user();
240 $tag = new Peopletag($this->peopletag, $cur, $this);
244 function showNotices()
246 if (Event::handle('StartShowProfileTagContent', array($this))) {
247 $nl = new ThreadedNoticeList($this->notice, $this, $this->userProfile);
252 $this->showEmptyListMessage();
255 $this->pagination($this->page > 1,
256 $cnt > NOTICES_PER_PAGE,
259 array('tag' => $this->peopletag->tag,
260 'tagger' => $this->tagger->nickname)
263 Event::handle('EndShowProfileTagContent', array($this));
267 function showSections()
270 if (!$this->peopletag->private) {
271 $this->showSubscribers();
273 # $this->showStatistics();
276 function showPageTitle()
278 $this->element('h1', null, $this->title());
281 function showTagged()
283 $profile = $this->peopletag->getTagged(0, PROFILES_PER_MINILIST + 1);
285 $this->elementStart('div', array('id' => 'entity_tagged',
286 'class' => 'section'));
287 if (Event::handle('StartShowTaggedProfilesMiniList', array($this))) {
290 // TRANS: Header on show list page.
291 $this->element('h2', null, _('Listed'));
295 if (!empty($profile)) {
296 $pml = new ProfileMiniList($profile, $this);
299 // TRANS: Content of "Listed" page if there are no listed users.
300 $this->element('p', null, _('(None)'));
304 if ($cnt > PROFILES_PER_MINILIST) {
305 $this->elementStart('p');
306 $this->element('a', array('href' => common_local_url('taggedprofiles',
307 array('nickname' => $this->tagger->nickname,
308 'profiletag' => $this->peopletag->tag)),
310 // TRANS: Link for more "People tagged x by a user"
311 // TRANS: if there are more than the mini list's maximum.
313 $this->elementEnd('p');
316 Event::handle('EndShowTaggedProfilesMiniList', array($this));
318 $this->elementEnd('div');
321 function showSubscribers()
323 $profile = $this->peopletag->getSubscribers(0, PROFILES_PER_MINILIST + 1);
325 $this->elementStart('div', array('id' => 'entity_subscribers',
326 'class' => 'section'));
327 if (Event::handle('StartShowProfileTagSubscribersMiniList', array($this))) {
328 // TRANS: Header for tag subscribers.
329 $this->element('h2', null, _('Subscribers'));
333 if (!empty($profile)) {
334 $pml = new ProfileMiniList($profile, $this);
337 // TRANS: Content of "People following tag x" if there are no subscribed users.
338 $this->element('p', null, _('(None)'));
342 if ($cnt > PROFILES_PER_MINILIST) {
343 $this->elementStart('p');
344 $this->element('a', array('href' => common_local_url('profiletagsubscribers',
345 array('nickname' => $this->tagger->nickname,
346 'profiletag' => $this->peopletag->tag)),
348 // TRANS: Link for more "People following tag x"
349 // TRANS: if there are more than the mini list's maximum.
350 _('All subscribers'));
351 $this->elementEnd('p');
354 Event::handle('EndShowProfileTagSubscribersMiniList', array($this));
356 $this->elementEnd('div');
360 class Peopletag extends PeopletagListItem
364 $mode = $this->peopletag->private ? 'private' : 'public';
365 $this->out->elementStart('div', array('class' => 'hentry peopletag peopletag-profile mode-'.$mode,
366 'id' => 'peopletag-' . $this->peopletag->id));
371 $this->out->elementEnd('div');
374 function showAvatar()
376 parent::showAvatar(AVATAR_PROFILE_SIZE);