summaryrefslogtreecommitdiff
path: root/includes/api/ApiFormatXml.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/api/ApiFormatXml.php')
-rw-r--r--includes/api/ApiFormatXml.php34
1 files changed, 29 insertions, 5 deletions
diff --git a/includes/api/ApiFormatXml.php b/includes/api/ApiFormatXml.php
index d39e8049..d35eb3e9 100644
--- a/includes/api/ApiFormatXml.php
+++ b/includes/api/ApiFormatXml.php
@@ -29,11 +29,12 @@ if (!defined('MEDIAWIKI')) {
}
/**
- * @addtogroup API
+ * @ingroup API
*/
class ApiFormatXml extends ApiFormatBase {
private $mRootElemName = 'api';
+ private $mDoubleQuote = false;
public function __construct($main, $format) {
parent :: __construct($main, $format);
@@ -46,12 +47,15 @@ class ApiFormatXml extends ApiFormatBase {
public function getNeedsRawData() {
return true;
}
-
+
public function setRootElement($rootElemName) {
$this->mRootElemName = $rootElemName;
}
public function execute() {
+ $params = $this->extractRequestParams();
+ $this->mDoubleQuote = $params['xmldoublequote'];
+
$this->printText('<?xml version="1.0" encoding="utf-8"?>');
$this->recXmlPrint($this->mRootElemName, $this->getResultData(), $this->getIsHtml() ? -2 : null);
}
@@ -79,9 +83,10 @@ class ApiFormatXml extends ApiFormatBase {
switch (gettype($elemValue)) {
case 'array' :
-
if (isset ($elemValue['*'])) {
$subElemContent = $elemValue['*'];
+ if ($this->mDoubleQuote)
+ $subElemContent = $this->doubleQuote($subElemContent);
unset ($elemValue['*']);
} else {
$subElemContent = null;
@@ -97,6 +102,9 @@ class ApiFormatXml extends ApiFormatBase {
$indElements = array ();
$subElements = array ();
foreach ($elemValue as $subElemId => & $subElemValue) {
+ if (is_string($subElemValue) && $this->mDoubleQuote)
+ $subElemValue = $this->doubleQuote($subElemValue);
+
if (gettype($subElemId) === 'integer') {
$indElements[] = $subElemValue;
unset ($elemValue[$subElemId]);
@@ -136,12 +144,28 @@ class ApiFormatXml extends ApiFormatBase {
break;
}
}
+ private function doubleQuote( $text ) {
+ return Sanitizer::encodeAttribute( $text );
+ }
+
+ public function getAllowedParams() {
+ return array (
+ 'xmldoublequote' => false
+ );
+ }
+
+ public function getParamDescription() {
+ return array (
+ 'xmldoublequote' => 'If specified, double quotes all attributes and content.',
+ );
+ }
+
+
public function getDescription() {
return 'Output data in XML format' . parent :: getDescription();
}
public function getVersion() {
- return __CLASS__ . ': $Id: ApiFormatXml.php 30222 2008-01-28 19:05:26Z catrope $';
+ return __CLASS__ . ': $Id: ApiFormatXml.php 37075 2008-07-04 22:44:57Z brion $';
}
}
-