]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apitimelineuser.php
Merge commit 'origin/0.9.x' into 0.9.x
[quix0rs-gnu-social.git] / actions / apitimelineuser.php
index d50648d7c9098125b179b0aecf29a383e0172455..2d0047c0464f8723d75d418a7c318fa11c880331 100644 (file)
  *
  * @category  API
  * @package   StatusNet
+ * @author    Craig Andrews <candrews@integralblue.com>
+ * @author    Evan Prodromou <evan@status.net>
+ * @author    Jeffery To <jeffery.to@gmail.com>
+ * @author    mac65 <mac65@mac65.com>
+ * @author    Mike Cochrane <mikec@mikenz.geek.nz>
+ * @author    Robin Millette <robin@millette.info>
  * @author    Zach Copley <zach@status.net>
  * @copyright 2009 StatusNet, Inc.
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
@@ -31,7 +37,7 @@ if (!defined('STATUSNET')) {
     exit(1);
 }
 
-require_once INSTALLDIR.'/lib/apibareauth.php';
+require_once INSTALLDIR . '/lib/apibareauth.php';
 
 /**
  * Returns the most recent notices (default 20) posted by the authenticating
@@ -40,6 +46,12 @@ require_once INSTALLDIR.'/lib/apibareauth.php';
  *
  * @category API
  * @package  StatusNet
+ * @author   Craig Andrews <candrews@integralblue.com>
+ * @author   Evan Prodromou <evan@status.net>
+ * @author   Jeffery To <jeffery.to@gmail.com>
+ * @author   mac65 <mac65@mac65.com>
+ * @author   Mike Cochrane <mikec@mikenz.geek.nz>
+ * @author   Robin Millette <robin@millette.info>
  * @author   Zach Copley <zach@status.net>
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
  * @link     http://status.net/
@@ -48,7 +60,6 @@ require_once INSTALLDIR.'/lib/apibareauth.php';
 class ApiTimelineUserAction extends ApiBareAuthAction
 {
 
-    var $user    = null;
     var $notices = null;
 
     /**
@@ -64,16 +75,10 @@ class ApiTimelineUserAction extends ApiBareAuthAction
     {
         parent::prepare($args);
 
-        $this->page     = (int)$this->arg('page', 1);
-        $this->count    = (int)$this->arg('count', 20);
-        $this->max_id   = (int)$this->arg('max_id', 0);
-        $this->since_id = (int)$this->arg('since_id', 0);
-        $this->since    = $this->arg('since');
-
         $this->user = $this->getTargetUser($this->arg('id'));
 
         if (empty($this->user)) {
-            $this->clientError(_('No such user!'), 404, $this->arg('format'));
+            $this->clientError(_('No such user.'), 404, $this->format);
             return;
         }
 
@@ -108,18 +113,16 @@ class ApiTimelineUserAction extends ApiBareAuthAction
     {
         $profile = $this->user->getProfile();
 
-        $sitename   = common_config('site', 'name');
-        $title      = sprintf(_("%s timeline"), $this->user->nickname);
-        $taguribase = common_config('integration', 'taguri');
-        $id         = "tag:$taguribase:UserTimeline:" . $this->user->id;
+        // We'll use the shared params from the Atom stub
+        // for other feed types.
+        $atom = new AtomUserNoticeFeed($this->user);
+        $title      = $atom->title;
         $link       = common_local_url(
             'showstream',
             array('nickname' => $this->user->nickname)
         );
-        $subtitle   = sprintf(
-            _('Updates from %1$s on %2$s!'),
-            $this->user->nickname, $sitename
-        );
+        $subtitle = $atom->subtitle;
+        $logo = $atom->logo;
 
         // FriendFeed's SUP protocol
         // Also added RSS and Atom feeds
@@ -127,35 +130,39 @@ class ApiTimelineUserAction extends ApiBareAuthAction
         $suplink = common_local_url('sup', null, null, $this->user->id);
         header('X-SUP-ID: ' . $suplink);
 
-        switch($this->arg('format')) {
+        switch($this->format) {
         case 'xml':
-            $this->show_xml_timeline($this->notices);
+            $this->showXmlTimeline($this->notices);
             break;
         case 'rss':
-            $this->show_rss_timeline(
+            $this->showRssTimeline(
                 $this->notices, $title, $link,
-                $subtitle, $suplink
+                $subtitle, $suplink, $logo
             );
             break;
         case 'atom':
-            if (isset($apidata['api_arg'])) {
-                $selfuri = common_root_url() .
-                    'api/statuses/user_timeline/' .
-                    $apidata['api_arg'] . '.atom';
-            } else {
-                $selfuri = common_root_url() .
-                    'api/statuses/user_timeline.atom';
+
+            header('Content-Type: application/atom+xml; charset=utf-8');
+
+            $id = $this->arg('id');
+            $aargs = array('format' => 'atom');
+            if (!empty($id)) {
+                $aargs['id'] = $id;
             }
-            $this->show_atom_timeline(
-                $this->notices, $title, $id, $link,
-                $subtitle, $suplink, $selfuri
-            );
+            $self = $this->getSelfUri('ApiTimelineUser', $aargs);
+            $atom->setId($self);
+            $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;
         }
 
@@ -173,7 +180,7 @@ class ApiTimelineUserAction extends ApiBareAuthAction
 
         $notice = $this->user->getNotices(
             ($this->page-1) * $this->count, $this->count,
-            $this->since_id, $this->max_id, $this->since
+            $this->since_id, $this->max_id
         );
 
         while ($notice->fetch()) {