3 * Laconica, 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@controlyourself.ca>
25 * @author Sarven Capadisli <csarven@controlyourself.ca>
26 * @copyright 2008-2009 Control Yourself, Inc.
27 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
28 * @link http://laconi.ca/
31 if (!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@controlyourself.ca>
53 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
54 * @link http://laconi.ca/
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;
72 if ($this->page == 1) {
75 return sprintf(_("%s, page %d"),
81 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 return array(new Feed(Feed::RSS1,
114 common_local_url('userrss',
115 array('nickname' => $this->user->nickname)),
116 sprintf(_('Notice feed for %s (RSS 1.0)'),
117 $this->user->nickname)),
119 common_local_url('api',
120 array('apiaction' => 'statuses',
121 'method' => 'user_timeline',
122 'argument' => $this->user->nickname.'.rss')),
123 sprintf(_('Notice feed for %s (RSS 2.0)'),
124 $this->user->nickname)),
126 common_local_url('api',
127 array('apiaction' => 'statuses',
128 'method' => 'user_timeline',
129 'argument' => $this->user->nickname.'.atom')),
130 sprintf(_('Notice feed for %s (Atom)'),
131 $this->user->nickname)),
133 common_local_url('foaf', array('nickname' =>
134 $this->user->nickname)),
135 sprintf(_('FOAF for %s'), $this->user->nickname)));
140 // for remote subscriptions etc.
141 $this->element('meta', array('http-equiv' => 'X-XRDS-Location',
142 'content' => common_local_url('xrds', array('nickname' =>
143 $this->user->nickname))));
145 if ($this->profile->bio) {
146 $this->element('meta', array('name' => 'description',
147 'content' => $this->profile->bio));
150 if ($this->user->emailmicroid && $this->user->email && $this->profile->profileurl) {
151 $id = new Microid('mailto:'.$this->user->email,
153 $this->element('meta', array('name' => 'microid',
154 'content' => $id->toString()));
156 if ($this->user->jabbermicroid && $this->user->jabber && $this->profile->profileurl) {
157 $id = new Microid('xmpp:'.$this->user->jabber,
159 $this->element('meta', array('name' => 'microid',
160 'content' => $id->toString()));
163 // See https://wiki.mozilla.org/Microsummaries
165 $this->element('link', array('rel' => 'microsummary',
166 'href' => common_local_url('microsummary',
167 array('nickname' => $this->profile->nickname))));
170 function showProfile()
172 $this->elementStart('div', 'entity_profile vcard author');
173 $this->element('h2', null, _('User profile'));
175 $avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
176 $this->elementStart('dl', 'entity_depiction');
177 $this->element('dt', null, _('Photo'));
178 $this->elementStart('dd');
179 $this->element('img', array('src' => ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE),
180 'class' => 'photo avatar',
181 'width' => AVATAR_PROFILE_SIZE,
182 'height' => AVATAR_PROFILE_SIZE,
183 'alt' => $this->profile->nickname));
184 $this->elementEnd('dd');
186 $user = User::staticGet('id', $this->profile->id);
187 $cur = common_current_user();
188 if ($cur && $cur->id == $user->id) {
189 $this->elementStart('dd');
190 $this->element('a', array('href' => common_local_url('avatarsettings')), _('Edit Avatar'));
191 $this->elementEnd('dd');
194 $this->elementEnd('dl');
196 $this->elementStart('dl', 'entity_nickname');
197 $this->element('dt', null, _('Nickname'));
198 $this->elementStart('dd');
199 $hasFN = ($this->profile->fullname) ? 'nickname url uid' : 'fn nickname url uid';
200 $this->element('a', array('href' => $this->profile->profileurl,
201 'rel' => 'me', 'class' => $hasFN),
202 $this->profile->nickname);
203 $this->elementEnd('dd');
204 $this->elementEnd('dl');
206 if ($this->profile->fullname) {
207 $this->elementStart('dl', 'entity_fn');
208 $this->element('dt', null, _('Full name'));
209 $this->elementStart('dd');
210 $this->element('span', 'fn', $this->profile->fullname);
211 $this->elementEnd('dd');
212 $this->elementEnd('dl');
215 if ($this->profile->location) {
216 $this->elementStart('dl', 'entity_location');
217 $this->element('dt', null, _('Location'));
218 $this->element('dd', 'label', $this->profile->location);
219 $this->elementEnd('dl');
222 if ($this->profile->homepage) {
223 $this->elementStart('dl', 'entity_url');
224 $this->element('dt', null, _('URL'));
225 $this->elementStart('dd');
226 $this->element('a', array('href' => $this->profile->homepage,
227 'rel' => 'me', 'class' => 'url'),
228 $this->profile->homepage);
229 $this->elementEnd('dd');
230 $this->elementEnd('dl');
233 if ($this->profile->bio) {
234 $this->elementStart('dl', 'entity_note');
235 $this->element('dt', null, _('Note'));
236 $this->element('dd', 'note', $this->profile->bio);
237 $this->elementEnd('dl');
240 $tags = Profile_tag::getTags($this->profile->id, $this->profile->id);
241 if (count($tags) > 0) {
242 $this->elementStart('dl', 'entity_tags');
243 $this->element('dt', null, _('Tags'));
244 $this->elementStart('dd');
245 $this->elementStart('ul', 'tags xoxo');
246 foreach ($tags as $tag) {
247 $this->elementStart('li');
248 // Avoid space by using raw output.
249 $pt = '<span class="mark_hash">#</span><a rel="tag" href="' .
250 common_local_url('peopletag', array('tag' => $tag)) .
251 '">' . $tag . '</a>';
253 $this->elementEnd('li');
255 $this->elementEnd('ul');
256 $this->elementEnd('dd');
257 $this->elementEnd('dl');
259 $this->elementEnd('div');
261 $this->elementStart('div', 'entity_actions');
262 $this->element('h2', null, _('User actions'));
263 $this->elementStart('ul');
264 $cur = common_current_user();
266 if ($cur && $cur->id == $this->profile->id) {
267 $this->elementStart('li', 'entity_edit');
268 $this->element('a', array('href' => common_local_url('profilesettings'),
269 'title' => _('Edit profile settings')),
271 $this->elementEnd('li');
275 if ($cur->id != $this->profile->id) {
276 $this->elementStart('li', 'entity_subscribe');
277 if ($cur->isSubscribed($this->profile)) {
278 $usf = new UnsubscribeForm($this, $this->profile);
281 $sf = new SubscribeForm($this, $this->profile);
284 $this->elementEnd('li');
287 $this->elementStart('li', 'entity_subscribe');
288 $this->showRemoteSubscribeLink();
289 $this->elementEnd('li');
292 if ($cur && $cur->id != $user->id && $cur->mutuallySubscribed($user)) {
293 $this->elementStart('li', 'entity_send-a-message');
294 $this->element('a', array('href' => common_local_url('newmessage', array('to' => $user->id)),
295 'title' => _('Send a direct message to this user')),
297 $this->elementEnd('li');
299 if ($user->email && $user->emailnotifynudge) {
300 $this->elementStart('li', 'entity_nudge');
301 $nf = new NudgeForm($this, $user);
303 $this->elementEnd('li');
307 if ($cur && $cur->id != $this->profile->id) {
308 $blocked = $cur->hasBlocked($this->profile);
309 $this->elementStart('li', 'entity_block');
311 $ubf = new UnblockForm($this, $this->profile);
314 $bf = new BlockForm($this, $this->profile);
317 $this->elementEnd('li');
319 $this->elementEnd('ul');
320 $this->elementEnd('div');
323 function showRemoteSubscribeLink()
325 $url = common_local_url('remotesubscribe',
326 array('nickname' => $this->profile->nickname));
327 $this->element('a', array('href' => $url,
328 'class' => 'entity_remote_subscribe'),
332 function showEmptyListMessage()
334 $message = sprintf(_('This is the timeline for %s but %s hasn\'t posted anything yet.'), $this->user->nickname, $this->user->nickname) . ' ';
336 if (common_logged_in()) {
337 $current_user = common_current_user();
338 if ($this->user->id === $current_user->id) {
339 $message .= _('Seen anything interesting recently? You haven\'t posted any notices yet, now would be a good time to start :)');
341 $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);
345 $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);
348 $this->elementStart('div', 'guide');
349 $this->raw(common_markup_to_html($message));
350 $this->elementEnd('div');
353 function showNotices()
355 $notice = $this->user->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
357 $pnl = new ProfileNoticeList($notice, $this);
360 $this->showEmptyListMessage();
363 $this->pagination($this->page>1, $cnt>NOTICES_PER_PAGE, $this->page,
364 'showstream', array('nickname' => $this->user->nickname));
367 function showAnonymousMessage()
369 if (!(common_config('site','closed') || common_config('site','inviteonly'))) {
370 $m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
371 'based on the Free Software [Laconica](http://laconi.ca/) tool. ' .
372 '[Join now](%%%%action.register%%%%) to follow **%s**\'s notices and many more! ([Read more](%%%%doc.help%%%%))'),
373 $this->user->nickname, $this->user->nickname);
375 $m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
376 'based on the Free Software [Laconica](http://laconi.ca/) tool. '),
377 $this->user->nickname, $this->user->nickname);
379 $this->elementStart('div', array('id' => 'anon_notice'));
380 $this->raw(common_markup_to_html($m));
381 $this->elementEnd('div');
384 function showSections()
386 parent::showSections();
387 $cloud = new PersonalTagCloudSection($this, $this->user);
392 // We don't show the author for a profile, since we already know who it is!
394 class ProfileNoticeList extends NoticeList
396 function newListItem($notice)
398 return new ProfileNoticeListItem($notice, $this->out);
402 class ProfileNoticeListItem extends NoticeListItem
404 function showAuthor()