diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2013-12-08 09:55:49 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2013-12-08 09:55:49 +0100 |
commit | 4ac9fa081a7c045f6a9f1cfc529d82423f485b2e (patch) | |
tree | af68743f2f4a47d13f2b0eb05f5c4aaf86d8ea37 /includes/api/ApiOpenSearch.php | |
parent | af4da56f1ad4d3ef7b06557bae365da2ea27a897 (diff) |
Update to MediaWiki 1.22.0
Diffstat (limited to 'includes/api/ApiOpenSearch.php')
-rw-r--r-- | includes/api/ApiOpenSearch.php | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/includes/api/ApiOpenSearch.php b/includes/api/ApiOpenSearch.php index caf361ac..315ace37 100644 --- a/includes/api/ApiOpenSearch.php +++ b/includes/api/ApiOpenSearch.php @@ -1,7 +1,5 @@ <?php /** - * - * * Created on Oct 13, 2006 * * Copyright © 2006 Yuri Astrakhan "<Firstname><Lastname>@gmail.com" @@ -29,8 +27,20 @@ */ class ApiOpenSearch extends ApiBase { + /** + * Override built-in handling of format parameter. + * Only JSON is supported. + * + * @return ApiFormatBase + */ public function getCustomPrinter() { - return $this->getMain()->createPrinterByName( 'json' ); + $params = $this->extractRequestParams(); + $format = $params['format']; + $allowed = array( 'json', 'jsonfm' ); + if ( in_array( $format, $allowed ) ) { + return $this->getMain()->createPrinterByName( $format ); + } + return $this->getMain()->createPrinterByName( $allowed[0] ); } public function execute() { @@ -94,6 +104,10 @@ class ApiOpenSearch extends ApiBase { ApiBase::PARAM_ISMULTI => true ), 'suggest' => false, + 'format' => array( + ApiBase::PARAM_DFLT => 'json', + ApiBase::PARAM_TYPE => array( 'json', 'jsonfm' ), + ) ); } @@ -103,6 +117,7 @@ class ApiOpenSearch extends ApiBase { 'limit' => 'Maximum amount of results to return', 'namespace' => 'Namespaces to search', 'suggest' => 'Do nothing if $wgEnableOpenSearchSuggest is false', + 'format' => 'The format of the output', ); } |