]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/all.php
Added new 'Scroller' plugin from @buttle which aims to replace the out-dated
[quix0rs-gnu-social.git] / actions / all.php
1 <?php
2 /**
3  * StatusNet - the distributed open-source microblogging tool
4  * Copyright (C) 2008-2011, StatusNet, 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  * @category Actions
20  * @package  Actions
21  * @author   Adrian Lang <mail@adrianlang.de>
22  * @author   Brenda Wallace <shiny@cpan.org>
23  * @author   Brion Vibber <brion@pobox.com>
24  * @author   Craig Andrews <candrews@integralblue.com>
25  * @author   Evan Prodromou <evan@status.net>
26  * @author   Jeffery To <jeffery.to@gmail.com>
27  * @author   Meitar Moscovitz <meitarm@gmail.com>
28  * @author   Mike Cochrane <mikec@mikenz.geek.nz>
29  * @author   Robin Millette <millette@status.net>
30  * @author   Sarven Capadisli <csarven@status.net>
31  * @author   Siebrand Mazeland <s.mazeland@xs4all.nl>
32  * @author   Zach Copley <zach@status.net>
33  * @copyright 2009-2014 Free Software Foundation, Inc http://www.fsf.org
34  * @license  GNU Affero General Public License http://www.gnu.org/licenses/
35  * @link     http://status.net
36  */
37
38 if (!defined('GNUSOCIAL') && !defined('STATUSNET')) { exit(1); }
39
40 class AllAction extends ProfileAction
41 {
42     var $notice;
43
44     protected function profileActionPreparation()
45     {
46         if ($this->scoped instanceof Profile && $this->scoped->isLocal() && $this->scoped->getUser()->streamModeOnly()) {
47             $stream = new InboxNoticeStream($this->target, $this->scoped);
48         } else {
49             $stream = new ThreadingInboxNoticeStream($this->target, $this->scoped);
50         }
51
52         $this->notice = $stream->getNotices(($this->page-1)*NOTICES_PER_PAGE,
53                                             NOTICES_PER_PAGE + 1);
54
55         if ($this->page > 1 && $this->notice->N == 0) {
56             // TRANS: Client error when page not found (404).
57             $this->clientError(_('No such page.'), 404);
58         }
59     }
60
61     function title()
62     {
63         if (!empty($this->scoped) && $this->scoped->id == $this->target->id) {
64             // TRANS: Title of a user's own start page.
65             return _('Home timeline');
66         } else {
67             // TRANS: Title of another user's start page.
68             // TRANS: %s is the other user's name.
69             return sprintf(_("%s's home timeline"), $this->target->getBestName());
70         }
71     }
72
73     function getFeeds()
74     {
75         return array(
76             new Feed(Feed::JSON,
77                 common_local_url(
78                     'ApiTimelineFriends', array(
79                         'format' => 'as',
80                         'id' => $this->target->nickname
81                     )
82                 ),
83                 // TRANS: %s is user nickname.
84                 sprintf(_('Feed for friends of %s (Activity Streams JSON)'), $this->target->nickname)),
85             new Feed(Feed::RSS1,
86                 common_local_url(
87                     'allrss', array(
88                         'nickname' =>
89                         $this->target->nickname)
90                 ),
91                 // TRANS: %s is user nickname.
92                 sprintf(_('Feed for friends of %s (RSS 1.0)'), $this->target->nickname)),
93             new Feed(Feed::RSS2,
94                 common_local_url(
95                     'ApiTimelineFriends', array(
96                         'format' => 'rss',
97                         'id' => $this->target->nickname
98                     )
99                 ),
100                 // TRANS: %s is user nickname.
101                 sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->target->nickname)),
102             new Feed(Feed::ATOM,
103                 common_local_url(
104                     'ApiTimelineFriends', array(
105                         'format' => 'atom',
106                         'id' => $this->target->nickname
107                     )
108                 ),
109                 // TRANS: %s is user nickname.
110                 sprintf(_('Feed for friends of %s (Atom)'), $this->target->nickname))
111         );
112     }
113
114     function showEmptyListMessage()
115     {
116         // TRANS: Empty list message. %s is a user nickname.
117         $message = sprintf(_('This is the timeline for %s and friends but no one has posted anything yet.'), $this->target->nickname) . ' ';
118
119         if (common_logged_in()) {
120             if ($this->target->id === $this->scoped->id) {
121                 // TRANS: Encouragement displayed on logged in user's empty timeline.
122                 // TRANS: This message contains Markdown links. Keep "](" together.
123                 $message .= _('Try subscribing to more people, [join a group](%%action.groups%%) or post something yourself.');
124             } else {
125                 // TRANS: %1$s is user nickname, %2$s is user nickname, %2$s is user nickname prefixed with "@".
126                 // TRANS: This message contains Markdown links. Keep "](" together.
127                 $message .= sprintf(_('You can try to [nudge %1$s](../%2$s) from their profile or [post something to them](%%%%action.newnotice%%%%?status_textarea=%3$s).'), $this->target->nickname, $this->target->nickname, '@' . $this->target->nickname);
128             }
129         } else {
130             // TRANS: Encouragement displayed on empty timeline user pages for anonymous users.
131             // TRANS: %s is a user nickname. This message contains Markdown links. Keep "](" together.
132             $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to them.'), $this->target->nickname);
133         }
134
135         $this->elementStart('div', 'guide');
136         $this->raw(common_markup_to_html($message));
137         $this->elementEnd('div');
138     }
139
140     function showContent()
141     {
142         if (Event::handle('StartShowAllContent', array($this))) {
143
144             $profile = null;
145
146             $current_user = common_current_user();
147
148             if (!empty($current_user)) {
149                 $profile = $current_user->getProfile();
150             }
151
152             if (!empty($current_user) && $current_user->streamModeOnly()) {
153                 $nl = new PrimaryNoticeList($this->notice, $this, array('show_n'=>NOTICES_PER_PAGE));
154             } else {
155                 $nl = new ThreadedNoticeList($this->notice, $this, $profile);
156             }
157
158             $cnt = $nl->show();
159
160             if (0 == $cnt) {
161                 $this->showEmptyListMessage();
162             }
163
164             $this->pagination(
165                 $this->page > 1, $cnt > NOTICES_PER_PAGE,
166                 $this->page, 'all', array('nickname' => $this->target->nickname)
167             );
168
169             Event::handle('EndShowAllContent', array($this));
170         }
171     }
172
173     function showSections()
174     {
175         // Show invite button, as long as site isn't closed, and
176         // we have a logged in user.
177         if (common_config('invite', 'enabled') && !common_config('site', 'closed') && common_logged_in()) {
178             if (!common_config('site', 'private')) {
179                 $ibs = new InviteButtonSection(
180                     $this,
181                     // TRANS: Button text for inviting more users to the StatusNet instance.
182                     // TRANS: Less business/enterprise-oriented language for public sites.
183                     _m('BUTTON', 'Send invite')
184                 );
185             } else {
186                 $ibs = new InviteButtonSection($this);
187             }
188             $ibs->show();
189         }
190         // XXX: make this a little more convenient
191
192         if (!common_config('performance', 'high')) {
193             $pop = new InboxTagCloudSection($this, $this->target);
194             $pop->show();
195         }
196     }
197 }
198
199 class ThreadingInboxNoticeStream extends ThreadingNoticeStream
200 {
201     function __construct(Profile $target, Profile $scoped=null)
202     {
203         parent::__construct(new InboxNoticeStream($target, $scoped));
204     }
205 }