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;
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 $this->clientError(_('No tagger.'), 404);
68 $user = User::staticGet('nickname', $tagger);
71 $this->clientError(_('No such user.'), 404);
75 $this->tagger = $user->getProfile();
76 $this->peopletag = Profile_list::pkeyGet(array('tagger' => $user->id, 'tag' => $tag));
78 $current = common_current_user();
79 $can_see = !empty($this->peopletag) && (!$this->peopletag->private ||
80 ($this->peopletag->private && $this->peopletag->tagger === $current->id));
83 $this->clientError(_('No such peopletag.'), 404);
87 $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
88 $this->notice = $this->peopletag->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
90 if ($this->page > 1 && $this->notice->N == 0) {
91 // TRANS: Server error when page not found (404)
92 $this->serverError(_('No such page.'), $code = 404);
98 function handle($args)
100 parent::handle($args);
102 if (!$this->peopletag) {
103 $this->clientError(_('No such user.'));
112 if ($this->page > 1) {
114 if($this->peopletag->private) {
115 return sprintf(_('Private timeline for people tagged %s by you, page %d'),
116 $this->peopletag->tag, $this->page);
119 $current = common_current_user();
120 if (!empty($current) && $current->id == $this->peopletag->tagger) {
121 return sprintf(_('Timeline for people tagged %s by you, page %d'),
122 $this->peopletag->tag, $this->page);
125 // TRANS: Page title. %1$s is user nickname, %2$d is page number
126 return sprintf(_('Timeline for people tagged %1$s by %2$s, page %3$d'),
127 $this->peopletag->tag,
128 $this->tagger->nickname,
133 if($this->peopletag->private) {
134 return sprintf(_('Private timeline of people tagged %s by you'),
135 $this->peopletag->tag, $this->page);
138 $current = common_current_user();
139 if (!empty($current) && $current->id == $this->peopletag->tagger) {
140 return sprintf(_('Timeline for people tagged %s by you'),
141 $this->peopletag->tag, $this->page);
144 // TRANS: Page title. %1$s is user nickname, %2$d is page number
145 return sprintf(_('Timeline for people tagged %1$s by %2$s'),
146 $this->peopletag->tag,
147 $this->tagger->nickname,
155 #XXX: make these actually work
156 return array(new Feed(Feed::RSS2,
158 'ApiTimelineList', array(
159 'user' => $this->tagger->id,
160 'id' => $this->peopletag->id,
164 // TRANS: %1$s is user nickname
165 sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->tagger->nickname)),
168 'ApiTimelineList', array(
169 'user' => $this->tagger->id,
170 'id' => $this->peopletag->id,
174 // TRANS: %1$s is user nickname
175 sprintf(_('Feed for people tagged %s by %s (Atom)'),
176 $this->peopletag->tag, $this->tagger->nickname
182 function showLocalNav()
184 $nav = new PeopletagGroupNav($this);
188 function showEmptyListMessage()
190 // TRANS: %1$s is user nickname
191 $message = sprintf(_('This is the timeline for people tagged %s by %s but no one has posted anything yet.'), $this->peopletag->tag, $this->tagger->nickname) . ' ';
193 if (common_logged_in()) {
194 $current_user = common_current_user();
195 if ($this->tagger->id == $current_user->id) {
196 $message .= _('Try tagging more people.');
199 $message .= _('Why not [register an account](%%%%action.register%%%%) and start following this timeline.');
202 $this->elementStart('div', 'guide');
203 $this->raw(common_markup_to_html($message));
204 $this->elementEnd('div');
207 function showContent()
209 $this->showPeopletag();
210 $this->showNotices();
213 function showPeopletag()
215 $cur = common_current_user();
216 $tag = new Peopletag($this->peopletag, $cur, $this);
220 function showNotices()
222 if (Event::handle('StartShowProfileTagContent', array($this))) {
223 $nl = new NoticeList($this->notice, $this);
228 $this->showEmptyListMessage();
232 $this->page > 1, $cnt > NOTICES_PER_PAGE,
233 $this->page, 'showprofiletag', array('tag' => $this->peopletag->tag,
234 'tagger' => $this->tagger->nickname)
237 Event::handle('EndShowProfileTagContent', array($this));
241 function showSections()
244 if (!$this->peopletag->private) {
245 $this->showSubscribers();
247 # $this->showStatistics();
250 function showPageTitle()
252 $this->element('h1', null, $this->title());
255 function showTagged()
257 $profile = $this->peopletag->getTagged(0, PROFILES_PER_MINILIST + 1);
259 $this->elementStart('div', array('id' => 'entity_tagged',
260 'class' => 'section'));
261 if (Event::handle('StartShowTaggedProfilesMiniList', array($this))) {
265 $current = common_current_user();
266 if(!empty($current) && $this->peopletag->tagger == $current->id) {
267 $title = sprintf(_('People tagged %s by you'), $this->peopletag->tag);
269 $title = sprintf(_('People tagged %1$s by %2$s'),
270 $this->peopletag->tag,
271 $this->tagger->nickname);
274 $this->element('h2', null, $title);
278 if (!empty($profile)) {
279 $pml = new ProfileMiniList($profile, $this);
282 $this->element('p', null, _('(None)'));
286 if ($cnt > PROFILES_PER_MINILIST) {
287 $this->elementStart('p');
288 $this->element('a', array('href' => common_local_url('taggedprofiles',
289 array('nickname' => $this->tagger->nickname,
290 'profiletag' => $this->peopletag->tag)),
293 $this->elementEnd('p');
296 Event::handle('EndShowTaggedProfilesMiniList', array($this));
298 $this->elementEnd('div');
301 function showSubscribers()
303 $profile = $this->peopletag->getSubscribers(0, PROFILES_PER_MINILIST + 1);
305 $this->elementStart('div', array('id' => 'entity_subscribers',
306 'class' => 'section'));
307 if (Event::handle('StartShowProfileTagSubscribersMiniList', array($this))) {
308 $this->element('h2', null, _('Subscribers'));
312 if (!empty($profile)) {
313 $pml = new ProfileMiniList($profile, $this);
316 $this->element('p', null, _('(None)'));
320 if ($cnt > PROFILES_PER_MINILIST) {
321 $this->elementStart('p');
322 $this->element('a', array('href' => common_local_url('profiletagsubscribers',
323 array('nickname' => $this->tagger->nickname,
324 'profiletag' => $this->peopletag->tag)),
326 _('All subscribers'));
327 $this->elementEnd('p');
330 Event::handle('EndShowProfileTagSubscribersMiniList', array($this));
332 $this->elementEnd('div');
336 class Peopletag extends PeopletagListItem
340 $mode = $this->peopletag->private ? 'private' : 'public';
341 $this->out->elementStart('div', array('class' => 'hentry peopletag peopletag-profile mode-'.$mode,
342 'id' => 'peopletag-' . $this->peopletag->id));
347 $this->out->elementEnd('div');
350 function showAvatar()
352 parent::showAvatar(AVATAR_PROFILE_SIZE);