Exemplo n.º 1
0
 /**
  * Show the timeline of notices
  *
  * @return void
  */
 function showTimeline()
 {
     $profile = $this->user->getProfile();
     // We'll use the shared params from the Atom stub
     // for other feed types.
     $atom = new AtomUserNoticeFeed($this->user, $this->auth_user);
     $link = common_local_url('showstream', array('nickname' => $this->user->nickname));
     $self = $this->getSelfUri();
     // FriendFeed's SUP protocol
     // Also added RSS and Atom feeds
     $suplink = common_local_url('sup', null, null, $this->user->id);
     header('X-SUP-ID: ' . $suplink);
     switch ($this->format) {
         case 'xml':
             $this->showXmlTimeline($this->notices);
             break;
         case 'rss':
             $this->showRssTimeline($this->notices, $atom->title, $link, $atom->subtitle, $suplink, $atom->logo, $self);
             break;
         case 'atom':
             header('Content-Type: application/atom+xml; charset=utf-8');
             $atom->setId($self);
             $atom->setSelfLink($self);
             $atom->addEntryFromNotices($this->notices);
             $this->raw($atom->getString());
             break;
         case 'json':
             $this->showJsonTimeline($this->notices);
             break;
         default:
             $this->clientError(_('API method not found.'), $code = 404);
             break;
     }
 }
Exemplo n.º 2
0
 /**
  * Show the timeline of notices
  *
  * @return void
  */
 function showTimeline()
 {
     // We'll use the shared params from the Atom stub
     // for other feed types.
     $atom = new AtomUserNoticeFeed($this->target->getUser(), $this->auth_user);
     $link = common_local_url('showstream', array('nickname' => $this->target->nickname));
     $self = $this->getSelfUri();
     // FriendFeed's SUP protocol
     // Also added RSS and Atom feeds
     $suplink = common_local_url('sup', null, null, $this->target->id);
     header('X-SUP-ID: ' . $suplink);
     // paging links
     $nextUrl = !empty($this->next_id) ? common_local_url('ApiTimelineUser', array('format' => $this->format, 'id' => $this->target->id), array('max_id' => $this->next_id)) : null;
     $prevExtra = array();
     if (!empty($this->notices)) {
         assert($this->notices[0] instanceof Notice);
         $prevExtra['since_id'] = $this->notices[0]->id;
     }
     $prevUrl = common_local_url('ApiTimelineUser', array('format' => $this->format, 'id' => $this->target->id), $prevExtra);
     $firstUrl = common_local_url('ApiTimelineUser', array('format' => $this->format, 'id' => $this->target->id));
     switch ($this->format) {
         case 'xml':
             $this->showXmlTimeline($this->notices);
             break;
         case 'rss':
             $this->showRssTimeline($this->notices, $atom->title, $link, $atom->subtitle, $suplink, $atom->logo, $self);
             break;
         case 'atom':
             header('Content-Type: application/atom+xml; charset=utf-8');
             $atom->setId($self);
             $atom->setSelfLink($self);
             // Add navigation links: next, prev, first
             // Note: we use IDs rather than pages for navigation; page boundaries
             // change too quickly!
             if (!empty($this->next_id)) {
                 $atom->addLink($nextUrl, array('rel' => 'next', 'type' => 'application/atom+xml'));
             }
             if (($this->page > 1 || !empty($this->max_id)) && !empty($this->notices)) {
                 $atom->addLink($prevUrl, array('rel' => 'prev', 'type' => 'application/atom+xml'));
             }
             if ($this->page > 1 || !empty($this->since_id) || !empty($this->max_id)) {
                 $atom->addLink($firstUrl, array('rel' => 'first', 'type' => 'application/atom+xml'));
             }
             $atom->addEntryFromNotices($this->notices);
             $this->raw($atom->getString());
             break;
         case 'json':
             $this->showJsonTimeline($this->notices);
             break;
         case 'as':
             header('Content-Type: ' . ActivityStreamJSONDocument::CONTENT_TYPE);
             $doc = new ActivityStreamJSONDocument($this->auth_user);
             $doc->setTitle($atom->title);
             $doc->addLink($link, 'alternate', 'text/html');
             $doc->addItemsFromNotices($this->notices);
             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;
         default:
             // TRANS: Client error displayed when coming across a non-supported API method.
             $this->clientError(_('API method not found.'), 404);
     }
 }
Exemplo n.º 3
0
 /**
  * Show the timeline of notices
  *
  * @return void
  */
 function showTimeline()
 {
     $profile = $this->user->getProfile();
     // We'll use the shared params from the Atom stub
     // for other feed types.
     $atom = new AtomUserNoticeFeed($this->user, $this->auth_user);
     $link = common_local_url('showstream', array('nickname' => $this->user->nickname));
     $self = $this->getSelfUri();
     // FriendFeed's SUP protocol
     // Also added RSS and Atom feeds
     $suplink = common_local_url('sup', null, null, $this->user->id);
     header('X-SUP-ID: ' . $suplink);
     switch ($this->format) {
         case 'xml':
             $this->showXmlTimeline($this->notices);
             break;
         case 'rss':
             $this->showRssTimeline($this->notices, $atom->title, $link, $atom->subtitle, $suplink, $atom->logo, $self);
             break;
         case 'atom':
             header('Content-Type: application/atom+xml; charset=utf-8');
             $atom->setId($self);
             $atom->setSelfLink($self);
             // Add navigation links: next, prev, first
             // Note: we use IDs rather than pages for navigation; page boundaries
             // change too quickly!
             if (!empty($this->next_id)) {
                 $nextUrl = common_local_url('ApiTimelineUser', array('format' => 'atom', 'id' => $this->user->id), array('max_id' => $this->next_id));
                 $atom->addLink($nextUrl, array('rel' => 'next', 'type' => 'application/atom+xml'));
             }
             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->user->id), array('since_id' => $lastId));
                 $atom->addLink($prevUrl, array('rel' => 'prev', 'type' => 'application/atom+xml'));
             }
             if ($this->page > 1 || !empty($this->since_id) || !empty($this->max_id)) {
                 $firstUrl = common_local_url('ApiTimelineUser', array('format' => 'atom', 'id' => $this->user->id));
                 $atom->addLink($firstUrl, array('rel' => 'first', 'type' => 'application/atom+xml'));
             }
             $atom->addEntryFromNotices($this->notices);
             $this->raw($atom->getString());
             break;
         case 'json':
             $this->showJsonTimeline($this->notices);
             break;
         case 'as':
             header('Content-Type: application/json; charset=utf-8');
             $doc = new ActivityStreamJSONDocument($this->auth_user);
             $doc->setTitle($atom->title);
             $doc->addLink($link, 'alternate', 'text/html');
             $doc->addItemsFromNotices($this->notices);
             // XXX: Add paging extension?
             $this->raw($doc->asString());
             break;
         default:
             // TRANS: Client error displayed when trying to handle an unknown API method.
             $this->clientError(_('API method not found.'), $code = 404);
             break;
     }
 }