]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/pocourl.php
Misses this file to merge. I like the comments.
[quix0rs-gnu-social.git] / lib / pocourl.php
index 803484d760bd3b93ef9c19b84e1bf767aac64781..e375f125a0a514ec612f2c71bc121af798e321df 100644 (file)
@@ -53,13 +53,38 @@ class PoCoURL
     function asString()
     {
         $xs = new XMLStringer(true);
-        $xs->elementStart('poco:urls');
-        $xs->element('poco:type', null, $this->type);
-        $xs->element('poco:value', null, $this->value);
+        $this->outputTo($xs);
+        return $xs->getString();
+    }
+
+    function outputTo($xo)
+    {
+        $xo->elementStart('poco:urls');
+        $xo->element('poco:type', null, $this->type);
+        $xo->element('poco:value', null, $this->value);
         if (!empty($this->primary)) {
-            $xs->element('poco:primary', null, 'true');
+            $xo->element('poco:primary', null, 'true');
         }
-        $xs->elementEnd('poco:urls');
-        return $xs->getString();
+        $xo->elementEnd('poco:urls');
+    }
+
+    /**
+     * Return this PoCo URL as an array suitable for serializing in JSON
+     *
+     * @array $url the url
+     */
+
+    function asArray()
+    {
+        $url = array();
+
+        $url['type']  = $this->type;
+        $url['value'] = $this->value;
+
+        if (!empty($this->primary)) {
+            $url['primary'] = 'true';
+        }
+
+        return $url;
     }
 }