3 if (!defined('GNUSOCIAL')) { exit(1); }
5 // Farther than any human will go
7 define('MAX_PUBLIC_PAGE', 100);
9 class SitestreamAction extends ManagedAction
12 * page of the stream we're on; default = 1
18 protected $stream = null;
20 function isReadOnly($args)
25 protected function doPreparation()
27 $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
29 if ($this->page > MAX_PUBLIC_PAGE) {
30 // TRANS: Client error displayed when requesting a public timeline page beyond the page limit.
31 // TRANS: %s is the page limit.
32 $this->clientError(sprintf(_('Beyond the page limit (%s).'), MAX_PUBLIC_PAGE));
35 common_set_returnto($this->selfUrl());
37 $this->streamPrepare();
39 $this->notice = $this->stream->getNotices(($this->page-1)*NOTICES_PER_PAGE,
40 NOTICES_PER_PAGE + 1);
43 // TRANS: Server error displayed when a public timeline cannot be retrieved.
44 $this->serverError(_('Could not retrieve public timeline.'));
47 if ($this->page > 1 && $this->notice->N == 0){
48 // TRANS: Client error when page not found (404).
49 $this->clientError(_('No such page.'), 404);
58 * @return page title, including page number if over 1
62 if ($this->page > 1) {
63 // TRANS: Title for all public timeline pages but the first.
64 // TRANS: %d is the page number.
65 return sprintf(_('Public timeline, page %d'), $this->page);
67 // TRANS: Title for the first public timeline page.
68 return _('Public timeline');
75 $rsd = common_local_url('rsd');
77 // RSD, http://tales.phrasewise.com/rfc/rsd
79 $this->element('link', array('rel' => 'EditURI',
80 'type' => 'application/rsd+xml',
83 if ($this->page != 1) {
84 $this->element('link', array('rel' => 'canonical',
85 'href' => common_local_url('public')));
90 * Output <head> elements for RSS and Atom feeds
96 return array(new Feed(Feed::JSON,
97 common_local_url('ApiTimelinePublic',
98 array('format' => 'as')),
99 // TRANS: Link description for public timeline feed.
100 _('Public Timeline Feed (Activity Streams JSON)')),
101 new Feed(Feed::RSS1, common_local_url('publicrss'),
102 // TRANS: Link description for public timeline feed.
103 _('Public Timeline Feed (RSS 1.0)')),
105 common_local_url('ApiTimelinePublic',
106 array('format' => 'rss')),
107 // TRANS: Link description for public timeline feed.
108 _('Public Timeline Feed (RSS 2.0)')),
110 common_local_url('ApiTimelinePublic',
111 array('format' => 'atom')),
112 // TRANS: Link description for public timeline feed.
113 _('Public Timeline Feed (Atom)')));
116 function showEmptyList()
118 // TRANS: Text displayed for public feed when there are no public notices.
119 $message = _('This is the public timeline for %%site.name%% but no one has posted anything yet.') . ' ';
121 if (common_logged_in()) {
122 // TRANS: Additional text displayed for public feed when there are no public notices for a logged in user.
123 $message .= _('Be the first to post!');
126 if (! (common_config('site','closed') || common_config('site','inviteonly'))) {
127 // TRANS: Additional text displayed for public feed when there are no public notices for a not logged in user.
128 $message .= _('Why not [register an account](%%action.register%%) and be the first to post!');
132 $this->elementStart('div', 'guide');
133 $this->raw(common_markup_to_html($message));
134 $this->elementEnd('div');
138 * Fill the content area
140 * Shows a list of the notices in the public stream, with some pagination
145 function showContent()
147 if ($this->scoped instanceof Profile && $this->scoped->isLocal() && $this->scoped->getUser()->streamModeOnly()) {
148 $nl = new PrimaryNoticeList($this->notice, $this, array('show_n'=>NOTICES_PER_PAGE));
150 $nl = new ThreadedNoticeList($this->notice, $this, $this->scoped);
156 $this->showEmptyList();
159 $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
160 $this->page, $this->action);
163 function showAnonymousMessage()
165 if (! (common_config('site','closed') || common_config('site','inviteonly'))) {
166 // TRANS: Message for not logged in users at an invite-only site trying to view the public feed of notices.
167 // TRANS: This message contains Markdown links. Please mind the formatting.
168 $m = _('This is %%site.name%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
169 'based on the Free Software [StatusNet](http://status.net/) tool. ' .
170 '[Join now](%%action.register%%) to share notices about yourself with friends, family, and colleagues! ' .
171 '([Read more](%%doc.help%%))');
173 // TRANS: Message for not logged in users at a closed site trying to view the public feed of notices.
174 // TRANS: This message contains Markdown links. Please mind the formatting.
175 $m = _('This is %%site.name%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
176 'based on the Free Software [StatusNet](http://status.net/) tool.');
178 $this->elementStart('div', array('id' => 'anon_notice'));
179 $this->raw(common_markup_to_html($m));
180 $this->elementEnd('div');