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