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. %1$s is the username, %2$s is the hash tag.
69 return sprintf(_('%1$s tagged %2$s'), $base, $this->tag);
71 // TRANS: Page title showing tagged notices in one user's stream.
72 // TRANS: %1$s is the username, %2$s is the hash tag, %3$d is the page number.
73 return sprintf(_('%1$s tagged %2$s, page %3$d'), $base, $this->tag, $this->page);
76 if ($this->page == 1) {
79 // TRANS: Extended page title showing tagged notices in one user's stream.
80 // TRANS: %1$s is the username, %2$d is the page number.
81 return sprintf(_('%1$s, page %2$d'),
88 function handle($args)
90 // Looks like we're good; start output
92 // For YADIS discovery, we also have a <meta> tag
94 header('X-XRDS-Location: '. common_local_url('xrds', array('nickname' =>
95 $this->user->nickname)));
100 function showContent()
102 $this->showNotices();
105 function showObjectNav()
107 $nav = new SubGroupNav($this, $this->user);
111 function showProfileBlock()
113 $block = new AccountProfileBlock($this, $this->profile);
117 function showPageNoticeBlock()
124 if (!empty($this->tag)) {
125 return array(new Feed(Feed::RSS1,
126 common_local_url('userrss',
127 array('nickname' => $this->user->nickname,
128 'tag' => $this->tag)),
129 // TRANS: Title for link to notice feed.
130 // TRANS: %1$s is a user nickname, %2$s is a hashtag.
131 sprintf(_('Notice feed for %1$s tagged %2$s (RSS 1.0)'),
132 $this->user->nickname, $this->tag)));
135 return array(new Feed(Feed::RSS1,
136 common_local_url('userrss',
137 array('nickname' => $this->user->nickname)),
138 // TRANS: Title for link to notice feed.
139 // TRANS: %s is a user nickname.
140 sprintf(_('Notice feed for %s (RSS 1.0)'),
141 $this->user->nickname)),
143 common_local_url('ApiTimelineUser',
145 'id' => $this->user->id,
147 // TRANS: Title for link to notice feed.
148 // TRANS: %s is a user nickname.
149 sprintf(_('Notice feed for %s (RSS 2.0)'),
150 $this->user->nickname)),
152 common_local_url('ApiTimelineUser',
154 'id' => $this->user->id,
155 'format' => 'atom')),
156 sprintf(_('Notice feed for %s (Atom)'),
157 $this->user->nickname)),
159 common_local_url('foaf', array('nickname' =>
160 $this->user->nickname)),
161 // TRANS: Title for link to notice feed. FOAF stands for Friend of a Friend.
162 // TRANS: More information at http://www.foaf-project.org. %s is a user nickname.
163 sprintf(_('FOAF for %s'), $this->user->nickname)));
168 // for remote subscriptions etc.
169 $this->element('meta', array('http-equiv' => 'X-XRDS-Location',
170 'content' => common_local_url('xrds', array('nickname' =>
171 $this->user->nickname))));
173 if ($this->profile->bio) {
174 $this->element('meta', array('name' => 'description',
175 'content' => $this->profile->bio));
178 if ($this->user->emailmicroid && $this->user->email && $this->profile->profileurl) {
179 $id = new Microid('mailto:'.$this->user->email,
181 $this->element('meta', array('name' => 'microid',
182 'content' => $id->toString()));
185 // See https://wiki.mozilla.org/Microsummaries
187 $this->element('link', array('rel' => 'microsummary',
188 'href' => common_local_url('microsummary',
189 array('nickname' => $this->profile->nickname))));
191 $rsd = common_local_url('rsd',
192 array('nickname' => $this->profile->nickname));
194 // RSD, http://tales.phrasewise.com/rfc/rsd
195 $this->element('link', array('rel' => 'EditURI',
196 'type' => 'application/rsd+xml',
200 function showEmptyListMessage()
202 // TRANS: First sentence of empty list message for a stream. $1%s is a user nickname.
203 $message = sprintf(_('This is the timeline for %1$s, but %1$s hasn\'t posted anything yet.'), $this->user->nickname) . ' ';
205 if (common_logged_in()) {
206 $current_user = common_current_user();
207 if ($this->user->id === $current_user->id) {
208 // TRANS: Second sentence of empty list message for a stream for the user themselves.
209 $message .= _('Seen anything interesting recently? You haven\'t posted any notices yet, now would be a good time to start :)');
211 // 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.
212 // TRANS: This message contains a Markdown link. Keep "](" together.
213 $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);
217 // TRANS: Second sentence of empty message for anonymous users. %s is a user nickname.
218 // TRANS: This message contains a Markdown link. Keep "](" together.
219 $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to them.'), $this->user->nickname);
222 $this->elementStart('div', 'guide');
223 $this->raw(common_markup_to_html($message));
224 $this->elementEnd('div');
227 function showNotices()
229 $notice = empty($this->tag)
230 ? $this->user->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1)
231 : $this->user->getTaggedNotices($this->tag, ($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1, 0, 0, null);
234 if (Event::handle('ShowStreamNoticeList', array($notice, $this, &$pnl))) {
235 $pnl = new ProfileNoticeList($notice, $this);
239 $this->showEmptyListMessage();
242 $args = array('nickname' => $this->user->nickname);
243 if (!empty($this->tag))
245 $args['tag'] = $this->tag;
247 $this->pagination($this->page>1, $cnt>NOTICES_PER_PAGE, $this->page,
248 'showstream', $args);
251 function showAnonymousMessage()
253 if (!(common_config('site','closed') || common_config('site','inviteonly'))) {
254 // TRANS: Announcement for anonymous users showing a stream if site registrations are open.
255 // TRANS: This message contains a Markdown link. Keep "](" together.
256 $m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
257 'based on the Free Software [StatusNet](http://status.net/) tool. ' .
258 '[Join now](%%%%action.register%%%%) to follow **%s**\'s notices and many more! ([Read more](%%%%doc.help%%%%))'),
259 $this->user->nickname, $this->user->nickname);
261 // TRANS: Announcement for anonymous users showing a stream if site registrations are closed or invite only.
262 // TRANS: This message contains a Markdown link. Keep "](" together.
263 $m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
264 'based on the Free Software [StatusNet](http://status.net/) tool. '),
265 $this->user->nickname, $this->user->nickname);
267 $this->elementStart('div', array('id' => 'anon_notice'));
268 $this->raw(common_markup_to_html($m));
269 $this->elementEnd('div');
272 function showSections()
274 parent::showSections();
275 $cloud = new PersonalTagCloudSection($this, $this->user);
280 // We don't show the author for a profile, since we already know who it is!
282 class ProfileNoticeList extends NoticeList
284 function newListItem($notice)
286 return new ProfileNoticeListItem($notice, $this->out);
290 class ProfileNoticeListItem extends DoFollowListItem
292 function showAuthor()
298 * show a link to the author of repeat
302 function showRepeat()
304 if (!empty($this->repeat)) {
306 // FIXME: this code is almost identical to default; need to refactor
308 $attrs = array('href' => $this->profile->profileurl,
311 if (!empty($this->profile->fullname)) {
312 $attrs['title'] = $this->profile->getFancyName();
315 $this->out->elementStart('span', 'repeat');
317 $text_link = XMLStringer::estring('a', $attrs, $this->profile->nickname);
319 // TRANS: Link to the author of a repeated notice. %s is a linked nickname.
320 $this->out->raw(sprintf(_('Repeat of %s'), $text_link));
322 $this->out->elementEnd('span');