From: Bryan Tong Minh Date: Mon, 3 Mar 2008 22:19:03 +0000 (+0000) Subject: (bug 11401) Added xmldoublequote to xml formatter X-Git-Tag: 1.31.0-rc.0~49262 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22articles%22%2C%22id_article=%24id_article%22%29%20.%20%22?a=commitdiff_plain;h=3e0efaef149a335e9628391fcf389c307a09adf5;p=lhc%2Fweb%2Fwiklou.git (bug 11401) Added xmldoublequote to xml formatter --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 86016dd3dd..0f192077a7 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -73,6 +73,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 13218) Fix inclusion of " character in hyperlinks * Added watch and unwatch parameters to action=delete and action=move * Added action=edit +* (bug 11401) Added xmldoublequote to xml formatter === Languages updated in 1.13 === diff --git a/includes/api/ApiFormatXml.php b/includes/api/ApiFormatXml.php index 165e2c371f..c910b24ff5 100644 --- a/includes/api/ApiFormatXml.php +++ b/includes/api/ApiFormatXml.php @@ -34,6 +34,7 @@ if (!defined('MEDIAWIKI')) { class ApiFormatXml extends ApiFormatBase { private $mRootElemName = 'api'; + private $mDoubleQuote = false; public function __construct($main, $format) { parent :: __construct($main, $format); @@ -52,6 +53,9 @@ class ApiFormatXml extends ApiFormatBase { } public function execute() { + $params = $this->extractRequestParams(); + $this->mDoubleQuote = $params['xmldoublequote']; + $this->printText(''); $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['*']; + $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,6 +144,23 @@ 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(); }