X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fxmloutputter.php;h=71d57e2d56647afad12e413dda029a912c6e19bc;hb=b22acbb42e2cefa4c3d94f192b735519b1182f07;hp=5f06e491df2c2182fef496be074d419efe5c987c;hpb=a08c76a4342cfb4b3d772f6880ba0b8f3153b246;p=quix0rs-gnu-social.git diff --git a/lib/xmloutputter.php b/lib/xmloutputter.php index 5f06e491df..71d57e2d56 100644 --- a/lib/xmloutputter.php +++ b/lib/xmloutputter.php @@ -67,10 +67,13 @@ class XMLOutputter * @param boolean $indent Whether to indent output, default true */ - function __construct($output='php://output', $indent=true) + function __construct($output='php://output', $indent=null) { $this->xw = new XMLWriter(); $this->xw->openURI($output); + if(is_null($indent)) { + $indent = common_config('site', 'indent'); + } $this->xw->setIndent($indent); } @@ -139,6 +142,15 @@ class XMLOutputter $this->elementEnd($tag); } + function elementNS(array $ns, $tag, $attrs=null, $content=null) + { + $this->elementStartNS($ns, $tag, $attrs); + if (!is_null($content)) { + $this->xw->text($content); + } + $this->elementEnd($tag); + } + /** * output a start tag for an element * @@ -166,6 +178,20 @@ class XMLOutputter } } + function elementStartNS(array $ns, $tag, $attrs=null) + { + reset($ns); // array pointer to 0 + $uri = key($ns); + $this->xw->startElementNS($ns[$uri], $tag, $uri); + if (is_array($attrs)) { + foreach ($attrs as $name => $value) { + $this->xw->writeAttribute($name, $value); + } + } else if (is_string($attrs)) { + $this->xw->writeAttribute('class', $attrs); + } + } + /** * output an end tag for an element * @@ -186,7 +212,7 @@ class XMLOutputter { static $empty_tag = array('base', 'meta', 'link', 'hr', 'br', 'param', 'img', 'area', - 'input', 'col'); + 'input', 'col', 'source'); // XXX: check namespace if (in_array($tag, $empty_tag)) { $this->xw->endElement(); @@ -239,4 +265,15 @@ class XMLOutputter { $this->xw->writeComment($txt); } + + /** + * Flush output buffers + * + * @return void + */ + + function flush() + { + $this->xw->flush(); + } }