3 * Laconica - a distributed open-source microblogging tool
4 * Copyright (C) 2008, Controlez-Vous, Inc.
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 if (!defined('LACONICA')) { exit(1); }
22 class StreamAction extends Action {
24 function is_readonly() {
28 function handle($args) {
29 parent::handle($args);
30 common_set_returnto($this->self_url());
33 function views_menu() {
36 $action = $this->trimmed('action');
37 $nickname = $this->trimmed('nickname');
40 $user = User::staticGet('nickname', $nickname);
41 $user_profile = $user->getProfile();
43 $user_profile = false;
46 common_element_start('ul', array('id' => 'nav_views'));
48 common_menu_item(common_local_url('all', array('nickname' =>
51 sprintf(_('%s and friends'), (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)),
53 common_menu_item(common_local_url('replies', array('nickname' =>
56 sprintf(_('Replies to %s'), (($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname)),
57 $action == 'replies');
58 common_menu_item(common_local_url('showstream', array('nickname' =>
61 ($user_profile && $user_profile->fullname) ? $user_profile->fullname : $nickname,
62 $action == 'showstream');
63 common_menu_item(common_local_url('showfavorites', array('nickname' =>
66 sprintf(_('%s\'s favorite notices'), ($user_profile) ? $user_profile->getBestName() : _('User')),
67 $action == 'showfavorites');
68 common_element_end('ul');
71 function show_notice($notice) {
73 $profile = $notice->getProfile();
74 $user = common_current_user();
77 common_element_start('li', array('class' => 'notice_single',
78 'id' => 'notice-' . $notice->id));
79 $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
80 common_element_start('a', array('href' => $profile->profileurl));
81 common_element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE),
82 'class' => 'avatar stream',
83 'width' => AVATAR_STREAM_SIZE,
84 'height' => AVATAR_STREAM_SIZE,
86 ($profile->fullname) ? $profile->fullname :
88 common_element_end('a');
89 common_element('a', array('href' => $profile->profileurl,
90 'class' => 'nickname'),
92 # FIXME: URL, image, video, audio
93 common_element_start('p', array('class' => 'content'));
94 if ($notice->rendered) {
95 common_raw($notice->rendered);
97 # XXX: may be some uncooked notices in the DB,
98 # we cook them right now. This should probably disappear in future
100 common_raw(common_render_content($notice->content, $notice));
102 common_element_end('p');
103 $noticeurl = common_local_url('shownotice', array('notice' => $notice->id));
104 # XXX: we need to figure this out better. Is this right?
105 if (strcmp($notice->uri, $noticeurl) != 0 && preg_match('/^http/', $notice->uri)) {
106 $noticeurl = $notice->uri;
108 common_element_start('p', 'time');
109 common_element('a', array('class' => 'permalink',
110 'href' => $noticeurl,
111 'title' => common_exact_date($notice->created)),
112 common_date_string($notice->created));
113 if ($notice->source) {
114 common_text(_(' from '));
115 $this->source_link($notice->source);
117 if ($notice->reply_to) {
118 $replyurl = common_local_url('shownotice', array('notice' => $notice->reply_to));
120 common_element('a', array('class' => 'inreplyto',
121 'href' => $replyurl),
122 _('in reply to...'));
125 common_element_start('a',
126 array('href' => common_local_url('newnotice',
127 array('replyto' => $profile->nickname)),
128 'onclick' => 'return doreply("'.$profile->nickname.'");',
129 'title' => _('reply'),
130 'class' => 'replybutton'));
131 common_raw('→');
132 common_element_end('a');
133 if ($user && $notice->profile_id == $user->id) {
134 $deleteurl = common_local_url('deletenotice', array('notice' => $notice->id));
135 common_element_start('a', array('class' => 'deletenotice',
136 'href' => $deleteurl,
137 'title' => _('delete')));
138 common_raw('×');
139 common_element_end('a');
142 if ($user->hasFave($notice)) {
143 common_disfavor_form($notice);
145 common_favor_form($notice);
148 common_element_end('p');
149 common_element_end('li');
152 function source_link($source) {
153 $source_name = _($source);
160 common_element('span', 'noticesource', $source_name);
163 $ns = Notice_source::staticGet($source);
165 common_element('a', array('href' => $ns->url),
168 common_element('span', 'noticesource', $source_name);