]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Use outputTo() instead of asString() for including sub-elements
authorEvan Prodromou <evan@status.net>
Mon, 27 Dec 2010 17:46:25 +0000 (09:46 -0800)
committerEvan Prodromou <evan@status.net>
Mon, 27 Dec 2010 17:46:25 +0000 (09:46 -0800)
lib/activity.php
lib/activityobject.php
lib/atomcategory.php
lib/poco.php
lib/pocoaddress.php
lib/pocourl.php

index 85d3efa21aeb888aaa7a3b77188b7238a5816286..8d7ae1540b7b23b06daba33d30ff580a13227235 100644 (file)
@@ -440,7 +440,7 @@ class Activity
         }
 
         foreach ($this->categories as $cat) {
-            $xs->raw($cat->asString());
+            $cat->outputTo($xs);
         }
 
         // can be either URLs or enclosure objects
index 3df35f84b082dc7bf747d9f17004787053bbbacf..b5e6013b4b383cbca09013837c4027c054cd000f 100644 (file)
@@ -570,7 +570,7 @@ class ActivityObject
         }
 
         if (!empty($this->poco)) {
-            $xo->raw($this->poco->asString());
+            $this->poco->outputTo($xo);
         }
 
         foreach ($this->extra as $el) {
index 9763023f7589c151ed4e24c2cea51fa93f7e951b..e527877cb090347bdf064222369756dcaede3346 100644 (file)
@@ -59,6 +59,13 @@ class AtomCategory
     }
 
     function asString()
+    {
+        $xs = new XMLStringer();
+        $this->outputTo($xs);
+        return $xs->getString();
+    }
+
+    function outputTo($xo)
     {
         $attribs = array();
         if ($this->term !== null) {
@@ -70,8 +77,6 @@ class AtomCategory
         if ($this->label !== null) {
             $attribs['label'] = $this->label;
         }
-        $xs = new XMLStringer();
-        $xs->element('category', $attribs);
-        return $xs->getString();
+        $xo->element('category', $attribs);
     }
 }
index 2157062b3798202b9c6a3da5b5b636a890ab515e..d7b082163ee21eb4199be57d17463f49f21f7fc5 100644 (file)
@@ -211,30 +211,34 @@ class PoCo
     function asString()
     {
         $xs = new XMLStringer(true);
-        $xs->element(
+        $this->outputTo($xs);
+        return $xs->getString();
+    }
+
+    function outputTo($xo)
+    {
+        $xo->element(
             'poco:preferredUsername',
             null,
             $this->preferredUsername
         );
 
-        $xs->element(
+        $xo->element(
             'poco:displayName',
             null,
             $this->displayName
         );
 
         if (!empty($this->note)) {
-            $xs->element('poco:note', null, common_xml_safe_str($this->note));
+            $xo->element('poco:note', null, common_xml_safe_str($this->note));
         }
 
         if (!empty($this->address)) {
-            $xs->raw($this->address->asString());
+            $this->address->outputTo($xo);
         }
 
         foreach ($this->urls as $url) {
-            $xs->raw($url->asString());
+            $url->outputTo($xo);
         }
-
-        return $xs->getString();
     }
 }
index 60873bdc42cd6f7e56c84d415004ea02f2131895..d9f6ff2bdefa8ea988cbb6200a30c2ffa71bd0f7 100644 (file)
@@ -42,15 +42,18 @@ class PoCoAddress
     // @todo Other address fields
 
     function asString()
+    {
+        $xs = new XMLStringer(true);
+        $this->outputTo($xs);
+        return $xs->getString();
+    }
+
+    function outputTo($xo)
     {
         if (!empty($this->formatted)) {
-            $xs = new XMLStringer(true);
-            $xs->elementStart('poco:address');
-            $xs->element('poco:formatted', null, common_xml_safe_str($this->formatted));
-            $xs->elementEnd('poco:address');
-            return $xs->getString();
+            $xo->elementStart('poco:address');
+            $xo->element('poco:formatted', null, common_xml_safe_str($this->formatted));
+            $xo->elementEnd('poco:address');
         }
-
-        return null;
     }
 }
index 803484d760bd3b93ef9c19b84e1bf767aac64781..786793b280d67e2ec53735eb4a1fb4bc8effcff6 100644 (file)
@@ -53,13 +53,18 @@ 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');
     }
 }