From 324e642c2c843157d9be4d553827a3882a7977e8 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Fri, 16 Sep 2011 18:25:02 +0000 Subject: [PATCH] Add handling of format modules to ApiParamInfo --- includes/api/ApiParamInfo.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/includes/api/ApiParamInfo.php b/includes/api/ApiParamInfo.php index 8ed75e7266..3ad14ab806 100644 --- a/includes/api/ApiParamInfo.php +++ b/includes/api/ApiParamInfo.php @@ -88,6 +88,21 @@ class ApiParamInfo extends ApiBase { $pageSet = new ApiPageSet( $this->queryObj ); $r['pagesetmodule'] = $this->getClassInfo( $pageSet ); } + if ( is_array( $params['formatmodules'] ) ) { + $formats = $this->getMain()->getFormats(); + $r['formatmodules'] = array(); + foreach ( $params['formatmodules'] as $f ) { + if ( !isset( $formats[$f] ) ) { + $r['formatmodules'][] = array( 'name' => $f, 'missing' => '' ); + continue; + } + $obj = new $formats[$f]( $this, $f ); + $a = $this->getClassInfo( $obj ); + $a['name'] = $f; + $r['formatmodules'][] = $a; + } + $result->setIndexedTagName( $r['formatmodules'], 'module' ); + } $result->addValue( null, $this->getModuleName(), $r ); } @@ -237,6 +252,10 @@ class ApiParamInfo extends ApiBase { ), 'mainmodule' => false, 'pagesetmodule' => false, + 'formatmodules' => array( + ApiBase::PARAM_ISMULTI => true, + ApiBase::PARAM_TYPE => array_keys( $this->getMain()->getFormats() ), + ) ); } @@ -246,6 +265,7 @@ class ApiParamInfo extends ApiBase { 'querymodules' => 'List of query module names (value of prop=, meta= or list= parameter)', 'mainmodule' => 'Get information about the main (top-level) module as well', 'pagesetmodule' => 'Get information about the pageset module (providing titles= and friends) as well', + 'formatmodules' => 'List of format module names (value of format= parameter)', ); } -- 2.20.1