]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Bringing the presentation of boolean variables (favorited, truncated, profile_backgro...
authorDan Moore <dan@moore.cx>
Sat, 18 Apr 2009 19:33:36 +0000 (15:33 -0400)
committerDan Moore <dan@moore.cx>
Sat, 18 Apr 2009 19:33:36 +0000 (15:33 -0400)
Currently, laconica returns text strings enclosed in quotes instead of bare Javascript booleans.  This change fixes that.

See http://laconi.ca/trac/ticket/1326 for one open issue related to this.

actions/twitapifriendships.php
actions/twitapiusers.php
lib/twitterapi.php

index c50c5e84a9dcc948682e80d55c0a26641a726dd6..2f8250e0dc9dfa56b55893b436a15838c8a9b39a 100644 (file)
@@ -133,11 +133,7 @@ class TwitapifriendshipsAction extends TwitterapiAction
             return;
         }
 
-        if ($user_a->isSubscribed($user_b)) {
-            $result = 'true';
-        } else {
-            $result = 'false';
-        }
+        $result = $user_a->isSubscribed($user_b);
 
         switch ($apidata['content-type']) {
          case 'xml':
index 2894b7486dd31372fe63ca76ca41ed99821922b4..41d0d955b1e39d377c9b4988e6cd61945d228841 100644 (file)
@@ -83,7 +83,7 @@ class TwitapiusersAction extends TwitterapiAction
                $twitter_user['profile_link_color'] = '';
                $twitter_user['profile_sidebar_fill_color'] = '';
         $twitter_user['profile_sidebar_border_color'] = '';
-        $twitter_user['profile_background_tile'] = 'false';
+        $twitter_user['profile_background_tile'] = false;
 
                $faves = DB_DataObject::factory('fave');
                $faves->user_id = $user->id;
index 6a90b4e2885701d83c99cfe93d08ac0afdf48161..caf8c071639212a4ec8c7eb19dc37509fddd197e 100644 (file)
@@ -51,6 +51,26 @@ class TwitterapiAction extends Action
         parent::handle($args);
     }
 
+    /**
+     * Overrides XMLOutputter::element to write booleans as strings (true|false).
+     * See that method's documentation for more info.
+     * 
+     * @param string $tag     Element type or tagname
+     * @param array  $attrs   Array of element attributes, as
+     *                        key-value pairs
+     * @param string $content string content of the element
+     *
+     * @return void
+     */
+    function element($tag, $attrs=null, $content=null)
+    {
+        if (is_bool($content)) {
+            $content = ($content ? 'true' : 'false');
+        }
+
+        return parent::element($tag, $attrs, $content);
+    }
+    
     function twitter_user_array($profile, $get_notice=false)
     {
 
@@ -66,7 +86,7 @@ class TwitterapiAction extends Action
         $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE);
 
         $twitter_user['profile_image_url'] = ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_STREAM_SIZE);
-        $twitter_user['protected'] = 'false'; # not supported by Laconica yet
+        $twitter_user['protected'] = false; # not supported by Laconica yet
         $twitter_user['url'] = ($profile->homepage) ? $profile->homepage : null;
 
         if ($get_notice) {
@@ -86,7 +106,7 @@ class TwitterapiAction extends Action
 
         $twitter_status = array();
         $twitter_status['text'] = $notice->content;
-        $twitter_status['truncated'] = 'false'; # Not possible on Laconica
+        $twitter_status['truncated'] = false; # Not possible on Laconica
         $twitter_status['created_at'] = $this->date_twitter($notice->created);
         $twitter_status['in_reply_to_status_id'] = ($notice->reply_to) ?
             intval($notice->reply_to) : null;
@@ -108,10 +128,9 @@ class TwitterapiAction extends Action
             ($replier_profile) ? $replier_profile->nickname : null;
 
         if (isset($this->auth_user)) {
-            $twitter_status['favorited'] =
-                ($this->auth_user->hasFave($notice)) ? 'true' : 'false';
+            $twitter_status['favorited'] = $this->auth_user->hasFave($notice);
         } else {
-            $twitter_status['favorited'] = 'false';
+            $twitter_status['favorited'] = false;
         }
 
         if ($include_user) {