http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88766
Revision: 88766
Author: brion
Date: 2011-05-24 23:29:03 +0000 (Tue, 24 May 2011)
Log Message:
-----------
* (bug 18003) Fix API doc help for action=opensearch with OpenSearchXml
extension
Now adds the full description of the parameter and accepted values instead of
just sticking it in with no validation or description.
Unfortunately still can't just fetch the param as normal, as something in
ApiBase is overriding the default selection and ends up 'xmlfm' instead of
'json' that way. Very annoying!
This should do for now.
Modified Paths:
--------------
trunk/extensions/OpenSearchXml/ApiOpenSearchXml.php
Modified: trunk/extensions/OpenSearchXml/ApiOpenSearchXml.php
===================================================================
--- trunk/extensions/OpenSearchXml/ApiOpenSearchXml.php 2011-05-24 23:12:34 UTC
(rev 88765)
+++ trunk/extensions/OpenSearchXml/ApiOpenSearchXml.php 2011-05-24 23:29:03 UTC
(rev 88766)
@@ -43,6 +43,9 @@
}
protected function validateFormat() {
+ // We can't use $this->getMan()->getParameter('format') as this
+ // seems to override our specified limits and defaults, picking
+ // 'xmlfm' instead of 'json' as default.
$params = $this->extractRequestParams();
$format = $params['format'];
$allowed = array( 'json', 'jsonfm', 'xml', 'xmlfm' );
@@ -84,12 +87,27 @@
$result->addValue( null, 'Section', $items );
}
+
public function getAllowedParams() {
$params = parent::getAllowedParams();
- $params['format'] = null;
+ $params['format'] = array(
+ ApiBase::PARAM_DFLT => 'json',
+ ApiBase::PARAM_TYPE => array(
+ 'json',
+ 'jsonfm',
+ 'xml',
+ 'xmlfm'
+ )
+ );
return $params;
}
+ public function getParamDescription() {
+ return parent::getParamDescription() + array(
+ 'format' => 'Output format defaults to JSON, with
expanded XML optional.',
+ );
+ }
+
protected function formatItem( $name ) {
$title = Title::newFromText( $name );
if( $title ) {
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs