X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fpublic.php;h=73fad182a3f2ab71e7452f349637826dfb95d2d9;hb=4e639b8769f42e700b9ad3abe5564ddb0178501c;hp=a20ae40321ca17b36ae28313f4a87eac90d69f92;hpb=d014d43c6860e3aaf46a5afba0ea3dffd54f630d;p=quix0rs-gnu-social.git diff --git a/actions/public.php b/actions/public.php index a20ae40321..73fad182a3 100644 --- a/actions/public.php +++ b/actions/public.php @@ -1,6 +1,6 @@ . * * @category Public - * @package Laconica - * @author Evan Prodromou - * @copyright 2008-2009 Control Yourself, Inc. + * @package StatusNet + * @author Evan Prodromou + * @copyright 2008-2009 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ + * @link http://status.net/ */ -if (!defined('LACONICA')) { +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } @@ -35,14 +35,18 @@ require_once INSTALLDIR.'/lib/publicgroupnav.php'; require_once INSTALLDIR.'/lib/noticelist.php'; require_once INSTALLDIR.'/lib/feedlist.php'; +// Farther than any human will go + +define('MAX_PUBLIC_PAGE', 100); + /** * Action for displaying the public stream * * @category Public - * @package Laconica - * @author Evan Prodromou + * @package StatusNet + * @author Evan Prodromou * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ + * @link http://status.net/ * * @see PublicrssAction * @see PublicxrdsAction @@ -55,8 +59,9 @@ class PublicAction extends Action */ var $page = null; + var $notice; - function isReadOnly() + function isReadOnly($args) { return true; } @@ -74,8 +79,24 @@ class PublicAction extends Action parent::prepare($args); $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->notice = Notice::publicStream(($this->page-1)*NOTICES_PER_PAGE, + NOTICES_PER_PAGE + 1); + + if (!$this->notice) { + $this->serverError(_('Could not retrieve public stream.')); + return; + } + + if($this->page > 1 && $this->notice->N == 0){ + $this->serverError(_('No such page'),$code=404); + } + return true; } @@ -93,8 +114,6 @@ class PublicAction extends Action { parent::handle($args); - header('X-XRDS-Location: '. common_local_url('publicxrds')); - $this->showPage(); } @@ -135,22 +154,6 @@ class PublicAction extends Action _('Public Stream Feed (Atom)'))); } - /** - * Extra head elements - * - * We include a element linking to the publicxrds page, for OpenID - * client-side authentication. - * - * @return void - */ - - function extraHead() - { - // for client side of OpenID authentication - $this->element('meta', array('http-equiv' => 'X-XRDS-Location', - 'content' => common_local_url('publicxrds'))); - } - /** * Show tabset for this page * @@ -166,6 +169,24 @@ class PublicAction extends Action $nav->show(); } + 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'); + } + /** * Fill the content area * @@ -177,18 +198,14 @@ class PublicAction extends Action function showContent() { - $notice = Notice::publicStream(($this->page-1)*NOTICES_PER_PAGE, - NOTICES_PER_PAGE + 1); - - if (!$notice) { - $this->serverError(_('Could not retrieve public stream.')); - return; - } - - $nl = new NoticeList($notice, $this); + $nl = new NoticeList($this->notice, $this); $cnt = $nl->show(); + if ($cnt == 0) { + $this->showEmptyList(); + } + $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE, $this->page, 'public'); } @@ -199,7 +216,7 @@ class PublicAction extends Action // $top->show(); $pop = new PopularNoticeSection($this); $pop->show(); - $gbp = new GroupsByPostsSection($this); + $gbp = new GroupsByMembersSection($this); $gbp->show(); $feat = new FeaturedUsersSection($this); $feat->show(); @@ -207,9 +224,15 @@ class PublicAction extends Action function showAnonymousMessage() { - $m = _('This is %%site.name%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' . - 'based on the Free Software [Laconica](http://laconi.ca/) tool. ' . - '[Join now](%%action.register%%) to share notices about yourself with friends, family, and colleagues! ([Read more](%%doc.help%%))'); + 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');