summaryrefslogtreecommitdiff
path: root/includes/api/ApiOpenSearch.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/api/ApiOpenSearch.php')
-rw-r--r--includes/api/ApiOpenSearch.php21
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',
);
}