123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- <?php
- if (!defined('GNUSOCIAL')) { exit(1); }
- define('MAX_PUBLIC_PAGE', 100);
- class SitestreamAction extends ManagedAction
- {
-
- var $page = null;
- var $notice;
- protected $stream = null;
- function isReadOnly($args)
- {
- return true;
- }
- protected function doPreparation()
- {
- $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
- if ($this->page > MAX_PUBLIC_PAGE) {
-
-
- $this->clientError(sprintf(_('Beyond the page limit (%s).'), MAX_PUBLIC_PAGE));
- }
- common_set_returnto($this->selfUrl());
- $this->streamPrepare();
- $this->notice = $this->stream->getNotices(($this->page-1)*NOTICES_PER_PAGE,
- NOTICES_PER_PAGE + 1);
- if (!$this->notice) {
-
- $this->serverError(_('Could not retrieve public timeline.'));
- }
- if ($this->page > 1 && $this->notice->N == 0){
-
- $this->clientError(_('No such page.'), 404);
- }
- return true;
- }
-
- function title()
- {
- if ($this->page > 1) {
-
-
- return sprintf(_('Public timeline, page %d'), $this->page);
- } else {
-
- return _('Public timeline');
- }
- }
- function extraHead()
- {
- parent::extraHead();
- $rsd = common_local_url('rsd');
-
- $this->element('link', array('rel' => 'EditURI',
- 'type' => 'application/rsd+xml',
- 'href' => $rsd));
- if ($this->page != 1) {
- $this->element('link', array('rel' => 'canonical',
- 'href' => common_local_url('public')));
- }
- }
-
- function getFeeds()
- {
- return array(new Feed(Feed::JSON,
- common_local_url('ApiTimelinePublic',
- array('format' => 'as')),
-
- _('Public Timeline Feed (Activity Streams JSON)')),
- new Feed(Feed::RSS1, common_local_url('publicrss'),
-
- _('Public Timeline Feed (RSS 1.0)')),
- new Feed(Feed::RSS2,
- common_local_url('ApiTimelinePublic',
- array('format' => 'rss')),
-
- _('Public Timeline Feed (RSS 2.0)')),
- new Feed(Feed::ATOM,
- common_local_url('ApiTimelinePublic',
- array('format' => 'atom')),
-
- _('Public Timeline Feed (Atom)')));
- }
- function showEmptyList()
- {
-
- $message = _('This is the public timeline for %%site.name%% but no one has posted anything yet.') . ' ';
- if (common_logged_in()) {
-
- $message .= _('Be the first to post!');
- }
- else {
- if (! (common_config('site','closed') || common_config('site','inviteonly'))) {
-
- $message .= _('Why not [register an account](%%action.register%%) and be the first to post!');
- }
- }
- $this->elementStart('div', 'guide');
- $this->raw(common_markup_to_html($message));
- $this->elementEnd('div');
- }
-
- function showContent()
- {
- if ($this->scoped instanceof Profile && $this->scoped->isLocal() && $this->scoped->getUser()->streamModeOnly()) {
- $nl = new PrimaryNoticeList($this->notice, $this, array('show_n'=>NOTICES_PER_PAGE));
- } else {
- $nl = new ThreadedNoticeList($this->notice, $this, $this->scoped);
- }
- $cnt = $nl->show();
- if ($cnt == 0) {
- $this->showEmptyList();
- }
- $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE,
- $this->page, $this->action);
- }
- function showAnonymousMessage()
- {
- if (! (common_config('site','closed') || common_config('site','inviteonly'))) {
-
-
- $m = _('This is %%site.name%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
- 'based on the Free Software [StatusNet](http://status.net/) tool. ' .
- '[Join now](%%action.register%%) to share notices about yourself with friends, family, and colleagues! ' .
- '([Read more](%%doc.help%%))');
- } else {
-
-
- $m = _('This is %%site.name%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' .
- 'based on the Free Software [StatusNet](http://status.net/) tool.');
- }
- $this->elementStart('div', array('id' => 'anon_notice'));
- $this->raw(common_markup_to_html($m));
- $this->elementEnd('div');
- }
- }
|