[Pkg-owncloud-commits] [php-sabre-vobject] 137/341: Fix <geo /> when unserializing to xCal.

David Prévot taffit at moszumanska.debian.org
Tue Aug 11 13:35:41 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository php-sabre-vobject.

commit 59926fbb305f2598770f8cc8f41ae7b02c11ce94
Author: Ivan Enderlin <ivan.enderlin at hoa-project.net>
Date:   Fri Jan 16 09:53:52 2015 +0100

    Fix <geo /> when unserializing to xCal.
---
 lib/Property/Float.php | 65 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 63 insertions(+), 2 deletions(-)

diff --git a/lib/Property/Float.php b/lib/Property/Float.php
index 1aae79e..bc7979a 100644
--- a/lib/Property/Float.php
+++ b/lib/Property/Float.php
@@ -73,7 +73,7 @@ class Float extends Property {
     }
 
     /**
-     * Returns the value, in the format it should be encoded for json.
+     * Returns the value, in the format it should be encoded for JSON.
      *
      * This method must always return an array.
      *
@@ -87,9 +87,10 @@ class Float extends Property {
         //
         // See:
         // http://tools.ietf.org/html/draft-ietf-jcardcal-jcal-04#section-3.4.1.2
-        if ($this->name==='GEO') {
+        if ($this->name === 'GEO') {
             return [$val];
         }
+
         return $val;
 
     }
@@ -109,4 +110,64 @@ class Float extends Property {
 
     }
 
+    /**
+     * Returns the value, in the format it should be encoded for XML.
+     *
+     * This method must always return an array.
+     *
+     * @return array
+     */
+    public function getXmlValue() {
+
+        $val = array_map('floatval', $this->getParts());
+
+        // Special-casing the GEO property.
+        //
+        // See:
+        // http://tools.ietf.org/html/rfc6321#section-3.4.1.2
+        if ($this->name === 'GEO') {
+            return [
+                [
+                    [
+                        'name' => 'latitude',
+                        'value' => $val[0]
+                    ],
+                    [
+                        'name' => 'longitude',
+                        'value' => $val[1]
+                    ]
+                ]
+            ];
+        }
+
+        return $val;
+
+    }
+
+    /**
+     * This method returns an array, with the representation as it should be
+     * encoded in XML. This is used to create xCard or xCal documents.
+     *
+     * @return array
+     */
+    function xmlSerialize() {
+
+        $serialization = parent::xmlSerialize();
+
+        // Special-casing the GEO property.
+        //
+        // See:
+        // http://tools.ietf.org/html/rfc6321#section-3.4.1.2
+        if ($this->name === 'GEO') {
+
+            $handle = $serialization['value'][0]['value'];
+            $serialization['value'] = $handle;
+            return $serialization;
+
+        }
+
+        return $serialization;
+
+    }
+
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabre-vobject.git



More information about the Pkg-owncloud-commits mailing list