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/userprofile.php';
37 require_once INSTALLDIR.'/lib/noticelist.php';
38 require_once INSTALLDIR.'/lib/profileminilist.php';
39 require_once INSTALLDIR.'/lib/groupminilist.php';
40 require_once INSTALLDIR.'/lib/feedlist.php';
45 * When I created this page, "show stream" seemed like the best name for it.
46 * Now, it seems like a really bad name.
48 * It shows a stream of the user's posts, plus lots of profile info, links
49 * to subscriptions and stuff, etc.
53 * @author Evan Prodromou <evan@status.net>
54 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
55 * @link http://status.net/
57 class ShowstreamAction extends ProfileAction
59 function isReadOnly($args)
66 $base = $this->profile->getFancyName();
67 if (!empty($this->tag)) {
68 // TRANS: Page title showing tagged notices in one user's stream. Param 1 is the username, 2 is the hash tag.
69 $base = sprintf(_('%1$s tagged %2$s'), $base, $this->tag);
72 if ($this->page == 1) {
75 // TRANS: Extended page title showing tagged notices in one user's stream. Param 1 is the main title clause; 2 is the page number.
76 return sprintf(_('%1$s, page %2$d'),
82 function handle($args)
84 // Looks like we're good; start output
86 // For YADIS discovery, we also have a <meta> tag
88 header('X-XRDS-Location: '. common_local_url('xrds', array('nickname' =>
89 $this->user->nickname)));
94 function showContent()
100 function showLocalNav()
102 $nav = new PersonalGroupNav($this);
106 function showPageNoticeBlock()
113 if (!empty($this->tag)) {
114 return array(new Feed(Feed::RSS1,
115 common_local_url('userrss',
116 array('nickname' => $this->user->nickname,
117 'tag' => $this->tag)),
118 sprintf(_('Notice feed for %1$s tagged %2$s (RSS 1.0)'),
119 $this->user->nickname, $this->tag)));
122 return array(new Feed(Feed::RSS1,
123 common_local_url('userrss',
124 array('nickname' => $this->user->nickname)),
125 sprintf(_('Notice feed for %s (RSS 1.0)'),
126 $this->user->nickname)),
128 common_local_url('ApiTimelineUser',
130 'id' => $this->user->id,
132 sprintf(_('Notice feed for %s (RSS 2.0)'),
133 $this->user->nickname)),
135 common_local_url('ApiTimelineUser',
137 'id' => $this->user->id,
138 'format' => 'atom')),
139 sprintf(_('Notice feed for %s (Atom)'),
140 $this->user->nickname)),
142 common_local_url('foaf', array('nickname' =>
143 $this->user->nickname)),
144 sprintf(_('FOAF for %s'), $this->user->nickname)));
149 // for remote subscriptions etc.
150 $this->element('meta', array('http-equiv' => 'X-XRDS-Location',
151 'content' => common_local_url('xrds', array('nickname' =>
152 $this->user->nickname))));
154 if ($this->profile->bio) {
155 $this->element('meta', array('name' => 'description',
156 'content' => $this->profile->bio));
159 if ($this->user->emailmicroid && $this->user->email && $this->profile->profileurl) {
160 $id = new Microid('mailto:'.$this->user->email,
162 $this->element('meta', array('name' => 'microid',
163 'content' => $id->toString()));
165 if ($this->user->jabbermicroid && $this->user->jabber && $this->profile->profileurl) {
166 $id = new Microid('xmpp:'.$this->user->jabber,
168 $this->element('meta', array('name' => 'microid',
169 'content' => $id->toString()));
172 // See https://wiki.mozilla.org/Microsummaries
174 $this->element('link', array('rel' => 'microsummary',
175 'href' => common_local_url('microsummary',
176 array('nickname' => $this->profile->nickname))));
178 $rsd = common_local_url('rsd',
179 array('nickname' => $this->profile->nickname));
181 // RSD, http://tales.phrasewise.com/rfc/rsd
182 $this->element('link', array('rel' => 'EditURI',
183 'type' => 'application/rsd+xml',
187 function showProfile()
189 $profile = new UserProfile($this, $this->user, $this->profile);
193 function showEmptyListMessage()
195 $message = sprintf(_('This is the timeline for %1$s but %2$s hasn\'t posted anything yet.'), $this->user->nickname, $this->user->nickname) . ' ';
197 if (common_logged_in()) {
198 $current_user = common_current_user();
199 if ($this->user->id === $current_user->id) {
200 $message .= _('Seen anything interesting recently? You haven\'t posted any notices yet, now would be a good time to start :)');
202 $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);
206 $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to them.'), $this->user->nickname);
209 $this->elementStart('div', 'guide');
210 $this->raw(common_markup_to_html($message));
211 $this->elementEnd('div');
214 function showNotices()
216 $notice = empty($this->tag)
217 ? $this->user->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1)
218 : $this->user->getTaggedNotices($this->tag, ($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1, 0, 0, null);
221 if (Event::handle('ShowStreamNoticeList', array($notice, $this, &$pnl))) {
222 $pnl = new ProfileNoticeList($notice, $this);
226 $this->showEmptyListMessage();
229 $args = array('nickname' => $this->user->nickname);
230 if (!empty($this->tag))
232 $args['tag'] = $this->tag;
234 $this->pagination($this->page>1, $cnt>NOTICES_PER_PAGE, $this->page,
235 'showstream', $args);
238 function showAnonymousMessage()
240 if (!(common_config('site','closed') || common_config('site','inviteonly'))) {
241 $m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
242 'based on the Free Software [StatusNet](http://status.net/) tool. ' .
243 '[Join now](%%%%action.register%%%%) to follow **%s**\'s notices and many more! ([Read more](%%%%doc.help%%%%))'),
244 $this->user->nickname, $this->user->nickname);
246 $m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
247 'based on the Free Software [StatusNet](http://status.net/) tool. '),
248 $this->user->nickname, $this->user->nickname);
250 $this->elementStart('div', array('id' => 'anon_notice'));
251 $this->raw(common_markup_to_html($m));
252 $this->elementEnd('div');
255 function showSections()
257 parent::showSections();
258 $cloud = new PersonalTagCloudSection($this, $this->user);
263 // We don't show the author for a profile, since we already know who it is!
265 class ProfileNoticeList extends NoticeList
267 function newListItem($notice)
269 return new ProfileNoticeListItem($notice, $this->out);
273 class ProfileNoticeListItem extends DoFollowListItem
275 function showAuthor()
281 * show a link to the author of repeat
286 function showRepeat()
288 if (!empty($this->repeat)) {
290 // FIXME: this code is almost identical to default; need to refactor
292 $attrs = array('href' => $this->profile->profileurl,
295 if (!empty($this->profile->fullname)) {
296 $attrs['title'] = $this->profile->fullname . ' (' . $this->profile->nickname . ')';
299 $this->out->elementStart('span', 'repeat');
301 $text_link = XMLStringer::estring('a', $attrs, $this->profile->nickname);
303 $this->out->raw(sprintf(_('Repeat of %s'), $text_link));
305 $this->out->elementEnd('span');