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
58 function isReadOnly($args)
65 $base = $this->profile->getFancyName();
66 if (!empty($this->tag)) {
67 if ($this->page == 1) {
68 // TRANS: Page title showing tagged notices in one user's stream.
69 // TRANS: %1$s is the username, %2$s is the hash tag.
70 return sprintf(_('Notices by %1$s tagged %2$s'), $base, $this->tag);
72 // TRANS: Page title showing tagged notices in one user's stream.
73 // TRANS: %1$s is the username, %2$s is the hash tag, %3$d is the page number.
74 return sprintf(_('Notices by %1$s tagged %2$s, page %3$d'), $base, $this->tag, $this->page);
77 if ($this->page == 1) {
80 // TRANS: Extended page title showing tagged notices in one user's stream.
81 // TRANS: %1$s is the username, %2$d is the page number.
82 return sprintf(_('Notices by %1$s, page %2$d'),
89 function handle($args)
91 // Looks like we're good; start output
93 // For YADIS discovery, we also have a <meta> tag
95 header('X-XRDS-Location: '. common_local_url('xrds', array('nickname' =>
96 $this->user->nickname)));
101 function showContent()
103 $this->showNotices();
106 function showObjectNav()
108 $nav = new SubGroupNav($this, $this->user);
112 function showProfileBlock()
114 $block = new AccountProfileBlock($this, $this->profile);
118 function showPageNoticeBlock()
125 if (!empty($this->tag)) {
126 return array(new Feed(Feed::RSS1,
127 common_local_url('userrss',
128 array('nickname' => $this->user->nickname,
129 'tag' => $this->tag)),
130 // TRANS: Title for link to notice feed.
131 // TRANS: %1$s is a user nickname, %2$s is a hashtag.
132 sprintf(_('Notice feed for %1$s tagged %2$s (RSS 1.0)'),
133 $this->user->nickname, $this->tag)));
136 return array(new Feed(Feed::RSS1,
137 common_local_url('userrss',
138 array('nickname' => $this->user->nickname)),
139 // TRANS: Title for link to notice feed.
140 // TRANS: %s is a user nickname.
141 sprintf(_('Notice feed for %s (RSS 1.0)'),
142 $this->user->nickname)),
144 common_local_url('ApiTimelineUser',
146 'id' => $this->user->id,
148 // TRANS: Title for link to notice feed.
149 // TRANS: %s is a user nickname.
150 sprintf(_('Notice feed for %s (RSS 2.0)'),
151 $this->user->nickname)),
153 common_local_url('ApiTimelineUser',
155 'id' => $this->user->id,
156 'format' => 'atom')),
157 // TRANS: Title for link to notice feed.
158 // TRANS: %s is a user nickname.
159 sprintf(_('Notice feed for %s (Atom)'),
160 $this->user->nickname)),
162 common_local_url('foaf', array('nickname' =>
163 $this->user->nickname)),
164 // TRANS: Title for link to notice feed. FOAF stands for Friend of a Friend.
165 // TRANS: More information at http://www.foaf-project.org. %s is a user nickname.
166 sprintf(_('FOAF for %s'), $this->user->nickname)));
171 // for remote subscriptions etc.
172 $this->element('meta', array('http-equiv' => 'X-XRDS-Location',
173 'content' => common_local_url('xrds', array('nickname' =>
174 $this->user->nickname))));
176 if ($this->profile->bio) {
177 $this->element('meta', array('name' => 'description',
178 'content' => $this->profile->bio));
181 if ($this->user->emailmicroid && $this->user->email && $this->profile->profileurl) {
182 $id = new Microid('mailto:'.$this->user->email,
184 $this->element('meta', array('name' => 'microid',
185 'content' => $id->toString()));
188 // See https://wiki.mozilla.org/Microsummaries
190 $this->element('link', array('rel' => 'microsummary',
191 'href' => common_local_url('microsummary',
192 array('nickname' => $this->profile->nickname))));
194 $rsd = common_local_url('rsd',
195 array('nickname' => $this->profile->nickname));
197 // RSD, http://tales.phrasewise.com/rfc/rsd
198 $this->element('link', array('rel' => 'EditURI',
199 'type' => 'application/rsd+xml',
203 function showEmptyListMessage()
205 // TRANS: First sentence of empty list message for a stream. $1%s is a user nickname.
206 $message = sprintf(_('This is the timeline for %1$s, but %1$s hasn\'t posted anything yet.'), $this->user->nickname) . ' ';
208 if (common_logged_in()) {
209 $current_user = common_current_user();
210 if ($this->user->id === $current_user->id) {
211 // TRANS: Second sentence of empty list message for a stream for the user themselves.
212 $message .= _('Seen anything interesting recently? You haven\'t posted any notices yet, now would be a good time to start :)');
214 // TRANS: Second sentence of empty list message for a non-self stream. %1$s is a user nickname, %2$s is a part of a URL.
215 // TRANS: This message contains a Markdown link. Keep "](" together.
216 $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);
220 // TRANS: Second sentence of empty message for anonymous users. %s is a user nickname.
221 // TRANS: This message contains a Markdown link. Keep "](" together.
222 $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to them.'), $this->user->nickname);
225 $this->elementStart('div', 'guide');
226 $this->raw(common_markup_to_html($message));
227 $this->elementEnd('div');
230 function showNotices()
232 $notice = empty($this->tag)
233 ? $this->user->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1)
234 : $this->user->getTaggedNotices($this->tag, ($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1, 0, 0, null);
237 if (Event::handle('ShowStreamNoticeList', array($notice, $this, &$pnl))) {
238 $pnl = new ProfileNoticeList($notice, $this);
242 $this->showEmptyListMessage();
245 $args = array('nickname' => $this->user->nickname);
246 if (!empty($this->tag))
248 $args['tag'] = $this->tag;
250 $this->pagination($this->page>1, $cnt>NOTICES_PER_PAGE, $this->page,
251 'showstream', $args);
254 function showAnonymousMessage()
256 if (!(common_config('site','closed') || common_config('site','inviteonly'))) {
257 // TRANS: Announcement for anonymous users showing a stream if site registrations are open.
258 // TRANS: This message contains a Markdown link. Keep "](" together.
259 $m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
260 'based on the Free Software [StatusNet](http://status.net/) tool. ' .
261 '[Join now](%%%%action.register%%%%) to follow **%s**\'s notices and many more! ([Read more](%%%%doc.help%%%%))'),
262 $this->user->nickname, $this->user->nickname);
264 // TRANS: Announcement for anonymous users showing a stream if site registrations are closed or invite only.
265 // TRANS: This message contains a Markdown link. Keep "](" together.
266 $m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
267 'based on the Free Software [StatusNet](http://status.net/) tool. '),
268 $this->user->nickname, $this->user->nickname);
270 $this->elementStart('div', array('id' => 'anon_notice'));
271 $this->raw(common_markup_to_html($m));
272 $this->elementEnd('div');
275 function showSections()
277 parent::showSections();
278 $cloud = new PersonalTagCloudSection($this, $this->user);
282 function noticeFormOptions()
284 $options = parent::noticeFormOptions();
285 $cur = common_current_user();
287 if (empty($cur) || $cur->id != $this->profile->id) {
288 $options['to_profile'] = $this->profile;
295 // We don't show the author for a profile, since we already know who it is!
298 * Slightly modified from standard list; the author & avatar are hidden
299 * in CSS. We used to remove them here too, but as it turns out that
300 * confuses the inline reply code... and we hide them in CSS anyway
301 * since realtime updates come through in original form.
303 * Remaining customization right now is for the repeat marker, where
304 * it'll list who the original poster was instead of who did the repeat
305 * (since the repeater is you, and the repeatee isn't shown!)
306 * This will remain inconsistent if realtime updates come through,
307 * since those'll get rendered as a regular NoticeListItem.
309 class ProfileNoticeList extends NoticeList
311 function newListItem($notice)
313 return new ProfileNoticeListItem($notice, $this->out);
317 class ProfileNoticeListItem extends DoFollowListItem
320 * show a link to the author of repeat
324 function showRepeat()
326 if (!empty($this->repeat)) {
328 // FIXME: this code is almost identical to default; need to refactor
330 $attrs = array('href' => $this->profile->profileurl,
333 if (!empty($this->profile->fullname)) {
334 $attrs['title'] = $this->profile->getFancyName();
337 $this->out->elementStart('span', 'repeat');
339 $text_link = XMLStringer::estring('a', $attrs, $this->profile->nickname);
341 // TRANS: Link to the author of a repeated notice. %s is a linked nickname.
342 $this->out->raw(sprintf(_('Repeat of %s'), $text_link));
344 $this->out->elementEnd('span');