summaryrefslogtreecommitdiff
path: root/actions/apitimelinefavorites.php
diff options
context:
space:
mode:
authorZach Copley <zach@status.net>2010-02-11 13:54:40 -0800
committerZach Copley <zach@status.net>2010-02-11 13:56:05 -0800
commitc465f675d9dbcf9f808bc31a1d01e753df4ddf58 (patch)
treecccfd152bf1d52f27cd63d00c0337c1273991a11 /actions/apitimelinefavorites.php
parentc8d5c8442fe6ce54f7f65d1d0eb4203b06c09583 (diff)
Make Atom timelines in the API use Atom10feed
Diffstat (limited to 'actions/apitimelinefavorites.php')
-rw-r--r--actions/apitimelinefavorites.php69
1 files changed, 53 insertions, 16 deletions
diff --git a/actions/apitimelinefavorites.php b/actions/apitimelinefavorites.php
index 1027d97d4..f7f900ddf 100644
--- a/actions/apitimelinefavorites.php
+++ b/actions/apitimelinefavorites.php
@@ -100,11 +100,11 @@ class ApiTimelineFavoritesAction extends ApiBareAuthAction
function showTimeline()
{
- $profile = $this->user->getProfile();
- $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
+ $profile = $this->user->getProfile();
+ $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
- $sitename = common_config('site', 'name');
- $title = sprintf(
+ $sitename = common_config('site', 'name');
+ $title = sprintf(
_('%1$s / Favorites from %2$s'),
$sitename,
$this->user->nickname
@@ -112,32 +112,69 @@ class ApiTimelineFavoritesAction extends ApiBareAuthAction
$taguribase = common_config('integration', 'taguri');
$id = "tag:$taguribase:Favorites:" . $this->user->id;
- $link = common_local_url(
- 'favorites',
- array('nickname' => $this->user->nickname)
- );
- $subtitle = sprintf(
+
+ $subtitle = sprintf(
_('%1$s updates favorited by %2$s / %2$s.'),
$sitename,
$profile->getBestName(),
$this->user->nickname
);
- $logo = ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
+ $logo = !empty($avatar)
+ ? $avatar->displayUrl()
+ : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
switch($this->format) {
case 'xml':
$this->showXmlTimeline($this->notices);
break;
case 'rss':
- $this->showRssTimeline($this->notices, $title, $link, $subtitle, null, $logo);
+ $link = common_local_url(
+ 'showfavorites',
+ array('nickname' => $this->user->nickname)
+ );
+ $this->showRssTimeline(
+ $this->notices,
+ $title,
+ $link,
+ $subtitle,
+ null,
+ $logo
+ );
break;
case 'atom':
- $selfuri = common_root_url() .
- ltrim($_SERVER['QUERY_STRING'], 'p=');
- $this->showAtomTimeline(
- $this->notices, $title, $id, $link, $subtitle,
- null, $selfuri, $logo
+
+ 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(
+ common_local_url(
+ 'showfavorites',
+ array('nickname' => $this->user->nickname)
+ )
+ );
+
+ $id = $this->arg('id');
+ $aargs = array('format' => 'atom');
+ if (!empty($id)) {
+ $aargs['id'] = $id;
+ }
+
+ $atom->addLink(
+ $this->getSelfUri('ApiTimelineFavorites', $aargs),
+ array('rel' => 'self', 'type' => 'application/atom+xml')
);
+
+ $atom->addEntryFromNotices($this->notices);
+
+ $this->raw($atom->getString());
+
break;
case 'json':
$this->showJsonTimeline($this->notices);