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 if (common_config('singleuser', 'enabled')) {
48 $tagger_arg = User::singleUserNickname();
50 $tagger_arg = $this->arg('tagger');
52 $tag_arg = $this->arg('tag');
53 $tagger = common_canonical_nickname($tagger_arg);
54 $tag = common_canonical_tag($tag_arg);
56 // Permanent redirect on non-canonical nickname
58 if ($tagger_arg != $tagger || $tag_arg != $tag) {
59 $args = array('tagger' => $nickname, 'tag' => $tag);
60 if ($this->page != 1) {
61 $args['page'] = $this->page;
63 common_redirect(common_local_url('showprofiletag', $args), 301);
67 // TRANS: Client error displayed when a tagger is expected but not provided.
68 $this->clientError(_('No tagger.'), 404);
71 $user = User::getKV('nickname', $tagger);
74 // TRANS: Client error displayed trying to perform an action related to a non-existing user.
75 $this->clientError(_('No such user.'), 404);
78 $this->tagger = $user->getProfile();
79 $this->peopletag = Profile_list::pkeyGet(array('tagger' => $user->id, 'tag' => $tag));
81 $current = common_current_user();
82 $can_see = !empty($this->peopletag) && (!$this->peopletag->private ||
83 ($this->peopletag->private && $this->peopletag->tagger === $current->id));
86 // TRANS: Client error displayed trying to reference a non-existing list.
87 $this->clientError(_('No such list.'), 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: Client error when page not found (404).
100 $this->clientError(_('No such page.'), 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.'));
120 if ($this->page > 1) {
121 if($this->peopletag->private) {
122 // TRANS: Title for private list timeline.
123 // TRANS: %1$s is a list, %2$s is a page number.
124 return sprintf(_('Private timeline for %1$s list by you, page %2$d'),
125 $this->peopletag->tag, $this->page);
128 $current = common_current_user();
129 if (!empty($current) && $current->id == $this->peopletag->tagger) {
130 // TRANS: Title for public list timeline where the viewer is the tagger.
131 // TRANS: %1$s is a list, %2$s is a page number.
132 return sprintf(_('Timeline for %1$s list by you, page %2$d'),
133 $this->peopletag->tag, $this->page);
136 // TRANS: Title for private list timeline.
137 // TRANS: %1$s is a list, %2$s is the tagger's nickname, %3$d is a page number.
138 return sprintf(_('Timeline for %1$s list by %2$s, page %3$d'),
139 $this->peopletag->tag,
140 $this->tagger->nickname,
144 if($this->peopletag->private) {
145 // TRANS: Title for private list timeline.
146 // TRANS: %s is a list.
147 return sprintf(_('Private timeline of %s list by you'),
148 $this->peopletag->tag);
151 $current = common_current_user();
152 if (!empty($current) && $current->id == $this->peopletag->tagger) {
153 // TRANS: Title for public list timeline where the viewer is the tagger.
154 // TRANS: %s is a list.
155 return sprintf(_('Timeline for %s list by you'),
156 $this->peopletag->tag);
159 // TRANS: Title for private list timeline.
160 // TRANS: %1$s is a list, %2$s is the tagger's nickname.
161 return sprintf(_('Timeline for %1$s list by %2$s'),
162 $this->peopletag->tag,
163 $this->tagger->nickname
170 #XXX: make these actually work
171 return array(new Feed(Feed::JSON,
173 'ApiTimelineList', array(
174 'user' => $this->tagger->id,
175 'id' => $this->peopletag->id,
179 // TRANS: Feed title.
180 // TRANS: %s is tagger's nickname.
181 sprintf(_('Feed for friends of %s (Activity Streams JSON)'), $this->tagger->nickname)),
184 'ApiTimelineList', array(
185 'user' => $this->tagger->id,
186 'id' => $this->peopletag->id,
190 // TRANS: Feed title.
191 // TRANS: %s is tagger's nickname.
192 sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->tagger->nickname)),
195 'ApiTimelineList', array(
196 'user' => $this->tagger->id,
197 'id' => $this->peopletag->id,
201 // TRANS: Feed title.
202 // TRANS: %1$s is a list, %2$s is tagger's nickname.
203 sprintf(_('Feed for %1$s list by %2$s (Atom)'),
204 $this->peopletag->tag, $this->tagger->nickname
210 function showObjectNav()
212 $nav = new PeopletagGroupNav($this);
216 function showEmptyListMessage()
218 // TRANS: Empty list message for list timeline.
219 // TRANS: %1$s is a list, %2$s is a tagger's nickname.
220 $message = sprintf(_('This is the timeline for %1$s list by %2$s but no one has posted anything yet.'),
221 $this->peopletag->tag,
222 $this->tagger->nickname) . ' ';
224 if (common_logged_in()) {
225 $current_user = common_current_user();
226 if ($this->tagger->id == $current_user->id) {
227 // TRANS: Additional empty list message for list timeline for currently logged in user tagged tags.
228 $message .= _('Try tagging more people.');
231 // TRANS: Additional empty list message for list timeline.
232 // TRANS: This message contains Markdown links in the form [description](link).
233 $message .= _('Why not [register an account](%%%%action.register%%%%) and start following this timeline!');
236 $this->elementStart('div', 'guide');
237 $this->raw(common_markup_to_html($message));
238 $this->elementEnd('div');
241 function showContent()
243 $this->showPeopletag();
244 $this->showNotices();
247 function showPeopletag()
249 $cur = common_current_user();
250 $tag = new Peopletag($this->peopletag, $cur, $this);
254 function showNotices()
256 if (Event::handle('StartShowProfileTagContent', array($this))) {
257 $nl = new PrimaryNoticeList($this->notice, $this, array('show_n'=>NOTICES_PER_PAGE));
262 $this->showEmptyListMessage();
265 $this->pagination($this->page > 1,
266 $cnt > NOTICES_PER_PAGE,
269 array('tag' => $this->peopletag->tag,
270 'tagger' => $this->tagger->nickname)
273 Event::handle('EndShowProfileTagContent', array($this));
277 function showSections()
280 if (!$this->peopletag->private) {
281 $this->showSubscribers();
283 # $this->showStatistics();
286 function showPageTitle()
288 $this->element('h1', null, $this->title());
291 function showTagged()
293 $profile = $this->peopletag->getTagged(0, PROFILES_PER_MINILIST + 1);
295 $this->elementStart('div', array('id' => 'entity_tagged',
296 'class' => 'section'));
297 if (Event::handle('StartShowTaggedProfilesMiniList', array($this))) {
300 // TRANS: Header on show list page.
301 $this->element('h2', null, _('Listed'));
305 if (!empty($profile)) {
306 $pml = new ProfileMiniList($profile, $this);
309 // TRANS: Content of "Listed" page if there are no listed users.
310 $this->element('p', null, _('(None)'));
314 if ($cnt > PROFILES_PER_MINILIST) {
315 $this->elementStart('p');
316 $this->element('a', array('href' => common_local_url('taggedprofiles',
317 array('nickname' => $this->tagger->nickname,
318 'profiletag' => $this->peopletag->tag)),
320 // TRANS: Link for more "People in list x by a user"
321 // TRANS: if there are more than the mini list's maximum.
323 $this->elementEnd('p');
326 Event::handle('EndShowTaggedProfilesMiniList', array($this));
328 $this->elementEnd('div');
331 function showSubscribers()
333 $profile = $this->peopletag->getSubscribers(0, PROFILES_PER_MINILIST + 1);
335 $this->elementStart('div', array('id' => 'entity_subscribers',
336 'class' => 'section'));
337 if (Event::handle('StartShowProfileTagSubscribersMiniList', array($this))) {
338 // TRANS: Header for tag subscribers.
339 $this->element('h2', null, _('Subscribers'));
343 if (!empty($profile)) {
344 $pml = new ProfileMiniList($profile, $this);
347 // TRANS: Content of "People following tag x" if there are no subscribed users.
348 $this->element('p', null, _('(None)'));
352 // FIXME: link to full list
354 Event::handle('EndShowProfileTagSubscribersMiniList', array($this));
356 $this->elementEnd('div');
360 class Peopletag extends PeopletagListItem
362 protected $avatarSize = AVATAR_PROFILE_SIZE;
366 $mode = $this->peopletag->private ? 'private' : 'public';
367 $this->out->elementStart('div', array('class' => 'h-entry peopletag peopletag-profile mode-'.$mode,
368 'id' => 'peopletag-' . $this->peopletag->id));
373 $this->out->elementEnd('div');