From 478a95fb13bf67948a0652e27b714323944ce1d6 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Fri, 16 Sep 2011 18:11:47 +0000 Subject: [PATCH] Give a list of modules to query and action into paraminfo --- includes/api/ApiParamInfo.php | 21 +++++++++++++++------ includes/api/ApiQuery.php | 2 +- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/includes/api/ApiParamInfo.php b/includes/api/ApiParamInfo.php index 8e578c12e1..8ed75e7266 100644 --- a/includes/api/ApiParamInfo.php +++ b/includes/api/ApiParamInfo.php @@ -34,15 +34,21 @@ if ( !defined( 'MEDIAWIKI' ) ) { */ class ApiParamInfo extends ApiBase { + /** + * @var ApiQuery + */ + protected $queryObj; + public function __construct( $main, $action ) { parent::__construct( $main, $action ); + $this->queryObj = new ApiQuery( $this->getMain(), 'query' ); } public function execute() { // Get parameters $params = $this->extractRequestParams(); $result = $this->getResult(); - $queryObj = new ApiQuery( $this->getMain(), 'query' ); + $r = array(); if ( is_array( $params['modules'] ) ) { $modArr = $this->getMain()->getModules(); @@ -60,7 +66,7 @@ class ApiParamInfo extends ApiBase { $result->setIndexedTagName( $r['modules'], 'module' ); } if ( is_array( $params['querymodules'] ) ) { - $qmodArr = $queryObj->getModules(); + $qmodArr = $this->queryObj->getModules(); $r['querymodules'] = array(); foreach ( $params['querymodules'] as $qm ) { if ( !isset( $qmodArr[$qm] ) ) { @@ -70,7 +76,7 @@ class ApiParamInfo extends ApiBase { $obj = new $qmodArr[$qm]( $this, $qm ); $a = $this->getClassInfo( $obj ); $a['name'] = $qm; - $a['querytype'] = $queryObj->getModuleType( $qm ); + $a['querytype'] = $this->queryObj->getModuleType( $qm ); $r['querymodules'][] = $a; } $result->setIndexedTagName( $r['querymodules'], 'module' ); @@ -79,7 +85,7 @@ class ApiParamInfo extends ApiBase { $r['mainmodule'] = $this->getClassInfo( $this->getMain() ); } if ( $params['pagesetmodule'] ) { - $pageSet = new ApiPageSet( $queryObj ); + $pageSet = new ApiPageSet( $this->queryObj ); $r['pagesetmodule'] = $this->getClassInfo( $pageSet ); } $result->addValue( null, $this->getModuleName(), $r ); @@ -219,12 +225,15 @@ class ApiParamInfo extends ApiBase { } public function getAllowedParams() { + return array( 'modules' => array( - ApiBase::PARAM_ISMULTI => true + ApiBase::PARAM_ISMULTI => true, + ApiBase::PARAM_TYPE => array_keys( $this->getMain()->getModules() ), ), 'querymodules' => array( - ApiBase::PARAM_ISMULTI => true + ApiBase::PARAM_ISMULTI => true, + ApiBase::PARAM_TYPE => array_keys( $this->queryObj->getModules() ), ), 'mainmodule' => false, 'pagesetmodule' => false, diff --git a/includes/api/ApiQuery.php b/includes/api/ApiQuery.php index 5279db93db..ea71282f7a 100644 --- a/includes/api/ApiQuery.php +++ b/includes/api/ApiQuery.php @@ -179,7 +179,7 @@ class ApiQuery extends ApiBase { /** * Get the array mapping module names to class names - * @return array(modulename => classname) + * @return array (modulename => classname) */ function getModules() { return array_merge( $this->mQueryPropModules, $this->mQueryListModules, $this->mQueryMetaModules ); -- 2.20.1