]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/stream.php
1dd4c55e79aeab235c2ba4e1375624c346fdeaba
[quix0rs-gnu-social.git] / lib / stream.php
1 <?php
2 /*
3  * Laconica - a distributed open-source microblogging tool
4  * Copyright (C) 2008, Controlez-Vous, Inc.
5  *
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.
10  *
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.
15  *
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/>.
18  */
19
20 if (!defined('LACONICA')) { exit(1); }
21
22 class StreamAction extends Action {
23
24         function is_readonly() {
25                 return true;
26         }
27
28         function handle($args) {
29                 parent::handle($args);
30                 common_set_returnto($this->self_url());
31         }
32
33         function views_menu() {
34
35                 $user = NULL;
36                 $action = $this->trimmed('action');
37                 $nickname = $this->trimmed('nickname');
38
39                 if ($nickname) {
40                         $user = User::staticGet('nickname', $nickname);
41                 }
42
43                 common_element_start('ul', array('id' => 'nav_views'));
44
45                 common_menu_item(common_local_url('all', array('nickname' =>
46                                                                                                            $nickname)),
47                                                  _('Personal'),
48                                                  sprintf(_('%s and friends'), (($user && $user->fullname) ? $user->fullname : $nickname)),
49                                                  $action == 'all');
50                 common_menu_item(common_local_url('replies', array('nickname' =>
51                                                                                                                           $nickname)),
52                                                  _('Replies'),
53                                                  sprintf(_('Replies to %s'), (($user && $user->fullname) ? $user->fullname : $nickname)),
54                                                  $action == 'replies');
55                 common_menu_item(common_local_url('showstream', array('nickname' =>
56                                                                                                                           $nickname)),
57                                                  _('Profile'),
58                                                  ($user && $user->fullname) ? $user->fullname : $nickname,
59                                                  $action == 'showstream');
60                 common_element_end('ul');
61         }
62
63         function show_notice($notice) {
64                 global $config;
65                 $profile = $notice->getProfile();
66                 if (common_logged_in()) {
67                         $user = common_current_user();
68                         $user_profile = $user->getProfile();
69                 } else {
70                         $user_profile = false;
71                 }
72
73                 # XXX: RDFa
74                 common_element_start('li', array('class' => 'notice_single',
75                                                                                   'id' => 'notice-' . $notice->id));
76                 $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
77                 common_element_start('a', array('href' => $profile->profileurl));
78                 common_element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE),
79                                                                         'class' => 'avatar stream',
80                                                                         'width' => AVATAR_STREAM_SIZE,
81                                                                         'height' => AVATAR_STREAM_SIZE,
82                                                                         'alt' =>
83                                                                         ($profile->fullname) ? $profile->fullname :
84                                                                         $profile->nickname));
85                 common_element_end('a');
86                 common_element('a', array('href' => $profile->profileurl,
87                                                                   'class' => 'nickname'),
88                                            $profile->nickname);
89                 # FIXME: URL, image, video, audio
90                 common_element_start('p', array('class' => 'content'));
91                 if ($notice->rendered) {
92                         common_raw($notice->rendered);
93                 } else {
94                         # XXX: may be some uncooked notices in the DB,
95                         # we cook them right now. This should probably disappear in future
96                         # versions (>> 0.4.x)
97                         common_raw(common_render_content($notice->content, $notice));
98                 }
99                 common_element_end('p');
100                 $noticeurl = common_local_url('shownotice', array('notice' => $notice->id));
101                 common_element_start('p', 'time');
102                 common_element('a', array('class' => 'permalink',
103                                                                   'href' => $noticeurl,
104                                                                   'title' => common_exact_date($notice->created)),
105                                            common_date_string($notice->created));
106                 if ($notice->reply_to) {
107                         $replyurl = common_local_url('shownotice', array('notice' => $notice->reply_to));
108                         common_text(' (');
109                         common_element('a', array('class' => 'inreplyto',
110                                                                           'href' => $replyurl),
111                                                    _('in reply to...'));
112                         common_text(')');
113                 }
114                 common_element_start('a',
115                                                          array('href' => common_local_url('newnotice',
116                                                                                                                           array('replyto' => $profile->nickname)),
117                                                                    'onclick' => 'doreply("'.$profile->nickname.'"); return false',
118                                                                    'title' => _('reply'),
119                                                                    'class' => 'replybutton'));
120                 common_raw('&rarr;');
121                 common_element_end('a');
122                 common_element_end('p');
123                 if ($user_profile && $notice->profile_id == $user_profile->id) {
124                         $deleteurl = common_local_url('deletenotice', array('notice' => $notice->id));
125                         common_element('a', array('class' => 'deletenotice',
126                                                                          'href' => $deleteurl),
127                                                    _('delete'));
128                 }
129                 common_element_end('li');
130         }
131 }