class ApiFormatXml extends ApiFormatBase {
private $mRootElemName = 'api';
+ private $mDoubleQuote = false;
public function __construct($main, $format) {
parent :: __construct($main, $format);
}
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);
}
switch (gettype($elemValue)) {
case 'array' :
-
if (isset ($elemValue['*'])) {
- $subElemContent = $elemValue['*'];
+ $subElemContent = $elemValue['*'];
+ if ($this->mDoubleQuote)
+ $subElemContent = $this->doubleQuote($subElemContent);
unset ($elemValue['*']);
} else {
$subElemContent = null;
$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]);
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();
}