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);
68 // TRANS: Client error displayed when a tagger is expected but not provided.
69 $this->clientError(_('No tagger.'), 404);
73 $user = User::getKV('nickname', $tagger);
76 // TRANS: Client error displayed trying to perform an action related to a non-existing user.
77 $this->clientError(_('No such user.'), 404);
81 $this->tagger = $user->getProfile();
82 $this->peopletag = Profile_list::pkeyGet(array('tagger' => $user->id, 'tag' => $tag));
84 $current = common_current_user();
85 $can_see = !empty($this->peopletag) && (!$this->peopletag->private ||
86 ($this->peopletag->private && $this->peopletag->tagger === $current->id));
89 // TRANS: Client error displayed trying to reference a non-existing list.
90 $this->clientError(_('No such list.'), 404);
94 $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
95 $this->userProfile = Profile::current();
97 $stream = new PeopletagNoticeStream($this->peopletag, $this->userProfile);
99 $this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE,
100 NOTICES_PER_PAGE + 1);
102 if ($this->page > 1 && $this->notice->N == 0) {
103 // TRANS: Server error when page not found (404).
104 $this->serverError(_('No such page.'), $code = 404);
110 function handle($args)
112 parent::handle($args);
114 if (!$this->peopletag) {
115 // TRANS: Client error displayed trying to perform an action related to a non-existing user.
116 $this->clientError(_('No such user.'));
125 if ($this->page > 1) {
126 if($this->peopletag->private) {
127 // TRANS: Title for private list timeline.
128 // TRANS: %1$s is a list, %2$s is a page number.
129 return sprintf(_('Private timeline for %1$s list by you, page %2$d'),
130 $this->peopletag->tag, $this->page);
133 $current = common_current_user();
134 if (!empty($current) && $current->id == $this->peopletag->tagger) {
135 // TRANS: Title for public list timeline where the viewer is the tagger.
136 // TRANS: %1$s is a list, %2$s is a page number.
137 return sprintf(_('Timeline for %1$s list by you, page %2$d'),
138 $this->peopletag->tag, $this->page);
141 // TRANS: Title for private list timeline.
142 // TRANS: %1$s is a list, %2$s is the tagger's nickname, %3$d is a page number.
143 return sprintf(_('Timeline for %1$s list by %2$s, page %3$d'),
144 $this->peopletag->tag,
145 $this->tagger->nickname,
149 if($this->peopletag->private) {
150 // TRANS: Title for private list timeline.
151 // TRANS: %s is a list.
152 return sprintf(_('Private timeline of %s list by you'),
153 $this->peopletag->tag);
156 $current = common_current_user();
157 if (!empty($current) && $current->id == $this->peopletag->tagger) {
158 // TRANS: Title for public list timeline where the viewer is the tagger.
159 // TRANS: %s is a list.
160 return sprintf(_('Timeline for %s list by you'),
161 $this->peopletag->tag);
164 // TRANS: Title for private list timeline.
165 // TRANS: %1$s is a list, %2$s is the tagger's nickname.
166 return sprintf(_('Timeline for %1$s list by %2$s'),
167 $this->peopletag->tag,
168 $this->tagger->nickname
175 #XXX: make these actually work
176 return array(new Feed(Feed::JSON,
178 'ApiTimelineList', array(
179 'user' => $this->tagger->id,
180 'id' => $this->peopletag->id,
184 // TRANS: Feed title.
185 // TRANS: %s is tagger's nickname.
186 sprintf(_('Feed for friends of %s (Activity Streams JSON)'), $this->tagger->nickname)),
189 'ApiTimelineList', array(
190 'user' => $this->tagger->id,
191 'id' => $this->peopletag->id,
195 // TRANS: Feed title.
196 // TRANS: %s is tagger's nickname.
197 sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->tagger->nickname)),
200 'ApiTimelineList', array(
201 'user' => $this->tagger->id,
202 'id' => $this->peopletag->id,
206 // TRANS: Feed title.
207 // TRANS: %1$s is a list, %2$s is tagger's nickname.
208 sprintf(_('Feed for %1$s list by %2$s (Atom)'),
209 $this->peopletag->tag, $this->tagger->nickname
215 function showObjectNav()
217 $nav = new PeopletagGroupNav($this);
221 function showEmptyListMessage()
223 // TRANS: Empty list message for list timeline.
224 // TRANS: %1$s is a list, %2$s is a tagger's nickname.
225 $message = sprintf(_('This is the timeline for %1$s list by %2$s but no one has posted anything yet.'),
226 $this->peopletag->tag,
227 $this->tagger->nickname) . ' ';
229 if (common_logged_in()) {
230 $current_user = common_current_user();
231 if ($this->tagger->id == $current_user->id) {
232 // TRANS: Additional empty list message for list timeline for currently logged in user tagged tags.
233 $message .= _('Try tagging more people.');
236 // TRANS: Additional empty list message for list timeline.
237 // TRANS: This message contains Markdown links in the form [description](link).
238 $message .= _('Why not [register an account](%%%%action.register%%%%) and start following this timeline!');
241 $this->elementStart('div', 'guide');
242 $this->raw(common_markup_to_html($message));
243 $this->elementEnd('div');
246 function showContent()
248 $this->showPeopletag();
249 $this->showNotices();
252 function showPeopletag()
254 $cur = common_current_user();
255 $tag = new Peopletag($this->peopletag, $cur, $this);
259 function showNotices()
261 if (Event::handle('StartShowProfileTagContent', array($this))) {
262 $nl = new NoticeList($this->notice, $this);
267 $this->showEmptyListMessage();
270 $this->pagination($this->page > 1,
271 $cnt > NOTICES_PER_PAGE,
274 array('tag' => $this->peopletag->tag,
275 'tagger' => $this->tagger->nickname)
278 Event::handle('EndShowProfileTagContent', array($this));
282 function showSections()
285 if (!$this->peopletag->private) {
286 $this->showSubscribers();
288 # $this->showStatistics();
291 function showPageTitle()
293 $this->element('h1', null, $this->title());
296 function showTagged()
298 $profile = $this->peopletag->getTagged(0, PROFILES_PER_MINILIST + 1);
300 $this->elementStart('div', array('id' => 'entity_tagged',
301 'class' => 'section'));
302 if (Event::handle('StartShowTaggedProfilesMiniList', array($this))) {
305 // TRANS: Header on show list page.
306 $this->element('h2', null, _('Listed'));
310 if (!empty($profile)) {
311 $pml = new ProfileMiniList($profile, $this);
314 // TRANS: Content of "Listed" page if there are no listed users.
315 $this->element('p', null, _('(None)'));
319 if ($cnt > PROFILES_PER_MINILIST) {
320 $this->elementStart('p');
321 $this->element('a', array('href' => common_local_url('taggedprofiles',
322 array('nickname' => $this->tagger->nickname,
323 'profiletag' => $this->peopletag->tag)),
325 // TRANS: Link for more "People in list x by a user"
326 // TRANS: if there are more than the mini list's maximum.
328 $this->elementEnd('p');
331 Event::handle('EndShowTaggedProfilesMiniList', array($this));
333 $this->elementEnd('div');
336 function showSubscribers()
338 $profile = $this->peopletag->getSubscribers(0, PROFILES_PER_MINILIST + 1);
340 $this->elementStart('div', array('id' => 'entity_subscribers',
341 'class' => 'section'));
342 if (Event::handle('StartShowProfileTagSubscribersMiniList', array($this))) {
343 // TRANS: Header for tag subscribers.
344 $this->element('h2', null, _('Subscribers'));
348 if (!empty($profile)) {
349 $pml = new ProfileMiniList($profile, $this);
352 // TRANS: Content of "People following tag x" if there are no subscribed users.
353 $this->element('p', null, _('(None)'));
357 // FIXME: link to full list
359 Event::handle('EndShowProfileTagSubscribersMiniList', array($this));
361 $this->elementEnd('div');
365 class Peopletag extends PeopletagListItem
369 $mode = $this->peopletag->private ? 'private' : 'public';
370 $this->out->elementStart('div', array('class' => 'hentry peopletag peopletag-profile mode-'.$mode,
371 'id' => 'peopletag-' . $this->peopletag->id));
376 $this->out->elementEnd('div');
379 function showAvatar()
381 parent::showAvatar(AVATAR_PROFILE_SIZE);