X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapitimelinetag.php;h=fed1437ea805805a06ba4c3ba608aebbc952076d;hb=80d1e86a7c54521f364600c85c9f29ff29aaa611;hp=1627763798a4c55c8171dbf71ebaf7f27c581dbc;hpb=8d284ca82c1e33a102ef4cb7aa150dd54d876ec7;p=quix0rs-gnu-social.git diff --git a/actions/apitimelinetag.php b/actions/apitimelinetag.php index 1627763798..fed1437ea8 100644 --- a/actions/apitimelinetag.php +++ b/actions/apitimelinetag.php @@ -21,8 +21,11 @@ * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To * @author Zach Copley - * @copyright 2009 StatusNet, Inc. + * @copyright 2009-2010 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ @@ -31,19 +34,22 @@ if (!defined('STATUSNET')) { exit(1); } -require_once INSTALLDIR.'/lib/twitterapi.php'; +require_once INSTALLDIR . '/lib/apiprivateauth.php'; /** * Returns the 20 most recent notices tagged by a given tag * * @category API * @package StatusNet + * @author Craig Andrews + * @author Evan Prodromou + * @author Jeffery To * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ -class ApiTimelineTagAction extends TwitterapiAction +class ApiTimelineTagAction extends ApiPrivateAuthAction { var $notices = null; @@ -61,11 +67,9 @@ class ApiTimelineTagAction extends TwitterapiAction { parent::prepare($args); - $this->page = (int)$this->arg('page', 1); - $this->count = (int)$this->arg('count', 20); - $this->tag = $this->arg('tag'); - $this->format = $this->arg('format'); + common_debug("apitimelinetag prepare()"); + $this->tag = $this->arg('tag'); $this->notices = $this->getNotices(); return true; @@ -96,35 +100,64 @@ class ApiTimelineTagAction extends TwitterapiAction function showTimeline() { $sitename = common_config('site', 'name'); + $sitelogo = (common_config('site', 'logo')) ? common_config('site', 'logo') : Theme::path('logo.png'); $title = sprintf(_("Notices tagged with %s"), $this->tag); - $link = common_local_url('tag', - array('tag' => $this->tag)); - $subtitle = sprintf(_('Updates tagged with %1$s on %2$s!'), - $this->tag, $sitename); - $taguribase = common_config('integration', 'taguri'); + $subtitle = sprintf( + _('Updates tagged with %1$s on %2$s!'), + $this->tag, + $sitename + ); + $taguribase = TagURI::base(); $id = "tag:$taguribase:TagTimeline:".$tag; + $link = common_local_url( + 'tag', + array('tag' => $this->tag) + ); + + $self = $this->getSelfUri(); + + common_debug("self link is: $self"); + switch($this->format) { case 'xml': - $this->show_xml_timeline($this->notices); + $this->showXmlTimeline($this->notices); break; case 'rss': - $this->show_rss_timeline($this->notices, $title, $link, $subtitle); + $this->showRssTimeline( + $this->notices, + $title, + $link, + $subtitle, + null, + $sitelogo, + $self + ); break; case 'atom': - $selfuri = common_root_url() . - 'api/statusnet/tags/timeline/' . - $this->tag . '.atom'; - $this->show_atom_timeline( - $this->notices, $title, $id, $link, - $subtitle, null, $selfuri - ); + + header('Content-Type: application/atom+xml; charset=utf-8'); + + $atom = new AtomNoticeFeed(); + + $atom->setId($id); + $atom->setTitle($title); + $atom->setSubtitle($subtitle); + $atom->setLogo($logo); + $atom->setUpdated('now'); + + $atom->addLink($link); + $atom->setSelfLink($self); + + $atom->addEntryFromNotices($this->notices); + $this->raw($atom->getString()); + break; case 'json': - $this->show_json_timeline($this->notices); + $this->showJsonTimeline($this->notices); break; default: - $this->clientError(_('API method not found!'), $code = 404); + $this->clientError(_('API method not found.'), $code = 404); break; } }