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/
58 class ShowstreamAction extends ProfileAction
60 function isReadOnly($args)
67 if (!empty($this->profile->fullname)) {
68 $base = $this->profile->fullname . ' (' . $this->user->nickname . ') ';
70 $base = $this->user->nickname;
72 if (!empty($this->tag)) {
73 $base .= sprintf(_(' tagged %s'), $this->tag);
76 if ($this->page == 1) {
79 return sprintf(_("%s, page %d"),
85 function handle($args)
88 // Looks like we're good; start output
90 // For YADIS discovery, we also have a <meta> tag
92 header('X-XRDS-Location: '. common_local_url('xrds', array('nickname' =>
93 $this->user->nickname)));
98 function showContent()
100 $this->showProfile();
101 $this->showNotices();
104 function showLocalNav()
106 $nav = new PersonalGroupNav($this);
110 function showPageNoticeBlock()
117 if (!empty($this->tag)) {
118 return array(new Feed(Feed::RSS1,
119 common_local_url('userrss',
120 array('nickname' => $this->user->nickname,
121 'tag' => $this->tag)),
122 sprintf(_('Notice feed for %s tagged %s (RSS 1.0)'),
123 $this->user->nickname, $this->tag)));
126 return array(new Feed(Feed::RSS1,
127 common_local_url('userrss',
128 array('nickname' => $this->user->nickname)),
129 sprintf(_('Notice feed for %s (RSS 1.0)'),
130 $this->user->nickname)),
132 common_local_url('ApiTimelineUser',
134 'id' => $this->user->nickname,
136 sprintf(_('Notice feed for %s (RSS 2.0)'),
137 $this->user->nickname)),
139 common_local_url('ApiTimelineUser',
141 'id' => $this->user->nickname,
142 'format' => 'atom')),
143 sprintf(_('Notice feed for %s (Atom)'),
144 $this->user->nickname)),
146 common_local_url('foaf', array('nickname' =>
147 $this->user->nickname)),
148 sprintf(_('FOAF for %s'), $this->user->nickname)));
153 // for remote subscriptions etc.
154 $this->element('meta', array('http-equiv' => 'X-XRDS-Location',
155 'content' => common_local_url('xrds', array('nickname' =>
156 $this->user->nickname))));
158 if ($this->profile->bio) {
159 $this->element('meta', array('name' => 'description',
160 'content' => $this->profile->bio));
163 if ($this->user->emailmicroid && $this->user->email && $this->profile->profileurl) {
164 $id = new Microid('mailto:'.$this->user->email,
166 $this->element('meta', array('name' => 'microid',
167 'content' => $id->toString()));
169 if ($this->user->jabbermicroid && $this->user->jabber && $this->profile->profileurl) {
170 $id = new Microid('xmpp:'.$this->user->jabber,
172 $this->element('meta', array('name' => 'microid',
173 'content' => $id->toString()));
176 // See https://wiki.mozilla.org/Microsummaries
178 $this->element('link', array('rel' => 'microsummary',
179 'href' => common_local_url('microsummary',
180 array('nickname' => $this->profile->nickname))));
183 function showProfile()
185 $profile = new UserProfile($this, $this->user, $this->profile);
189 function showEmptyListMessage()
191 $message = sprintf(_('This is the timeline for %s but %s hasn\'t posted anything yet.'), $this->user->nickname, $this->user->nickname) . ' ';
193 if (common_logged_in()) {
194 $current_user = common_current_user();
195 if ($this->user->id === $current_user->id) {
196 $message .= _('Seen anything interesting recently? You haven\'t posted any notices yet, now would be a good time to start :)');
198 $message .= sprintf(_('You can try to nudge %s or [post something to his or her attention](%%%%action.newnotice%%%%?status_textarea=%s).'), $this->user->nickname, '@' . $this->user->nickname);
202 $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to his or her attention.'), $this->user->nickname);
205 $this->elementStart('div', 'guide');
206 $this->raw(common_markup_to_html($message));
207 $this->elementEnd('div');
210 function showNotices()
212 $notice = empty($this->tag)
213 ? $this->user->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1)
214 : $this->user->getTaggedNotices($this->tag, ($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1, 0, 0, null);
216 $pnl = new ProfileNoticeList($notice, $this);
219 $this->showEmptyListMessage();
222 $args = array('nickname' => $this->user->nickname);
223 if (!empty($this->tag))
225 $args['tag'] = $this->tag;
227 $this->pagination($this->page>1, $cnt>NOTICES_PER_PAGE, $this->page,
228 'showstream', $args);
231 function showAnonymousMessage()
233 if (!(common_config('site','closed') || common_config('site','inviteonly'))) {
234 $m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
235 'based on the Free Software [StatusNet](http://status.net/) tool. ' .
236 '[Join now](%%%%action.register%%%%) to follow **%s**\'s notices and many more! ([Read more](%%%%doc.help%%%%))'),
237 $this->user->nickname, $this->user->nickname);
239 $m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
240 'based on the Free Software [StatusNet](http://status.net/) tool. '),
241 $this->user->nickname, $this->user->nickname);
243 $this->elementStart('div', array('id' => 'anon_notice'));
244 $this->raw(common_markup_to_html($m));
245 $this->elementEnd('div');
248 function showSections()
250 parent::showSections();
251 $cloud = new PersonalTagCloudSection($this, $this->user);
256 // We don't show the author for a profile, since we already know who it is!
258 class ProfileNoticeList extends NoticeList
260 function newListItem($notice)
262 return new ProfileNoticeListItem($notice, $this->out);
266 class ProfileNoticeListItem extends NoticeListItem
268 function showAuthor()