diff --git a/actions/apitimelineuser.php b/actions/apitimelineuser.php index c0894c5dba..ac33beada4 100644 --- a/actions/apitimelineuser.php +++ b/actions/apitimelineuser.php @@ -124,6 +124,22 @@ class ApiTimelineUserAction extends ApiBareAuthAction $suplink = common_local_url('sup', null, null, $this->target->id); header('X-SUP-ID: ' . $suplink); + + // paging links + $nextUrl = common_local_url('ApiTimelineUser', + array('format' => $this->format, + 'id' => $this->target->id), + array('max_id' => $this->next_id)); + $lastNotice = $this->notices[0]; + $lastId = $lastNotice->id; + $prevUrl = common_local_url('ApiTimelineUser', + array('format' => $this->format, + 'id' => $this->target->id), + array('since_id' => $lastId)); + $firstUrl = common_local_url('ApiTimelineUser', + array('format' => $this->format, + 'id' => $this->target->id)); + switch($this->format) { case 'xml': $this->showXmlTimeline($this->notices); @@ -150,10 +166,6 @@ class ApiTimelineUserAction extends ApiBareAuthAction // change too quickly! if (!empty($this->next_id)) { - $nextUrl = common_local_url('ApiTimelineUser', - array('format' => 'atom', - 'id' => $this->target->id), - array('max_id' => $this->next_id)); $atom->addLink($nextUrl, array('rel' => 'next', @@ -162,13 +174,6 @@ class ApiTimelineUserAction extends ApiBareAuthAction if (($this->page > 1 || !empty($this->max_id)) && !empty($this->notices)) { - $lastNotice = $this->notices[0]; - $lastId = $lastNotice->id; - - $prevUrl = common_local_url('ApiTimelineUser', - array('format' => 'atom', - 'id' => $this->target->id), - array('since_id' => $lastId)); $atom->addLink($prevUrl, array('rel' => 'prev', @@ -177,10 +182,6 @@ class ApiTimelineUserAction extends ApiBareAuthAction if ($this->page > 1 || !empty($this->since_id) || !empty($this->max_id)) { - $firstUrl = common_local_url('ApiTimelineUser', - array('format' => 'atom', - 'id' => $this->target->id)); - $atom->addLink($firstUrl, array('rel' => 'first', 'type' => 'application/atom+xml')); @@ -201,7 +202,23 @@ class ApiTimelineUserAction extends ApiBareAuthAction $doc->addLink($link, 'alternate', 'text/html'); $doc->addItemsFromNotices($this->notices); - // XXX: Add paging extension? + if (!empty($this->next_id)) { + $doc->addLink($nextUrl, + array('rel' => 'next', + 'type' => ActivityStreamJSONDocument::CONTENT_TYPE)); + } + + if (($this->page > 1 || !empty($this->max_id)) && !empty($this->notices)) { + $doc->addLink($prevUrl, + array('rel' => 'prev', + 'type' => ActivityStreamJSONDocument::CONTENT_TYPE)); + } + + if ($this->page > 1 || !empty($this->since_id) || !empty($this->max_id)) { + $doc->addLink($firstUrl, + array('rel' => 'first', + 'type' => ActivityStreamJSONDocument::CONTENT_TYPE)); + } $this->raw($doc->asString()); break;