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('STATUSNET') && !defined('LACONICA')) {
35 require_once INSTALLDIR.'/lib/personalgroupnav.php';
36 require_once INSTALLDIR.'/lib/noticelist.php';
37 require_once INSTALLDIR.'/lib/profileminilist.php';
38 require_once INSTALLDIR.'/lib/groupminilist.php';
39 require_once INSTALLDIR.'/lib/feedlist.php';
44 * When I created this page, "show stream" seemed like the best name for it.
45 * Now, it seems like a really bad name.
47 * It shows a stream of the user's posts, plus lots of profile info, links
48 * to subscriptions and stuff, etc.
52 * @author Evan Prodromou <evan@status.net>
53 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
54 * @link http://status.net/
56 class ShowstreamAction extends ProfileAction
60 function prepare($args)
62 parent::prepare($args);
64 $p = Profile::current();
66 if (empty($this->tag)) {
67 $stream = new ProfileNoticeStream($this->profile, $p);
69 $stream = new TaggedProfileNoticeStream($this->profile, $this->tag, $p);
72 $this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
77 function isReadOnly($args)
84 $base = $this->profile->getFancyName();
85 if (!empty($this->tag)) {
86 if ($this->page == 1) {
87 // TRANS: Page title showing tagged notices in one user's timeline.
88 // TRANS: %1$s is the username, %2$s is the hash tag.
89 return sprintf(_('Notices by %1$s tagged %2$s'), $base, $this->tag);
91 // TRANS: Page title showing tagged notices in one user's timeline.
92 // TRANS: %1$s is the username, %2$s is the hash tag, %3$d is the page number.
93 return sprintf(_('Notices by %1$s tagged %2$s, page %3$d'), $base, $this->tag, $this->page);
96 if ($this->page == 1) {
99 // TRANS: Extended page title showing tagged notices in one user's timeline.
100 // TRANS: %1$s is the username, %2$d is the page number.
101 return sprintf(_('Notices by %1$s, page %2$d'),
108 function handle($args)
110 // Looks like we're good; start output
112 // For YADIS discovery, we also have a <meta> tag
117 function showContent()
119 $this->showNotices();
122 function showProfileBlock()
124 $block = new AccountProfileBlock($this, $this->profile);
128 function showPageNoticeBlock()
135 if (!empty($this->tag)) {
136 return array(new Feed(Feed::RSS1,
137 common_local_url('userrss',
138 array('nickname' => $this->user->nickname,
139 'tag' => $this->tag)),
140 // TRANS: Title for link to notice feed.
141 // TRANS: %1$s is a user nickname, %2$s is a hashtag.
142 sprintf(_('Notice feed for %1$s tagged %2$s (RSS 1.0)'),
143 $this->user->nickname, $this->tag)));
146 return array(new Feed(Feed::JSON,
147 common_local_url('ApiTimelineUser',
149 'id' => $this->user->id,
151 // TRANS: Title for link to notice feed.
152 // TRANS: %s is a user nickname.
153 sprintf(_('Notice feed for %s (Activity Streams JSON)'),
154 $this->user->nickname)),
156 common_local_url('userrss',
157 array('nickname' => $this->user->nickname)),
158 // TRANS: Title for link to notice feed.
159 // TRANS: %s is a user nickname.
160 sprintf(_('Notice feed for %s (RSS 1.0)'),
161 $this->user->nickname)),
163 common_local_url('ApiTimelineUser',
165 'id' => $this->user->id,
167 // TRANS: Title for link to notice feed.
168 // TRANS: %s is a user nickname.
169 sprintf(_('Notice feed for %s (RSS 2.0)'),
170 $this->user->nickname)),
172 common_local_url('ApiTimelineUser',
174 'id' => $this->user->id,
175 'format' => 'atom')),
176 // TRANS: Title for link to notice feed.
177 // TRANS: %s is a user nickname.
178 sprintf(_('Notice feed for %s (Atom)'),
179 $this->user->nickname)),
181 common_local_url('foaf', array('nickname' =>
182 $this->user->nickname)),
183 // TRANS: Title for link to notice feed. FOAF stands for Friend of a Friend.
184 // TRANS: More information at http://www.foaf-project.org. %s is a user nickname.
185 sprintf(_('FOAF for %s'), $this->user->nickname)));
190 if ($this->profile->bio) {
191 $this->element('meta', array('name' => 'description',
192 'content' => $this->profile->bio));
195 if ($this->user->emailmicroid && $this->user->email && $this->profile->profileurl) {
196 $id = new Microid('mailto:'.$this->user->email,
198 $this->element('meta', array('name' => 'microid',
199 'content' => $id->toString()));
202 // See https://wiki.mozilla.org/Microsummaries
204 $this->element('link', array('rel' => 'microsummary',
205 'href' => common_local_url('microsummary',
206 array('nickname' => $this->profile->nickname))));
208 $rsd = common_local_url('rsd',
209 array('nickname' => $this->profile->nickname));
211 // RSD, http://tales.phrasewise.com/rfc/rsd
212 $this->element('link', array('rel' => 'EditURI',
213 'type' => 'application/rsd+xml',
217 function showEmptyListMessage()
219 // TRANS: First sentence of empty list message for a timeline. $1%s is a user nickname.
220 $message = sprintf(_('This is the timeline for %1$s, but %1$s hasn\'t posted anything yet.'), $this->user->nickname) . ' ';
222 if (common_logged_in()) {
223 $current_user = common_current_user();
224 if ($this->user->id === $current_user->id) {
225 // TRANS: Second sentence of empty list message for a stream for the user themselves.
226 $message .= _('Seen anything interesting recently? You haven\'t posted any notices yet, now would be a good time to start :)');
228 // 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.
229 // TRANS: This message contains a Markdown link. Keep "](" together.
230 $message .= sprintf(_('You can try to nudge %1$s or [post something to them](%%%%action.newnotice%%%%?status_textarea=%2$s).'), $this->user->nickname, '@' . $this->user->nickname);
234 // TRANS: Second sentence of empty message for anonymous users. %s is a user nickname.
235 // TRANS: This message contains a Markdown link. Keep "](" together.
236 $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to them.'), $this->user->nickname);
239 $this->elementStart('div', 'guide');
240 $this->raw(common_markup_to_html($message));
241 $this->elementEnd('div');
244 function showNotices()
247 if (Event::handle('ShowStreamNoticeList', array($this->notice, $this, &$pnl))) {
248 $pnl = new ProfileNoticeList($this->notice, $this);
252 $this->showEmptyListMessage();
255 $args = array('nickname' => $this->user->nickname);
256 if (!empty($this->tag))
258 $args['tag'] = $this->tag;
260 $this->pagination($this->page>1, $cnt>NOTICES_PER_PAGE, $this->page,
261 'showstream', $args);
264 function showAnonymousMessage()
266 if (!(common_config('site','closed') || common_config('site','inviteonly'))) {
267 // TRANS: Announcement for anonymous users showing a timeline if site registrations are open.
268 // TRANS: This message contains a Markdown link. Keep "](" together.
269 $m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
270 'based on the Free Software [StatusNet](http://status.net/) tool. ' .
271 '[Join now](%%%%action.register%%%%) to follow **%s**\'s notices and many more! ([Read more](%%%%doc.help%%%%))'),
272 $this->user->nickname, $this->user->nickname);
274 // TRANS: Announcement for anonymous users showing a timeline if site registrations are closed or invite only.
275 // TRANS: This message contains a Markdown link. Keep "](" together.
276 $m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
277 'based on the Free Software [StatusNet](http://status.net/) tool. '),
278 $this->user->nickname, $this->user->nickname);
280 $this->elementStart('div', array('id' => 'anon_notice'));
281 $this->raw(common_markup_to_html($m));
282 $this->elementEnd('div');
285 function showSections()
287 parent::showSections();
288 if (!common_config('performance', 'high')) {
289 $cloud = new PersonalTagCloudSection($this, $this->user);
294 function noticeFormOptions()
296 $options = parent::noticeFormOptions();
297 $cur = common_current_user();
299 if (empty($cur) || $cur->id != $this->profile->id) {
300 $options['to_profile'] = $this->profile;
307 // We don't show the author for a profile, since we already know who it is!
310 * Slightly modified from standard list; the author & avatar are hidden
311 * in CSS. We used to remove them here too, but as it turns out that
312 * confuses the inline reply code... and we hide them in CSS anyway
313 * since realtime updates come through in original form.
315 * Remaining customization right now is for the repeat marker, where
316 * it'll list who the original poster was instead of who did the repeat
317 * (since the repeater is you, and the repeatee isn't shown!)
318 * This will remain inconsistent if realtime updates come through,
319 * since those'll get rendered as a regular NoticeListItem.
321 class ProfileNoticeList extends NoticeList
323 function newListItem($notice)
325 return new ProfileNoticeListItem($notice, $this->out);
329 class ProfileNoticeListItem extends DoFollowListItem
332 * show a link to the author of repeat
336 function showRepeat()
338 if (!empty($this->repeat)) {
340 // FIXME: this code is almost identical to default; need to refactor
342 $attrs = array('href' => $this->profile->profileurl,
345 if (!empty($this->profile->fullname)) {
346 $attrs['title'] = $this->profile->getFancyName();
349 $this->out->elementStart('span', 'repeat');
351 $text_link = XMLStringer::estring('a', $attrs, $this->profile->nickname);
353 // TRANS: Link to the author of a repeated notice. %s is a linked nickname.
354 $this->out->raw(sprintf(_('Repeat of %s'), $text_link));
356 $this->out->elementEnd('span');