]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apitimelinefriends.php
Make page titles more consistent: no title case in four cases.
[quix0rs-gnu-social.git] / actions / apitimelinefriends.php
index 92a885293662ff1b2f382f85d3d5489d2934df52..ef58b103c5406b35e297c64193d5f32e055f8f3e 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 target user.
@@ -39,6 +45,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/
@@ -46,14 +58,7 @@ require_once INSTALLDIR.'/lib/apibareauth.php';
 
 class ApiTimelineFriendsAction extends ApiBareAuthAction
 {
-
-    var $user     = null;
     var $notices  = null;
-    var $count    = null;
-    var $max_id   = null;
-    var $since_id = null;
-    var $since    = null;
-    var $format   = null;
 
     /**
      * Take arguments for running
@@ -67,18 +72,11 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
     function prepare($args)
     {
         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->format   = $this->arg('format');
-
+        common_debug("api friends_timeline");
         $this->user = $this->getTargetUser($this->arg('id'));
 
         if (empty($this->user)) {
-            $this->clientError(_('No such user!'), 404, $this->format);
+            $this->clientError(_('No such user.'), 404, $this->format);
             return;
         }
 
@@ -112,24 +110,26 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
     function showTimeline()
     {
         $profile    = $this->user->getProfile();
+        $avatar     = $profile->getAvatar(AVATAR_PROFILE_SIZE);
         $sitename   = common_config('site', 'name');
         $title      = sprintf(_("%s and friends"), $this->user->nickname);
         $taguribase = common_config('integration', 'taguri');
         $id         = "tag:$taguribase:FriendsTimeline:" . $this->user->id;
         $link       = common_local_url(
-            'all', array('nickname' => $this->user->nickname)
-        );
+                                       'all', array('nickname' => $this->user->nickname)
+                                       );
         $subtitle   = sprintf(
-            _('Updates from %1$s and friends on %2$s!'),
-            $this->user->nickname, $sitename
-        );
+                              _('Updates from %1$s and friends on %2$s!'),
+                              $this->user->nickname, $sitename
+                              );
+        $logo       = ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
 
         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, $logo);
             break;
         case 'atom':
 
@@ -137,23 +137,23 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
 
             if (isset($target_id)) {
                 $selfuri = common_root_url() .
-                    'api/statuses/friends_timeline/' .
-                    $target_id . '.atom';
+                  'api/statuses/friends_timeline/' .
+                  $target_id . '.atom';
             } else {
                 $selfuri = common_root_url() .
-                    'api/statuses/friends_timeline.atom';
+                  'api/statuses/friends_timeline.atom';
             }
 
-            $this->show_atom_timeline(
-                $this->notices, $title, $id, $link,
-                $subtitle, null, $selfuri
-            );
+            $this->showAtomTimeline(
+                                    $this->notices, $title, $id, $link,
+                                    $subtitle, null, $selfuri, $logo
+                                    );
             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;
         }
     }
@@ -169,17 +169,13 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
         $notices = array();
 
         if (!empty($this->auth_user) && $this->auth_user->id == $this->user->id) {
-            $notice = $this->user->noticeInbox(
-                ($this->page-1) * $this->count,
-                $this->count, $this->since_id,
-                $this->max_id, $this->since
-            );
+            $notice = $this->user->ownFriendsTimeline(($this->page-1) * $this->count,
+                                                      $this->count, $this->since_id,
+                                                      $this->max_id, $this->since);
         } else {
-            $notice = $this->user->noticesWithFriends(
-                ($this->page-1) * $this->count,
-                $this->count, $this->since_id,
-                $this->max_id, $this->since
-            );
+            $notice = $this->user->friendsTimeline(($this->page-1) * $this->count,
+                                                   $this->count, $this->since_id,
+                                                   $this->max_id, $this->since);
         }
 
         while ($notice->fetch()) {
@@ -233,14 +229,14 @@ class ApiTimelineFriendsAction extends ApiBareAuthAction
             $last = count($this->notices) - 1;
 
             return '"' . implode(
-                ':',
-                array($this->arg('action'),
-                      common_language(),
-                      $this->user->id,
-                      strtotime($this->notices[0]->created),
-                      strtotime($this->notices[$last]->created))
-            )
-            . '"';
+                                 ':',
+                                 array($this->arg('action'),
+                                       common_language(),
+                                       $this->user->id,
+                                       strtotime($this->notices[0]->created),
+                                       strtotime($this->notices[$last]->created))
+                                 )
+              . '"';
         }
 
         return null;