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/
57 class ShowstreamAction extends ProfileAction
59 function isReadOnly($args)
66 if (!empty($this->profile->fullname)) {
67 $base = $this->profile->fullname . ' (' . $this->user->nickname . ') ';
69 $base = $this->user->nickname;
71 if (!empty($this->tag)) {
72 $base .= sprintf(_(' tagged %s'), $this->tag);
75 if ($this->page == 1) {
78 return sprintf(_("%s, page %d"),
84 function handle($args)
87 // Looks like we're good; start output
89 // For YADIS discovery, we also have a <meta> tag
91 header('X-XRDS-Location: '. common_local_url('xrds', array('nickname' =>
92 $this->user->nickname)));
97 function showContent()
100 $this->showNotices();
103 function showLocalNav()
105 $nav = new PersonalGroupNav($this);
109 function showPageNoticeBlock()
116 if (!empty($this->tag)) {
117 return array(new Feed(Feed::RSS1,
118 common_local_url('userrss',
119 array('nickname' => $this->user->nickname,
120 'tag' => $this->tag)),
121 sprintf(_('Notice feed for %s tagged %s (RSS 1.0)'),
122 $this->user->nickname, $this->tag)));
125 return array(new Feed(Feed::RSS1,
126 common_local_url('userrss',
127 array('nickname' => $this->user->nickname)),
128 sprintf(_('Notice feed for %s (RSS 1.0)'),
129 $this->user->nickname)),
131 common_local_url('api',
132 array('apiaction' => 'statuses',
133 'method' => 'user_timeline',
134 'argument' => $this->user->nickname.'.rss')),
135 sprintf(_('Notice feed for %s (RSS 2.0)'),
136 $this->user->nickname)),
138 common_local_url('api',
139 array('apiaction' => 'statuses',
140 'method' => 'user_timeline',
141 'argument' => $this->user->nickname.'.atom')),
142 sprintf(_('Notice feed for %s (Atom)'),
143 $this->user->nickname)),
145 common_local_url('foaf', array('nickname' =>
146 $this->user->nickname)),
147 sprintf(_('FOAF for %s'), $this->user->nickname)));
152 // for remote subscriptions etc.
153 $this->element('meta', array('http-equiv' => 'X-XRDS-Location',
154 'content' => common_local_url('xrds', array('nickname' =>
155 $this->user->nickname))));
157 if ($this->profile->bio) {
158 $this->element('meta', array('name' => 'description',
159 'content' => $this->profile->bio));
162 if ($this->user->emailmicroid && $this->user->email && $this->profile->profileurl) {
163 $id = new Microid('mailto:'.$this->user->email,
165 $this->element('meta', array('name' => 'microid',
166 'content' => $id->toString()));
168 if ($this->user->jabbermicroid && $this->user->jabber && $this->profile->profileurl) {
169 $id = new Microid('xmpp:'.$this->user->jabber,
171 $this->element('meta', array('name' => 'microid',
172 'content' => $id->toString()));
175 // See https://wiki.mozilla.org/Microsummaries
177 $this->element('link', array('rel' => 'microsummary',
178 'href' => common_local_url('microsummary',
179 array('nickname' => $this->profile->nickname))));
182 function showProfile()
184 $this->showProfileData();
185 $this->showEntityActions();
188 function showProfileData()
190 if (Event::handle('StartProfilePageProfileSection', array(&$this, $this->profile))) {
192 $this->elementStart('div', 'entity_profile vcard author');
193 $this->element('h2', null, _('User profile'));
195 if (Event::handle('StartProfilePageProfileElements', array(&$this, $this->profile))) {
198 $this->showNickname();
199 $this->showFullName();
200 $this->showLocation();
201 $this->showHomepage();
203 $this->showProfileTags();
205 Event::handle('EndProfilePageProfileElements', array(&$this, $this->profile));
208 $this->elementEnd('div');
209 Event::handle('EndProfilePageProfileSection', array(&$this, $this->profile));
213 function showAvatar()
215 if (Event::handle('StartProfilePageAvatar', array($this, $this->profile))) {
217 $avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
219 $this->elementStart('dl', 'entity_depiction');
220 $this->element('dt', null, _('Photo'));
221 $this->elementStart('dd');
222 $this->element('img', array('src' => ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE),
223 'class' => 'photo avatar',
224 'width' => AVATAR_PROFILE_SIZE,
225 'height' => AVATAR_PROFILE_SIZE,
226 'alt' => $this->profile->nickname));
227 $this->elementEnd('dd');
229 $user = User::staticGet('id', $this->profile->id);
231 $cur = common_current_user();
232 if ($cur && $cur->id == $user->id) {
233 $this->elementStart('dd');
234 $this->element('a', array('href' => common_local_url('avatarsettings')), _('Edit Avatar'));
235 $this->elementEnd('dd');
238 $this->elementEnd('dl');
240 Event::handle('EndProfilePageAvatar', array($this, $this->profile));
244 function showNickname()
246 if (Event::handle('StartProfilePageNickname', array($this, $this->profile))) {
248 $this->elementStart('dl', 'entity_nickname');
249 $this->element('dt', null, _('Nickname'));
250 $this->elementStart('dd');
251 $hasFN = ($this->profile->fullname) ? 'nickname url uid' : 'fn nickname url uid';
252 $this->element('a', array('href' => $this->profile->profileurl,
253 'rel' => 'me', 'class' => $hasFN),
254 $this->profile->nickname);
255 $this->elementEnd('dd');
256 $this->elementEnd('dl');
258 Event::handle('EndProfilePageNickname', array($this, $this->profile));
262 function showFullName()
264 if (Event::handle('StartProfilePageFullName', array($this, $this->profile))) {
265 if ($this->profile->fullname) {
266 $this->elementStart('dl', 'entity_fn');
267 $this->element('dt', null, _('Full name'));
268 $this->elementStart('dd');
269 $this->element('span', 'fn', $this->profile->fullname);
270 $this->elementEnd('dd');
271 $this->elementEnd('dl');
273 Event::handle('EndProfilePageFullName', array($this, $this->profile));
277 function showLocation()
279 if (Event::handle('StartProfilePageLocation', array($this, $this->profile))) {
280 if ($this->profile->location) {
281 $this->elementStart('dl', 'entity_location');
282 $this->element('dt', null, _('Location'));
283 $this->element('dd', 'label', $this->profile->location);
284 $this->elementEnd('dl');
286 Event::handle('EndProfilePageLocation', array($this, $this->profile));
290 function showHomepage()
292 if (Event::handle('StartProfilePageHomepage', array($this, $this->profile))) {
293 if ($this->profile->homepage) {
294 $this->elementStart('dl', 'entity_url');
295 $this->element('dt', null, _('URL'));
296 $this->elementStart('dd');
297 $this->element('a', array('href' => $this->profile->homepage,
298 'rel' => 'me', 'class' => 'url'),
299 $this->profile->homepage);
300 $this->elementEnd('dd');
301 $this->elementEnd('dl');
303 Event::handle('EndProfilePageHomepage', array($this, $this->profile));
309 if (Event::handle('StartProfilePageBio', array($this, $this->profile))) {
310 if ($this->profile->bio) {
311 $this->elementStart('dl', 'entity_note');
312 $this->element('dt', null, _('Note'));
313 $this->element('dd', 'note', $this->profile->bio);
314 $this->elementEnd('dl');
316 Event::handle('EndProfilePageBio', array($this, $this->profile));
320 function showProfileTags()
322 if (Event::handle('StartProfilePageProfileTags', array($this, $this->profile))) {
323 $tags = Profile_tag::getTags($this->profile->id, $this->profile->id);
325 if (count($tags) > 0) {
326 $this->elementStart('dl', 'entity_tags');
327 $this->element('dt', null, _('Tags'));
328 $this->elementStart('dd');
329 $this->elementStart('ul', 'tags xoxo');
330 foreach ($tags as $tag) {
331 $this->elementStart('li');
332 // Avoid space by using raw output.
333 $pt = '<span class="mark_hash">#</span><a rel="tag" href="' .
334 common_local_url('peopletag', array('tag' => $tag)) .
335 '">' . $tag . '</a>';
337 $this->elementEnd('li');
339 $this->elementEnd('ul');
340 $this->elementEnd('dd');
341 $this->elementEnd('dl');
343 Event::handle('EndProfilePageProfileTags', array($this, $this->profile));
347 function showEntityActions()
349 if (Event::handle('StartProfilePageActionsSection', array(&$this, $this->profile))) {
351 $this->elementStart('div', 'entity_actions');
352 $this->element('h2', null, _('User actions'));
353 $this->elementStart('ul');
355 if (Event::handle('StartProfilePageActionsElements', array(&$this, $this->profile))) {
356 if (empty($cur)) { // not logged in
357 $this->elementStart('li', 'entity_subscribe');
358 $this->showRemoteSubscribeLink();
359 $this->elementEnd('li');
361 if ($cur->id == $this->profile->id) { // your own page
362 $this->elementStart('li', 'entity_edit');
363 $this->element('a', array('href' => common_local_url('profilesettings'),
364 'title' => _('Edit profile settings')),
366 $this->elementEnd('li');
367 } else { // someone else's page
369 // subscribe/unsubscribe button
371 $this->elementStart('li', 'entity_subscribe');
373 if ($cur->isSubscribed($this->profile)) {
374 $usf = new UnsubscribeForm($this, $this->profile);
377 $sf = new SubscribeForm($this, $this->profile);
380 $this->elementEnd('li');
382 if ($cur->mutuallySubscribed($user)) {
386 $this->elementStart('li', 'entity_send-a-message');
387 $this->element('a', array('href' => common_local_url('newmessage', array('to' => $user->id)),
388 'title' => _('Send a direct message to this user')),
390 $this->elementEnd('li');
394 if ($user->email && $user->emailnotifynudge) {
395 $this->elementStart('li', 'entity_nudge');
396 $nf = new NudgeForm($this, $user);
398 $this->elementEnd('li');
404 $blocked = $cur->hasBlocked($this->profile);
405 $this->elementStart('li', 'entity_block');
407 $ubf = new UnblockForm($this, $this->profile,
408 array('action' => 'showstream',
409 'nickname' => $this->profile->nickname));
412 $bf = new BlockForm($this, $this->profile,
413 array('action' => 'showstream',
414 'nickname' => $this->profile->nickname));
417 $this->elementEnd('li');
421 Event::handle('EndProfilePageActionsElements', array(&$this, $this->profile));
424 $this->elementEnd('ul');
425 $this->elementEnd('div');
427 Event::handle('EndProfilePageActionsSection', array(&$this, $this->profile));
431 function showRemoteSubscribeLink()
433 $url = common_local_url('remotesubscribe',
434 array('nickname' => $this->profile->nickname));
435 $this->element('a', array('href' => $url,
436 'class' => 'entity_remote_subscribe'),
440 function showEmptyListMessage()
442 $message = sprintf(_('This is the timeline for %s but %s hasn\'t posted anything yet.'), $this->user->nickname, $this->user->nickname) . ' ';
444 if (common_logged_in()) {
445 $current_user = common_current_user();
446 if ($this->user->id === $current_user->id) {
447 $message .= _('Seen anything interesting recently? You haven\'t posted any notices yet, now would be a good time to start :)');
449 $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);
453 $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);
456 $this->elementStart('div', 'guide');
457 $this->raw(common_markup_to_html($message));
458 $this->elementEnd('div');
461 function showNotices()
463 $notice = empty($this->tag)
464 ? $this->user->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1)
465 : $this->user->getTaggedNotices($this->tag, ($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1, 0, 0, null);
467 $pnl = new ProfileNoticeList($notice, $this);
470 $this->showEmptyListMessage();
473 $args = array('nickname' => $this->user->nickname);
474 if (!empty($this->tag))
476 $args['tag'] = $this->tag;
478 $this->pagination($this->page>1, $cnt>NOTICES_PER_PAGE, $this->page,
479 'showstream', $args);
482 function showAnonymousMessage()
484 if (!(common_config('site','closed') || common_config('site','inviteonly'))) {
485 $m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
486 'based on the Free Software [StatusNet](http://status.net/) tool. ' .
487 '[Join now](%%%%action.register%%%%) to follow **%s**\'s notices and many more! ([Read more](%%%%doc.help%%%%))'),
488 $this->user->nickname, $this->user->nickname);
490 $m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
491 'based on the Free Software [StatusNet](http://status.net/) tool. '),
492 $this->user->nickname, $this->user->nickname);
494 $this->elementStart('div', array('id' => 'anon_notice'));
495 $this->raw(common_markup_to_html($m));
496 $this->elementEnd('div');
499 function showSections()
501 parent::showSections();
502 $cloud = new PersonalTagCloudSection($this, $this->user);
507 // We don't show the author for a profile, since we already know who it is!
509 class ProfileNoticeList extends NoticeList
511 function newListItem($notice)
513 return new ProfileNoticeListItem($notice, $this->out);
517 class ProfileNoticeListItem extends NoticeListItem
519 function showAuthor()