]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/stream.php
Script to update laconica.pot from source, and the results of running it
[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 require_once(INSTALLDIR.'/lib/personal.php');
23
24 class StreamAction extends PersonalAction {
25
26         function show_notice($notice) {
27                 global $config;
28                 $profile = $notice->getProfile();
29                 $user = common_current_user();
30
31                 # XXX: RDFa
32                 common_element_start('li', array('class' => 'notice_single',
33                                                                                   'id' => 'notice-' . $notice->id));
34                 if ($user) {
35                         if ($user->hasFave($notice)) {
36                                 common_disfavor_form($notice);
37                         } else {
38                                 common_favor_form($notice);
39                         }
40                 }
41                 $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
42                 common_element_start('a', array('href' => $profile->profileurl));
43                 common_element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE),
44                                                                         'class' => 'avatar stream',
45                                                                         'width' => AVATAR_STREAM_SIZE,
46                                                                         'height' => AVATAR_STREAM_SIZE,
47                                                                         'alt' =>
48                                                                         ($profile->fullname) ? $profile->fullname :
49                                                                         $profile->nickname));
50                 common_element_end('a');
51                 common_element('a', array('href' => $profile->profileurl,
52                                                                   'class' => 'nickname'),
53                                            $profile->nickname);
54                 # FIXME: URL, image, video, audio
55                 common_element_start('p', array('class' => 'content'));
56                 if ($notice->rendered) {
57                         common_raw($notice->rendered);
58                 } else {
59                         # XXX: may be some uncooked notices in the DB,
60                         # we cook them right now. This should probably disappear in future
61                         # versions (>> 0.4.x)
62                         common_raw(common_render_content($notice->content, $notice));
63                 }
64                 common_element_end('p');
65                 $noticeurl = common_local_url('shownotice', array('notice' => $notice->id));
66                 # XXX: we need to figure this out better. Is this right?
67                 if (strcmp($notice->uri, $noticeurl) != 0 && preg_match('/^http/', $notice->uri)) {
68                         $noticeurl = $notice->uri;
69                 }
70                 common_element_start('p', 'time');
71                 common_element('a', array('class' => 'permalink',
72                                                                   'href' => $noticeurl,
73                                                                   'title' => common_exact_date($notice->created)),
74                                            common_date_string($notice->created));
75                 if ($notice->source) {
76                         common_text(_(' from '));
77                         $this->source_link($notice->source);
78                 }
79                 if ($notice->reply_to) {
80                         $replyurl = common_local_url('shownotice', array('notice' => $notice->reply_to));
81                         common_text(' (');
82                         common_element('a', array('class' => 'inreplyto',
83                                                                           'href' => $replyurl),
84                                                    _('in reply to...'));
85                         common_text(')');
86                 }
87                 common_element_start('a',
88                                                          array('href' => common_local_url('newnotice',
89                                                                                                                           array('replyto' => $profile->nickname)),
90                                                                    'onclick' => 'return doreply("'.$profile->nickname.'", '.$notice->id.');',
91                                                                    'title' => _('reply'),
92                                                                    'class' => 'replybutton'));
93                 common_raw('&rarr;');
94                 common_element_end('a');
95                 if ($user && $notice->profile_id == $user->id) {
96                         $deleteurl = common_local_url('deletenotice', array('notice' => $notice->id));
97                         common_element_start('a', array('class' => 'deletenotice',
98                                                                                         'href' => $deleteurl,
99                                                                                         'title' => _('delete')));
100                         common_raw('&times;');
101                         common_element_end('a');
102                 }
103                 common_element_end('p');
104                 common_element_end('li');
105         }
106 }