X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fpocourl.php;h=e375f125a0a514ec612f2c71bc121af798e321df;hb=b4271a3533bdf12329f27dd75452c1ef2a6ee3d1;hp=803484d760bd3b93ef9c19b84e1bf767aac64781;hpb=99454be38cf1dc7f962441d23ccc0a59e7b05f3d;p=quix0rs-gnu-social.git diff --git a/lib/pocourl.php b/lib/pocourl.php index 803484d760..e375f125a0 100644 --- a/lib/pocourl.php +++ b/lib/pocourl.php @@ -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; } }