]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/public.php
More RESTish URL (/notice/:notice/delete) for notice delete
[quix0rs-gnu-social.git] / actions / public.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * Action for displaying the public stream
6  *
7  * PHP version 5
8  *
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.
13  *
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.
18  *
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/>.
21  *
22  * @category  Public
23  * @package   StatusNet
24  * @author    Evan Prodromou <evan@status.net>
25  * @copyright 2008-2009 StatusNet, Inc.
26  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27  * @link      http://status.net/
28  */
29
30 if (!defined('GNUSOCIAL')) { exit(1); }
31
32 /**
33  * Action for displaying the public stream
34  *
35  * @category Public
36  * @package  StatusNet
37  * @author   Evan Prodromou <evan@status.net>
38  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
39  * @link     http://status.net/
40  *
41  * @see      PublicrssAction
42  */
43 class PublicAction extends SitestreamAction
44 {
45     protected function streamPrepare()
46     {
47         if ($this->scoped instanceof Profile && $this->scoped->isLocal() && $this->scoped->getUser()->streamModeOnly()) {
48             $this->stream = new PublicNoticeStream($this->scoped);
49         } else {
50             $this->stream = new ThreadingPublicNoticeStream($this->scoped);
51         }
52     }
53
54     /**
55      * Title of the page
56      *
57      * @return page title, including page number if over 1
58      */
59     function title()
60     {
61         if ($this->page > 1) {
62             // TRANS: Title for all public timeline pages but the first.
63             // TRANS: %d is the page number.
64             return sprintf(_('Public timeline, page %d'), $this->page);
65         } else {
66             // TRANS: Title for the first public timeline page.
67             return _('Public timeline');
68         }
69     }
70
71     function showSections()
72     {
73         // Show invite button, as long as site isn't closed, and
74         // we have a logged in user.
75         if (common_config('invite', 'enabled') && !common_config('site', 'closed') && common_logged_in()) {
76             if (!common_config('site', 'private')) {
77                 $ibs = new InviteButtonSection(
78                     $this,
79                     // TRANS: Button text for inviting more users to the StatusNet instance.
80                     // TRANS: Less business/enterprise-oriented language for public sites.
81                     _m('BUTTON', 'Send invite')
82                 );
83             } else {
84                 $ibs = new InviteButtonSection($this);
85             }
86             $ibs->show();
87         }
88
89         $p = Profile::current();
90
91         if (!common_config('performance', 'high')) {
92             $cloud = new PublicTagCloudSection($this);
93             $cloud->show();
94         }
95         $feat = new FeaturedUsersSection($this);
96         $feat->show();
97     }
98
99     /**
100      * Output <head> elements for RSS and Atom feeds
101      *
102      * @return void
103      */
104     function getFeeds()
105     {
106         return array(new Feed(Feed::JSON,
107                               common_local_url('ApiTimelinePublic',
108                                                array('format' => 'as')),
109                               // TRANS: Link description for public timeline feed.
110                               _('Public Timeline Feed (Activity Streams JSON)')),
111                     new Feed(Feed::RSS1, common_local_url('publicrss'),
112                               // TRANS: Link description for public timeline feed.
113                               _('Public Timeline Feed (RSS 1.0)')),
114                      new Feed(Feed::RSS2,
115                               common_local_url('ApiTimelinePublic',
116                                                array('format' => 'rss')),
117                               // TRANS: Link description for public timeline feed.
118                               _('Public Timeline Feed (RSS 2.0)')),
119                      new Feed(Feed::ATOM,
120                               common_local_url('ApiTimelinePublic',
121                                                array('format' => 'atom')),
122                               // TRANS: Link description for public timeline feed.
123                               _('Public Timeline Feed (Atom)')));
124     }
125 }