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 ShowstreamAction
29 var $notice, $peopletag;
31 protected function doStreamPreparation()
33 $tag = common_canonical_tag($this->arg('tag'));
35 $this->peopletag = Profile_list::getByPK(array('tagger' => $this->target->getID(), 'tag' => $tag));
36 } catch (NoResultException $e) {
37 // TRANS: Client error displayed trying to reference a non-existing list.
38 throw new ClientException('No such list.');
41 if ($this->peopletag->private && !$this->peopletag->getTagger()->sameAs($this->scoped)) {
42 // TRANS: Client error displayed trying to reference a non-existing list.
43 throw new AuthorizationException('You do not have permission to see this list.');
47 public function getStream()
49 return new PeopletagNoticeStream($this->peopletag, $this->scoped);
54 if ($this->page > 1) {
55 if($this->peopletag->private) {
56 // TRANS: Title for private list timeline.
57 // TRANS: %1$s is a list, %2$s is a page number.
58 return sprintf(_('Private timeline for %1$s list by you, page %2$d'),
59 $this->peopletag->tag, $this->page);
62 $current = common_current_user();
63 if (!empty($current) && $current->id == $this->peopletag->tagger) {
64 // TRANS: Title for public list timeline where the viewer is the tagger.
65 // TRANS: %1$s is a list, %2$s is a page number.
66 return sprintf(_('Timeline for %1$s list by you, page %2$d'),
67 $this->peopletag->tag, $this->page);
70 // TRANS: Title for private list timeline.
71 // TRANS: %1$s is a list, %2$s is the tagger's nickname, %3$d is a page number.
72 return sprintf(_('Timeline for %1$s list by %2$s, page %3$d'),
73 $this->peopletag->tag,
74 $this->target->getNickname(),
78 if($this->peopletag->private) {
79 // TRANS: Title for private list timeline.
80 // TRANS: %s is a list.
81 return sprintf(_('Private timeline of %s list by you'),
82 $this->peopletag->tag);
85 $current = common_current_user();
86 if (!empty($current) && $current->id == $this->peopletag->tagger) {
87 // TRANS: Title for public list timeline where the viewer is the tagger.
88 // TRANS: %s is a list.
89 return sprintf(_('Timeline for %s list by you'),
90 $this->peopletag->tag);
93 // TRANS: Title for private list timeline.
94 // TRANS: %1$s is a list, %2$s is the tagger's nickname.
95 return sprintf(_('Timeline for %1$s list by %2$s'),
96 $this->peopletag->tag,
97 $this->target->getNickname()
104 #XXX: make these actually work
105 return array(new Feed(Feed::JSON,
107 'ApiTimelineList', array(
108 'user' => $this->target->id,
109 'id' => $this->peopletag->id,
113 // TRANS: Feed title.
114 // TRANS: %s is tagger's nickname.
115 sprintf(_('Feed for friends of %s (Activity Streams JSON)'), $this->target->getNickname())),
118 'ApiTimelineList', array(
119 'user' => $this->target->id,
120 'id' => $this->peopletag->id,
124 // TRANS: Feed title.
125 // TRANS: %s is tagger's nickname.
126 sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->target->getNickname())),
129 'ApiTimelineList', array(
130 'user' => $this->target->id,
131 'id' => $this->peopletag->id,
135 // TRANS: Feed title.
136 // TRANS: %1$s is a list, %2$s is tagger's nickname.
137 sprintf(_('Feed for %1$s list by %2$s (Atom)'),
138 $this->peopletag->tag, $this->target->getNickname()
144 function showObjectNav()
146 $nav = new PeopletagGroupNav($this);
150 function showEmptyListMessage()
152 // TRANS: Empty list message for list timeline.
153 // TRANS: %1$s is a list, %2$s is a tagger's nickname.
154 $message = sprintf(_('This is the timeline for %1$s list by %2$s but no one has posted anything yet.'),
155 $this->peopletag->tag,
156 $this->target->getNickname()) . ' ';
158 if (common_logged_in()) {
159 if ($this->target->sameAs($this->scoped)) {
160 // TRANS: Additional empty list message for list timeline for currently logged in user tagged tags.
161 $message .= _('Try tagging more people.');
164 // TRANS: Additional empty list message for list timeline.
165 // TRANS: This message contains Markdown links in the form [description](link).
166 $message .= _('Why not [register an account](%%%%action.register%%%%) and start following this timeline!');
169 $this->elementStart('div', 'guide');
170 $this->raw(common_markup_to_html($message));
171 $this->elementEnd('div');
174 protected function showContent()
176 $this->showPeopletag();
177 parent::showContent();
180 function showPeopletag()
182 $tag = new Peopletag($this->peopletag, $this->scoped, $this);
186 function showNotices()
188 if (Event::handle('StartShowProfileTagContent', array($this))) {
189 $nl = new PrimaryNoticeList($this->notice, $this, array('show_n'=>NOTICES_PER_PAGE));
194 $this->showEmptyListMessage();
197 $this->pagination($this->page > 1,
198 $cnt > NOTICES_PER_PAGE,
201 array('tag' => $this->peopletag->tag,
202 'nickname' => $this->target->getNickname())
205 Event::handle('EndShowProfileTagContent', array($this));
209 function showSections()
212 if (!$this->peopletag->private) {
213 $this->showSubscribers();
215 # $this->showStatistics();
218 function showTagged()
220 $profile = $this->peopletag->getTagged(0, PROFILES_PER_MINILIST + 1);
222 $this->elementStart('div', array('id' => 'entity_tagged',
223 'class' => 'section'));
224 if (Event::handle('StartShowTaggedProfilesMiniList', array($this))) {
227 // TRANS: Header on show list page.
228 $this->element('h2', null, _('Listed'));
232 if (!empty($profile)) {
233 $pml = new ProfileMiniList($profile, $this);
236 // TRANS: Content of "Listed" page if there are no listed users.
237 $this->element('p', null, _('(None)'));
241 if ($cnt > PROFILES_PER_MINILIST) {
242 $this->elementStart('p');
243 $this->element('a', array('href' => common_local_url('taggedprofiles',
244 array('nickname' => $this->target->getNickname(),
245 'profiletag' => $this->peopletag->tag)),
247 // TRANS: Link for more "People in list x by a user"
248 // TRANS: if there are more than the mini list's maximum.
250 $this->elementEnd('p');
253 Event::handle('EndShowTaggedProfilesMiniList', array($this));
255 $this->elementEnd('div');
258 function showSubscribers()
260 $profile = $this->peopletag->getSubscribers(0, PROFILES_PER_MINILIST + 1);
262 $this->elementStart('div', array('id' => 'entity_subscribers',
263 'class' => 'section'));
264 if (Event::handle('StartShowProfileTagSubscribersMiniList', array($this))) {
265 // TRANS: Header for tag subscribers.
266 $this->element('h2', null, _('Subscribers'));
270 if (!empty($profile)) {
271 $pml = new ProfileMiniList($profile, $this);
274 // TRANS: Content of "People following tag x" if there are no subscribed users.
275 $this->element('p', null, _('(None)'));
279 // FIXME: link to full list
281 Event::handle('EndShowProfileTagSubscribersMiniList', array($this));
283 $this->elementEnd('div');