3 * StatusNet, the distributed open-source microblogging tool
9 * LICENCE: This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * @author Evan Prodromou <evan@status.net>
25 * @author Sarven Capadisli <csarven@status.net>
26 * @copyright 2008-2009 StatusNet, Inc.
27 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
28 * @link http://status.net/
31 if (!defined('GNUSOCIAL')) { exit(1); }
36 * When I created this page, "show stream" seemed like the best name for it.
37 * Now, it seems like a really bad name.
39 * It shows a stream of the user's posts, plus lots of profile info, links
40 * to subscriptions and stuff, etc.
44 * @author Evan Prodromou <evan@status.net>
45 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
46 * @link http://status.net/
48 class ShowstreamAction extends ProfileAction
52 protected function doPreparation()
54 // showstream requires a nickname
55 $nickname_arg = $this->arg('nickname');
56 $nickname = common_canonical_nickname($nickname_arg);
58 // Permanent redirect on non-canonical nickname
60 if ($nickname_arg != $nickname) {
61 $args = array('nickname' => $nickname);
62 if ($this->arg('page') && $this->arg('page') != 1) {
63 $args['page'] = $this->arg['page'];
65 common_redirect(common_local_url($this->getActionName(), $args), 301);
67 $this->user = User::getKV('nickname', $nickname);
70 $group = Local_group::getKV('nickname', $nickname);
71 if ($group instanceof Local_group) {
72 common_redirect($group->getProfile()->getUrl());
74 // TRANS: Client error displayed when calling a profile action without specifying a user.
75 $this->clientError(_('No such user.'), 404);
78 $this->target = $this->user->getProfile();
81 public function getStream()
83 if (empty($this->tag)) {
84 $stream = new ProfileNoticeStream($this->target, $this->scoped);
86 $stream = new TaggedProfileNoticeStream($this->target, $this->tag, $this->scoped);
95 $base = $this->target->getFancyName();
96 if (!empty($this->tag)) {
97 if ($this->page == 1) {
98 // TRANS: Page title showing tagged notices in one user's timeline.
99 // TRANS: %1$s is the username, %2$s is the hash tag.
100 return sprintf(_('Notices by %1$s tagged %2$s'), $base, $this->tag);
102 // TRANS: Page title showing tagged notices in one user's timeline.
103 // TRANS: %1$s is the username, %2$s is the hash tag, %3$d is the page number.
104 return sprintf(_('Notices by %1$s tagged %2$s, page %3$d'), $base, $this->tag, $this->page);
107 if ($this->page == 1) {
110 // TRANS: Extended page title showing tagged notices in one user's timeline.
111 // TRANS: %1$s is the username, %2$d is the page number.
112 return sprintf(_('Notices by %1$s, page %2$d'),
119 function showContent()
121 $this->showNotices();
124 function showProfileBlock()
126 $block = new AccountProfileBlock($this, $this->target);
130 function showPageNoticeBlock()
137 if (!empty($this->tag)) {
138 return array(new Feed(Feed::RSS1,
139 common_local_url('userrss',
140 array('nickname' => $this->target->getNickname(),
141 'tag' => $this->tag)),
142 // TRANS: Title for link to notice feed.
143 // TRANS: %1$s is a user nickname, %2$s is a hashtag.
144 sprintf(_('Notice feed for %1$s tagged %2$s (RSS 1.0)'),
145 $this->target->getNickname(), $this->tag)));
148 return array(new Feed(Feed::JSON,
149 common_local_url('ApiTimelineUser',
151 'id' => $this->target->getID(),
153 // TRANS: Title for link to notice feed.
154 // TRANS: %s is a user nickname.
155 sprintf(_('Notice feed for %s (Activity Streams JSON)'),
156 $this->target->getNickname())),
158 common_local_url('userrss',
159 array('nickname' => $this->target->getNickname())),
160 // TRANS: Title for link to notice feed.
161 // TRANS: %s is a user nickname.
162 sprintf(_('Notice feed for %s (RSS 1.0)'),
163 $this->target->getNickname())),
165 common_local_url('ApiTimelineUser',
167 'id' => $this->target->getID(),
169 // TRANS: Title for link to notice feed.
170 // TRANS: %s is a user nickname.
171 sprintf(_('Notice feed for %s (RSS 2.0)'),
172 $this->target->getNickname())),
174 common_local_url('ApiTimelineUser',
176 'id' => $this->target->getID(),
177 'format' => 'atom')),
178 // TRANS: Title for link to notice feed.
179 // TRANS: %s is a user nickname.
180 sprintf(_('Notice feed for %s (Atom)'),
181 $this->target->getNickname())),
183 common_local_url('foaf', array('nickname' =>
184 $this->target->getNickname())),
185 // TRANS: Title for link to notice feed. FOAF stands for Friend of a Friend.
186 // TRANS: More information at http://www.foaf-project.org. %s is a user nickname.
187 sprintf(_('FOAF for %s'), $this->target->getNickname())));
192 if ($this->target->bio) {
193 $this->element('meta', array('name' => 'description',
194 'content' => $this->target->getDescription()));
197 if ($this->target->isLocal() && $this->target->getUser()->emailmicroid && $this->target->getUser()->email && $this->target->getUrl()) {
198 $id = new Microid('mailto:'.$this->target->getUser()->email,
200 $this->element('meta', array('name' => 'microid',
201 'content' => $id->toString()));
204 // See https://wiki.mozilla.org/Microsummaries
206 $this->element('link', array('rel' => 'microsummary',
207 'href' => common_local_url('microsummary',
208 array('nickname' => $this->target->getNickname()))));
210 $rsd = common_local_url('rsd',
211 array('nickname' => $this->target->getNickname()));
213 // RSD, http://tales.phrasewise.com/rfc/rsd
214 $this->element('link', array('rel' => 'EditURI',
215 'type' => 'application/rsd+xml',
218 if ($this->page != 1) {
219 $this->element('link', array('rel' => 'canonical',
220 'href' => $this->target->getUrl()));
224 function showEmptyListMessage()
226 // TRANS: First sentence of empty list message for a timeline. $1%s is a user nickname.
227 $message = sprintf(_('This is the timeline for %1$s, but %1$s hasn\'t posted anything yet.'), $this->target->getNickname()) . ' ';
229 if ($this->scoped instanceof Profile) {
230 if ($this->target->getID() === $this->scoped->getID()) {
231 // TRANS: Second sentence of empty list message for a stream for the user themselves.
232 $message .= _('Seen anything interesting recently? You haven\'t posted any notices yet, now would be a good time to start :)');
234 // TRANS: Second sentence of empty list message for a non-self timeline. %1$s is a user nickname, %2$s is a part of a URL.
235 // TRANS: This message contains a Markdown link. Keep "](" together.
236 $message .= sprintf(_('You can try to nudge %1$s or [post something to them](%%%%action.newnotice%%%%?status_textarea=%2$s).'), $this->target->getNickname(), '@' . $this->target->getNickname());
240 // TRANS: Second sentence of empty message for anonymous users. %s is a user nickname.
241 // TRANS: This message contains a Markdown link. Keep "](" together.
242 $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to them.'), $this->target->getNickname());
245 $this->elementStart('div', 'guide');
246 $this->raw(common_markup_to_html($message));
247 $this->elementEnd('div');
250 function showNotices()
252 $pnl = new NoticeList($this->notice, $this);
255 $this->showEmptyListMessage();
258 $args = array('nickname' => $this->target->getNickname());
259 if (!empty($this->tag))
261 $args['tag'] = $this->tag;
263 $this->pagination($this->page>1, $cnt>NOTICES_PER_PAGE, $this->page,
264 'showstream', $args);
267 function showAnonymousMessage()
269 if (!(common_config('site','closed') || common_config('site','inviteonly'))) {
270 // TRANS: Announcement for anonymous users showing a timeline if site registrations are open.
271 // TRANS: This message contains a Markdown link. Keep "](" together.
272 $m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
273 'based on the Free Software [StatusNet](http://status.net/) tool. ' .
274 '[Join now](%%%%action.register%%%%) to follow **%s**\'s notices and many more! ([Read more](%%%%doc.help%%%%))'),
275 $this->target->getNickname(), $this->target->getNickname());
277 // TRANS: Announcement for anonymous users showing a timeline if site registrations are closed or invite only.
278 // TRANS: This message contains a Markdown link. Keep "](" together.
279 $m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
280 'based on the Free Software [StatusNet](http://status.net/) tool.'),
281 $this->target->getNickname(), $this->target->getNickname());
283 $this->elementStart('div', array('id' => 'anon_notice'));
284 $this->raw(common_markup_to_html($m));
285 $this->elementEnd('div');
288 function showSections()
290 parent::showSections();
291 if (!common_config('performance', 'high')) {
292 $cloud = new PersonalTagCloudSection($this, $this->user);
297 function noticeFormOptions()
299 $options = parent::noticeFormOptions();
301 if (!$this->scoped instanceof Profile || $this->scoped->id != $this->target->id) {
302 $options['to_profile'] = $this->target;