diff options
author | Lukas Reschke <lukas@owncloud.com> | 2015-11-30 17:40:10 +0300 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2015-12-14 11:40:07 +0300 |
commit | cccf4b607340f52cd0e9301c6e2813c121f2c236 (patch) | |
tree | 5f624fae04ecb953ad04f69178ae697d34f3f800 /ocs | |
parent | cd4cc15ac9d4fe36f532a7cc0d98b2d06c713bae (diff) |
Use XMLWriter to generate response
Gets rid of manual XML generation.
Diffstat (limited to 'ocs')
-rw-r--r-- | ocs/providers.php | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/ocs/providers.php b/ocs/providers.php index ce818a0cb6a..93035d098a5 100644 --- a/ocs/providers.php +++ b/ocs/providers.php @@ -29,20 +29,29 @@ header('Content-type: application/xml'); $url=OCP\Util::getServerProtocol().'://'.substr(OCP\Util::getServerHost().OCP\Util::getRequestUri(), 0, -17).'ocs/v1.php/'; -echo(' -<providers> -<provider> - <id>ownCloud</id> - <location>'.$url.'</location> - <name>ownCloud</name> - <icon></icon> - <termsofuse></termsofuse> - <register></register> - <services> - <config ocsversion="1.7" /> - <activity ocsversion="1.7" /> - <cloud ocsversion="1.7" /> - </services> -</provider> -</providers> -'); +$writer = new XMLWriter(); +$writer->openURI('php://output'); +$writer->startDocument('1.0','UTF-8'); +$writer->setIndent(4); +$writer->startElement('providers'); +$writer->startElement('provider'); +$writer->writeElement('id', 'ownCloud'); +$writer->writeElement('location', $url); +$writer->writeElement('name', 'ownCloud'); +$writer->writeElement('icon', ''); +$writer->writeElement('termsofuse', ''); +$writer->writeElement('register', ''); +$writer->startElement('services'); +$writer->startElement('config'); +$writer->writeAttribute('ocsversion', '1.7'); +$writer->endElement(); +$writer->startElement('activity'); +$writer->writeAttribute('ocsversion', '1.7'); +$writer->endElement(); +$writer->startElement('cloud'); +$writer->writeAttribute('ocsversion', '1.7'); +$writer->endElement(); +$writer->endElement(); +$writer->endElement(); +$writer->endDocument(); +$writer->flush(); |