]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/all.php
Merge branch 'master' of https://git.gnu.io/gnu/gnu-social into social-master
[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')) { exit(1); }
39
40 class AllAction extends ShowstreamAction
41 {
42     var $notice;
43
44     public function getStream()
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         return $stream;
53     }
54
55     function title()
56     {
57         if (!empty($this->scoped) && $this->scoped->id == $this->target->id) {
58             // TRANS: Title of a user's own start page.
59             return _('Home timeline');
60         } else {
61             // TRANS: Title of another user's start page.
62             // TRANS: %s is the other user's name.
63             return sprintf(_("%s's home timeline"), $this->target->getBestName());
64         }
65     }
66
67     function getFeeds()
68     {
69         return array(
70             new Feed(Feed::JSON,
71                 common_local_url(
72                     'ApiTimelineFriends', array(
73                         'format' => 'as',
74                         'id' => $this->target->nickname
75                     )
76                 ),
77                 // TRANS: %s is user nickname.
78                 sprintf(_('Feed for friends of %s (Activity Streams JSON)'), $this->target->nickname)),
79             new Feed(Feed::RSS1,
80                 common_local_url(
81                     'allrss', array(
82                         'nickname' =>
83                         $this->target->nickname)
84                 ),
85                 // TRANS: %s is user nickname.
86                 sprintf(_('Feed for friends of %s (RSS 1.0)'), $this->target->nickname)),
87             new Feed(Feed::RSS2,
88                 common_local_url(
89                     'ApiTimelineFriends', array(
90                         'format' => 'rss',
91                         'id' => $this->target->nickname
92                     )
93                 ),
94                 // TRANS: %s is user nickname.
95                 sprintf(_('Feed for friends of %s (RSS 2.0)'), $this->target->nickname)),
96             new Feed(Feed::ATOM,
97                 common_local_url(
98                     'ApiTimelineFriends', array(
99                         'format' => 'atom',
100                         'id' => $this->target->nickname
101                     )
102                 ),
103                 // TRANS: %s is user nickname.
104                 sprintf(_('Feed for friends of %s (Atom)'), $this->target->nickname))
105         );
106     }
107
108     function showEmptyListMessage()
109     {
110         // TRANS: Empty list message. %s is a user nickname.
111         $message = sprintf(_('This is the timeline for %s and friends but no one has posted anything yet.'), $this->target->nickname) . ' ';
112
113         if (common_logged_in()) {
114             if ($this->target->id === $this->scoped->id) {
115                 // TRANS: Encouragement displayed on logged in user's empty timeline.
116                 // TRANS: This message contains Markdown links. Keep "](" together.
117                 $message .= _('Try subscribing to more people, [join a group](%%action.groups%%) or post something yourself.');
118             } else {
119                 // TRANS: %1$s is user nickname, %2$s is user nickname, %2$s is user nickname prefixed with "@".
120                 // TRANS: This message contains Markdown links. Keep "](" together.
121                 $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);
122             }
123         } else {
124             // TRANS: Encouragement displayed on empty timeline user pages for anonymous users.
125             // TRANS: %s is a user nickname. This message contains Markdown links. Keep "](" together.
126             $message .= sprintf(_('Why not [register an account](%%%%action.register%%%%) and then nudge %s or post a notice to them.'), $this->target->nickname);
127         }
128
129         $this->elementStart('div', 'guide');
130         $this->raw(common_markup_to_html($message));
131         $this->elementEnd('div');
132     }
133
134     function showContent()
135     {
136         if (Event::handle('StartShowAllContent', array($this))) {
137
138             $profile = null;
139
140             $current_user = common_current_user();
141
142             if (!empty($current_user)) {
143                 $profile = $current_user->getProfile();
144             }
145
146             if (!empty($current_user) && $current_user->streamModeOnly()) {
147                 $nl = new PrimaryNoticeList($this->notice, $this, array('show_n'=>NOTICES_PER_PAGE));
148             } else {
149                 $nl = new ThreadedNoticeList($this->notice, $this, $profile);
150             }
151
152             $cnt = $nl->show();
153
154             if (0 == $cnt) {
155                 $this->showEmptyListMessage();
156             }
157
158             $this->pagination(
159                 $this->page > 1, $cnt > NOTICES_PER_PAGE,
160                 $this->page, 'all', array('nickname' => $this->target->nickname)
161             );
162
163             Event::handle('EndShowAllContent', array($this));
164         }
165     }
166
167     function showSections()
168     {
169         // Show invite button, as long as site isn't closed, and
170         // we have a logged in user.
171         if (common_config('invite', 'enabled') && !common_config('site', 'closed') && common_logged_in()) {
172             if (!common_config('site', 'private')) {
173                 $ibs = new InviteButtonSection(
174                     $this,
175                     // TRANS: Button text for inviting more users to the StatusNet instance.
176                     // TRANS: Less business/enterprise-oriented language for public sites.
177                     _m('BUTTON', 'Send invite')
178                 );
179             } else {
180                 $ibs = new InviteButtonSection($this);
181             }
182             $ibs->show();
183         }
184         // XXX: make this a little more convenient
185
186         if (!common_config('performance', 'high')) {
187             $pop = new InboxTagCloudSection($this, $this->target);
188             $pop->show();
189         }
190     }
191 }
192
193 class ThreadingInboxNoticeStream extends ThreadingNoticeStream
194 {
195     function __construct(Profile $target, Profile $scoped=null)
196     {
197         parent::__construct(new InboxNoticeStream($target, $scoped));
198     }
199 }