]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/api.php
Revert "Remove more contractions"
[quix0rs-gnu-social.git] / lib / api.php
index db2d24fbd5adfbf918100c8ffb8b7b665499e6f9..a1236ab7ec7176e146070edf2407bd60ef64dc67 100644 (file)
  *
  * @category  API
  * @package   StatusNet
+ * @author    Craig Andrews <candrews@integralblue.com>
+ * @author    Dan Moore <dan@moore.cx>
+ * @author    Evan Prodromou <evan@status.net>
+ * @author    Jeffery To <jeffery.to@gmail.com>
+ * @author    Toby Inkster <mail@tobyinkster.co.uk>
  * @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
@@ -36,6 +41,11 @@ if (!defined('STATUSNET')) {
  *
  * @category API
  * @package  StatusNet
+ * @author   Craig Andrews <candrews@integralblue.com>
+ * @author   Dan Moore <dan@moore.cx>
+ * @author   Evan Prodromou <evan@status.net>
+ * @author   Jeffery To <jeffery.to@gmail.com>
+ * @author   Toby Inkster <mail@tobyinkster.co.uk>
  * @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/
@@ -124,11 +134,28 @@ class ApiAction extends Action
         $twitter_user['protected'] = false; # not supported by StatusNet yet
         $twitter_user['followers_count'] = $profile->subscriberCount();
 
-        // To be supported soon...
-        $twitter_user['profile_background_color'] = '';
-        $twitter_user['profile_text_color'] = '';
-        $twitter_user['profile_link_color'] = '';
-        $twitter_user['profile_sidebar_fill_color'] = '';
+        $defaultDesign = Design::siteDesign();
+        $design        = null;
+        $user          = $profile->getUser();
+
+        // Note: some profiles don't have an associated user
+
+        if (!empty($user)) {
+            $design = $user->getDesign();
+        }
+
+        if (empty($design)) {
+            $design = $defaultDesign;
+        }
+
+        $color = Design::toWebColor(empty($design->backgroundcolor) ? $defaultDesign->backgroundcolor : $design->backgroundcolor);
+        $twitter_user['profile_background_color'] = ($color == null) ? '' : '#'.$color->hexValue();
+        $color = Design::toWebColor(empty($design->textcolor) ? $defaultDesign->textcolor : $design->textcolor);
+        $twitter_user['profile_text_color'] = ($color == null) ? '' : '#'.$color->hexValue();
+        $color = Design::toWebColor(empty($design->linkcolor) ? $defaultDesign->linkcolor : $design->linkcolor);
+        $twitter_user['profile_link_color'] = ($color == null) ? '' : '#'.$color->hexValue();
+        $color = Design::toWebColor(empty($design->sidebarcolor) ? $defaultDesign->sidebarcolor : $design->sidebarcolor);
+        $twitter_user['profile_sidebar_fill_color'] = ($color == null) ? '' : '#'.$color->hexValue();
         $twitter_user['profile_sidebar_border_color'] = '';
 
         $twitter_user['friends_count'] = $profile->subscriptionCount();
@@ -137,8 +164,6 @@ class ApiAction extends Action
 
         $twitter_user['favourites_count'] = $profile->faveCount(); // British spelling!
 
-        // Need to pull up the user for some of this
-        $user = User::staticGet($profile->id);
 
         $timezone = 'UTC';