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 $this->element('meta', array('http-equiv' => 'X-XRDS-Location',
76 'content' => common_local_url('publicxrds')));
78 $rsd = common_local_url('rsd');
80 // RSD, http://tales.phrasewise.com/rfc/rsd
82 $this->element('link', array('rel' => 'EditURI',
83 'type' => 'application/rsd+xml',
86 if ($this->page != 1) {
87 $this->element('link', array('rel' => 'canonical',
88 'href' => common_local_url('public')));
93 * Output <head> elements for RSS and Atom feeds
99 return array(new Feed(Feed::JSON,
100 common_local_url('ApiTimelinePublic',
101 array('format' => 'as')),
102 // TRANS: Link description for public timeline feed.
103 _('Public Timeline Feed (Activity Streams JSON)')),
104 new Feed(Feed::RSS1, common_local_url('publicrss'),
105 // TRANS: Link description for public timeline feed.
106 _('Public Timeline Feed (RSS 1.0)')),
108 common_local_url('ApiTimelinePublic',
109 array('format' => 'rss')),
110 // TRANS: Link description for public timeline feed.
111 _('Public Timeline Feed (RSS 2.0)')),
113 common_local_url('ApiTimelinePublic',
114 array('format' => 'atom')),
115 // TRANS: Link description for public timeline feed.
116 _('Public Timeline Feed (Atom)')));
119 function showEmptyList()
121 // TRANS: Text displayed for public feed when there are no public notices.
122 $message = _('This is the public timeline for %%site.name%% but no one has posted anything yet.') . ' ';
124 if (common_logged_in()) {
125 // TRANS: Additional text displayed for public feed when there are no public notices for a logged in user.
126 $message .= _('Be the first to post!');
129 if (! (common_config('site','closed') || common_config('site','inviteonly'))) {
130 // TRANS: Additional text displayed for public feed when there are no public notices for a not logged in user.
131 $message .= _('Why not [register an account](%%action.register%%) and be the first to post!');
135 $this->elementStart('div', 'guide');
136 $this->raw(common_markup_to_html($message));
137 $this->elementEnd('div');
141 * Fill the content area
143 * Shows a list of the notices in the public stream, with some pagination
148 function showContent()
150 if ($this->scoped instanceof Profile && $this->scoped->isLocal() && $this->scoped->getUser()->streamModeOnly()) {
151 $nl = new PrimaryNoticeList($this->notice, $this, array('show_n'=>NOTICES_PER_PAGE));
153 $nl = new ThreadedNoticeList($this->notice, $this, $this->scoped);
159 $this->showEmptyList();
162 $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
163 $this->page, $this->action);
166 function showAnonymousMessage()
168 if (! (common_config('site','closed') || common_config('site','inviteonly'))) {
169 // TRANS: Message for not logged in users at an invite-only site trying to view the public feed of notices.
170 // TRANS: This message contains Markdown links. Please mind the formatting.
171 $m = _('This is %%site.name%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
172 'based on the Free Software [StatusNet](http://status.net/) tool. ' .
173 '[Join now](%%action.register%%) to share notices about yourself with friends, family, and colleagues! ' .
174 '([Read more](%%doc.help%%))');
176 // TRANS: Message for not logged in users at a closed site trying to view the public feed of notices.
177 // TRANS: This message contains Markdown links. Please mind the formatting.
178 $m = _('This is %%site.name%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
179 'based on the Free Software [StatusNet](http://status.net/) tool.');
181 $this->elementStart('div', array('id' => 'anon_notice'));
182 $this->raw(common_markup_to_html($m));
183 $this->elementEnd('div');