X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapitimelinepublic.php;h=957c187f9ff6b938a2cb403781b465b203cccd0e;hb=261ccfac8699534ff584a2f93d5dcd384529d855;hp=353973b6533a9d76fe25008a773db90dbb716272;hpb=2bd9532ebeef11f4e6032ace294115a990006c4c;p=quix0rs-gnu-social.git diff --git a/actions/apitimelinepublic.php b/actions/apitimelinepublic.php index 353973b653..957c187f9f 100644 --- a/actions/apitimelinepublic.php +++ b/actions/apitimelinepublic.php @@ -38,8 +38,6 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR . '/lib/apiprivateauth.php'; - /** * Returns the most recent notices (default 20) posted by everybody * @@ -156,7 +154,7 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction * @return boolean success flag * */ - function prepare($args) + protected function prepare(array $args=array()) { parent::prepare($args); @@ -170,16 +168,20 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction * * Just show the notices * - * @param array $args $_REQUEST data (unused) - * * @return void */ - function handle($args) + protected function handle() { - parent::handle($args); + parent::handle(); $this->showTimeline(); } + function title() + { + // TRANS: Title for site timeline. %s is the GNU social sitename. + return sprintf(_("%s public timeline"), common_config('site', 'name')); + } + /** * Show the timeline of notices * @@ -187,16 +189,16 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction */ function showTimeline() { - $sitename = common_config('site', 'name'); + $nonapi_action = substr($this->action, strlen('apitimeline')); // Just so we don't need to set this explicitly + $sitelogo = (common_config('site', 'logo')) ? common_config('site', 'logo') : Theme::path('logo.png'); - // TRANS: Title for site timeline. %s is the StatusNet sitename. - $title = sprintf(_("%s public timeline"), $sitename); + $title = $this->title(); $taguribase = TagURI::base(); - $id = "tag:$taguribase:PublicTimeline"; - $link = common_local_url('public'); + $id = "tag:$taguribase:" . ucfirst($nonapi_action) . 'Timeline'; // Public or Networkpublic probably + $link = common_local_url($nonapi_action); $self = $this->getSelfUri(); - // TRANS: Subtitle for site timeline. %s is the StatusNet sitename. - $subtitle = sprintf(_("%s updates from everyone!"), $sitename); + // TRANS: Subtitle for site timeline. %s is the GNU social sitename. + $subtitle = sprintf(_("%s updates from everyone!"), common_config('site', 'name')); switch($this->format) { case 'xml': @@ -224,7 +226,7 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction $atom->setSubtitle($subtitle); $atom->setLogo($sitelogo); $atom->setUpdated('now'); - $atom->addLink(common_local_url('public')); + $atom->addLink(common_local_url($nonapi_action)); $atom->setSelfLink($self); $atom->addEntryFromNotices($this->notices); @@ -235,7 +237,7 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction $this->showJsonTimeline($this->notices); break; case 'as': - header('Content-Type: application/json; charset=utf-8'); + header('Content-Type: ' . ActivityStreamJSONDocument::CONTENT_TYPE); $doc = new ActivityStreamJSONDocument($this->auth_user); $doc->setTitle($title); $doc->addLink($link, 'alternate', 'text/html'); @@ -243,7 +245,7 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction $this->raw($doc->asString()); break; default: - // TRANS: Client error displayed when trying to handle an unknown API method. + // TRANS: Client error displayed when coming across a non-supported API method. $this->clientError(_('API method not found.'), $code = 404); break; } @@ -258,18 +260,25 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction { $notices = array(); - $notice = Notice::publicStream( - ($this->page - 1) * $this->count, $this->count, $this->since_id, - $this->max_id - ); + $stream = $this->getStream(); - while ($notice->fetch()) { - $notices[] = clone($notice); - } + $notice = $stream->getNotices(($this->page - 1) * $this->count, + $this->count, + $this->since_id, + $this->max_id); + + $notices = $notice->fetchAll(); + + NoticeList::prefill($notices); return $notices; } + protected function getStream() + { + return new PublicNoticeStream($this->scoped); + } + /** * Is this action read only? * @@ -277,7 +286,7 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction * * @return boolean true */ - function isReadOnly($args) + function isReadOnly(array $args=array()) { return true; }