X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fpocourl.php;h=e375f125a0a514ec612f2c71bc121af798e321df;hb=edb467978d49e53da95e4d69ea9733395fed0aa3;hp=803484d760bd3b93ef9c19b84e1bf767aac64781;hpb=800b33590696e85480aa73c25261d80f1926e56d;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; } }