]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/public.php
039e885e6ba4b53f22fd1fc2dc3298a17e2fb53f
[quix0rs-gnu-social.git] / actions / public.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/stream.php');
23
24 class PublicAction extends StreamAction
25 {
26
27     function handle($args)
28     {
29         parent::handle($args);
30
31         $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
32
33         header('X-XRDS-Location: '. common_local_url('publicxrds'));
34
35         common_show_header(_('Public timeline'),
36                            array($this, 'show_header'), null,
37                            array($this, 'show_top'));
38
39         # XXX: Public sidebar here?
40
41         $this->show_notices($page);
42
43         common_show_footer();
44     }
45
46     function show_top()
47     {
48         if (common_logged_in()) {
49             common_notice_form('public');
50         } else {
51             $instr = $this->get_instructions();
52             $output = common_markup_to_html($instr);
53             common_element_start('div', 'instructions');
54             common_raw($output);
55             common_element_end('div');
56         }
57
58         $this->public_views_menu();
59
60         $this->show_feeds_list(array(0=>array('href'=>common_local_url('publicrss'),
61                                               'type' => 'rss',
62                                               'version' => 'RSS 1.0',
63                                               'item' => 'publicrss'),
64                                      1=>array('href'=>common_local_url('publicatom'),
65                                               'type' => 'atom',
66                                               'version' => 'Atom 1.0',
67                                               'item' => 'publicatom')));
68     }
69
70     function get_instructions()
71     {
72         return _('This is %%site.name%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
73                  'based on the Free Software [Laconica](http://laconi.ca/) tool. ' .
74                  '[Join now](%%action.register%%) to share notices about yourself with friends, family, and colleagues! ([Read more](%%doc.help%%))');
75     }
76
77     function show_header()
78     {
79         common_element('link', array('rel' => 'alternate',
80                                      'href' => common_local_url('publicrss'),
81                                      'type' => 'application/rss+xml',
82                                      'title' => _('Public Stream Feed')));
83         # for client side of OpenID authentication
84         common_element('meta', array('http-equiv' => 'X-XRDS-Location',
85                                      'content' => common_local_url('publicxrds')));
86     }
87
88     function show_notices($page)
89     {
90
91         $cnt = 0;
92         $notice = Notice::publicStream(($page-1)*NOTICES_PER_PAGE,
93                                        NOTICES_PER_PAGE + 1);
94
95         if (!$notice) {
96             $this->server_error(_('Could not retrieve public stream.'));
97             return;
98         }
99
100         $cnt = $this->show_notice_list($notice);
101
102         common_pagination($page > 1, $cnt > NOTICES_PER_PAGE,
103                           $page, 'public');
104     }
105 }