X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapitimelinepublic.php;h=b82e01aafe5658494544ab7f83b89bfe9a130a3d;hb=bce337e7c31c2badf34a3af99da6fc2158eedddd;hp=0119b504a7bb34899f9783455107e955e6df974e;hpb=b5cfcba4712809cb17eabba299ce5ff04f4d7d70;p=quix0rs-gnu-social.git diff --git a/actions/apitimelinepublic.php b/actions/apitimelinepublic.php index 0119b504a7..b82e01aafe 100644 --- a/actions/apitimelinepublic.php +++ b/actions/apitimelinepublic.php @@ -144,10 +144,8 @@ require_once INSTALLDIR . '/lib/apiprivateauth.php'; @endverbatim */ - class ApiTimelinePublicAction extends ApiPrivateAuthAction { - var $notices = null; /** @@ -158,7 +156,6 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction * @return boolean success flag * */ - function prepare($args) { parent::prepare($args); @@ -177,7 +174,6 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction * * @return void */ - function handle($args) { parent::handle($args); @@ -189,16 +185,17 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction * * @return void */ - function showTimeline() { $sitename = common_config('site', 'name'); $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); $taguribase = TagURI::base(); $id = "tag:$taguribase:PublicTimeline"; $link = common_local_url('public'); $self = $this->getSelfUri(); + // TRANS: Subtitle for site timeline. %s is the StatusNet sitename. $subtitle = sprintf(_("%s updates from everyone!"), $sitename); switch($this->format) { @@ -237,7 +234,16 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction case 'json': $this->showJsonTimeline($this->notices); break; + case 'as': + header('Content-Type: ' . ActivityStreamJSONDocument::CONTENT_TYPE); + $doc = new ActivityStreamJSONDocument($this->auth_user); + $doc->setTitle($title); + $doc->addLink($link, 'alternate', 'text/html'); + $doc->addItemsFromNotices($this->notices); + $this->raw($doc->asString()); + break; default: + // TRANS: Client error displayed when coming across a non-supported API method. $this->clientError(_('API method not found.'), $code = 404); break; } @@ -248,19 +254,22 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction * * @return array notices */ - function getNotices() { $notices = array(); - $notice = Notice::publicStream( - ($this->page - 1) * $this->count, $this->count, $this->since_id, - $this->max_id - ); + $profile = ($this->auth_user) ? $this->auth_user->getProfile() : null; - while ($notice->fetch()) { - $notices[] = clone($notice); - } + $stream = new PublicNoticeStream($profile); + + $notice = $stream->getNotices(($this->page - 1) * $this->count, + $this->count, + $this->since_id, + $this->max_id); + + $notices = $notice->fetchAll(); + + NoticeList::prefill($notices); return $notices; } @@ -272,7 +281,6 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction * * @return boolean true */ - function isReadOnly($args) { return true; @@ -283,7 +291,6 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction * * @return string datestamp of the latest notice in the stream */ - function lastModified() { if (!empty($this->notices) && (count($this->notices) > 0)) { @@ -301,7 +308,6 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction * * @return string etag */ - function etag() { if (!empty($this->notices) && (count($this->notices) > 0)) { @@ -321,5 +327,4 @@ class ApiTimelinePublicAction extends ApiPrivateAuthAction return null; } - }