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)));
139 * Output document relationship links
143 function showRelationshipLinks()
145 $this->sequenceRelationships($this->page > 1, $this->count > NOTICES_PER_PAGE, // FIXME
146 $this->page, 'showstream', array('nickname' => $this->user->nickname));
151 // for remote subscriptions etc.
152 $this->element('meta', array('http-equiv' => 'X-XRDS-Location',
153 'content' => common_local_url('xrds', array('nickname' =>
154 $this->user->nickname))));
156 if ($this->profile->bio) {
157 $this->element('meta', array('name' => 'description',
158 'content' => $this->profile->bio));
161 if ($this->user->emailmicroid && $this->user->email && $this->profile->profileurl) {
162 $id = new Microid('mailto:'.$this->user->email,
164 $this->element('meta', array('name' => 'microid',
165 'content' => $id->toString()));
167 if ($this->user->jabbermicroid && $this->user->jabber && $this->profile->profileurl) {
168 $id = new Microid('xmpp:'.$this->user->jabber,
170 $this->element('meta', array('name' => 'microid',
171 'content' => $id->toString()));
174 // See https://wiki.mozilla.org/Microsummaries
176 $this->element('link', array('rel' => 'microsummary',
177 'href' => common_local_url('microsummary',
178 array('nickname' => $this->profile->nickname))));
181 function showProfile()
183 $this->elementStart('div', 'entity_profile vcard author');
184 $this->element('h2', null, _('User profile'));
186 $avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE);
187 $this->elementStart('dl', 'entity_depiction');
188 $this->element('dt', null, _('Photo'));
189 $this->elementStart('dd');
190 $this->element('img', array('src' => ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE),
191 'class' => 'photo avatar',
192 'width' => AVATAR_PROFILE_SIZE,
193 'height' => AVATAR_PROFILE_SIZE,
194 'alt' => $this->profile->nickname));
195 $this->elementEnd('dd');
197 $user = User::staticGet('id', $this->profile->id);
198 $cur = common_current_user();
199 if ($cur && $cur->id == $user->id) {
200 $this->elementStart('dd');
201 $this->element('a', array('href' => common_local_url('avatarsettings')), _('Edit Avatar'));
202 $this->elementEnd('dd');
205 $this->elementEnd('dl');
207 $this->elementStart('dl', 'entity_nickname');
208 $this->element('dt', null, _('Nickname'));
209 $this->elementStart('dd');
210 $hasFN = ($this->profile->fullname) ? 'nickname url uid' : 'fn nickname url uid';
211 $this->element('a', array('href' => $this->profile->profileurl,
212 'rel' => 'me', 'class' => $hasFN),
213 $this->profile->nickname);
214 $this->elementEnd('dd');
215 $this->elementEnd('dl');
217 if ($this->profile->fullname) {
218 $this->elementStart('dl', 'entity_fn');
219 $this->element('dt', null, _('Full name'));
220 $this->elementStart('dd');
221 $this->element('span', 'fn', $this->profile->fullname);
222 $this->elementEnd('dd');
223 $this->elementEnd('dl');
226 if ($this->profile->location) {
227 $this->elementStart('dl', 'entity_location');
228 $this->element('dt', null, _('Location'));
229 $this->element('dd', 'label', $this->profile->location);
230 $this->elementEnd('dl');
233 if ($this->profile->homepage) {
234 $this->elementStart('dl', 'entity_url');
235 $this->element('dt', null, _('URL'));
236 $this->elementStart('dd');
237 $this->element('a', array('href' => $this->profile->homepage,
238 'rel' => 'me', 'class' => 'url'),
239 $this->profile->homepage);
240 $this->elementEnd('dd');
241 $this->elementEnd('dl');
244 if ($this->profile->bio) {
245 $this->elementStart('dl', 'entity_note');
246 $this->element('dt', null, _('Note'));
247 $this->element('dd', 'note', $this->profile->bio);
248 $this->elementEnd('dl');
251 $tags = Profile_tag::getTags($this->profile->id, $this->profile->id);
252 if (count($tags) > 0) {
253 $this->elementStart('dl', 'entity_tags');
254 $this->element('dt', null, _('Tags'));
255 $this->elementStart('dd');
256 $this->elementStart('ul', 'tags xoxo');
257 foreach ($tags as $tag) {
258 $this->elementStart('li');
259 // Avoid space by using raw output.
260 $pt = '<span class="mark_hash">#</span><a rel="tag" href="' .
261 common_local_url('peopletag', array('tag' => $tag)) .
262 '">' . $tag . '</a>';
264 $this->elementEnd('li');
266 $this->elementEnd('ul');
267 $this->elementEnd('dd');
268 $this->elementEnd('dl');
270 $this->elementEnd('div');
272 $this->elementStart('div', 'entity_actions');
273 $this->element('h2', null, _('User actions'));
274 $this->elementStart('ul');
275 $cur = common_current_user();
277 if ($cur && $cur->id == $this->profile->id) {
278 $this->elementStart('li', 'entity_edit');
279 $this->element('a', array('href' => common_local_url('profilesettings'),
280 'title' => _('Edit profile settings')),
282 $this->elementEnd('li');
286 if ($cur->id != $this->profile->id) {
287 $this->elementStart('li', 'entity_subscribe');
288 if ($cur->isSubscribed($this->profile)) {
289 $usf = new UnsubscribeForm($this, $this->profile);
292 $sf = new SubscribeForm($this, $this->profile);
295 $this->elementEnd('li');
298 $this->elementStart('li', 'entity_subscribe');
299 $this->showRemoteSubscribeLink();
300 $this->elementEnd('li');
303 if ($cur && $cur->id != $user->id && $cur->mutuallySubscribed($user)) {
304 $this->elementStart('li', 'entity_send-a-message');
305 $this->element('a', array('href' => common_local_url('newmessage', array('to' => $user->id)),
306 'title' => _('Send a direct message to this user')),
308 $this->elementEnd('li');
310 if ($user->email && $user->emailnotifynudge) {
311 $this->elementStart('li', 'entity_nudge');
312 $nf = new NudgeForm($this, $user);
314 $this->elementEnd('li');
318 if ($cur && $cur->id != $this->profile->id) {
319 $blocked = $cur->hasBlocked($this->profile);
320 $this->elementStart('li', 'entity_block');
322 $ubf = new UnblockForm($this, $this->profile);
325 $bf = new BlockForm($this, $this->profile);
328 $this->elementEnd('li');
330 $this->elementEnd('ul');
331 $this->elementEnd('div');
334 function showRemoteSubscribeLink()
336 $url = common_local_url('remotesubscribe',
337 array('nickname' => $this->profile->nickname));
338 $this->element('a', array('href' => $url,
339 'class' => 'entity_remote_subscribe'),
343 function showEmptyListMessage()
345 $message = sprintf(_('This is the timeline for %s but %s hasn\'t posted anything yet.'), $this->user->nickname, $this->user->nickname) . ' ';
347 if (common_logged_in()) {
348 $current_user = common_current_user();
349 if ($this->user->id === $current_user->id) {
350 $message .= _('Seen anything interesting recently? You haven\'t posted any notices yet, now would be a good time to start :)');
352 $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);
356 $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);
359 $this->elementStart('div', 'guide');
360 $this->raw(common_markup_to_html($message));
361 $this->elementEnd('div');
364 function showNotices()
366 $notice = $this->user->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
368 $pnl = new ProfileNoticeList($notice, $this);
371 $this->showEmptyListMessage();
374 $this->pagination($this->page>1, $cnt>NOTICES_PER_PAGE, $this->page,
375 'showstream', array('nickname' => $this->user->nickname));
378 function showAnonymousMessage()
380 if (!(common_config('site','closed') || common_config('site','inviteonly'))) {
381 $m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
382 'based on the Free Software [Laconica](http://laconi.ca/) tool. ' .
383 '[Join now](%%%%action.register%%%%) to follow **%s**\'s notices and many more! ([Read more](%%%%doc.help%%%%))'),
384 $this->user->nickname, $this->user->nickname);
386 $m = sprintf(_('**%s** has an account on %%%%site.name%%%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
387 'based on the Free Software [Laconica](http://laconi.ca/) tool. '),
388 $this->user->nickname, $this->user->nickname);
390 $this->elementStart('div', array('id' => 'anon_notice'));
391 $this->raw(common_markup_to_html($m));
392 $this->elementEnd('div');
395 function showSections()
397 parent::showSections();
398 $cloud = new PersonalTagCloudSection($this, $this->user);
403 // We don't show the author for a profile, since we already know who it is!
405 class ProfileNoticeList extends NoticeList
407 function newListItem($notice)
409 return new ProfileNoticeListItem($notice, $this->out);
413 class ProfileNoticeListItem extends NoticeListItem
415 function showAuthor()