http://www.mediawiki.org/wiki/Special:Code/MediaWiki/97303
Revision: 97303 Author: reedy Date: 2011-09-16 18:11:47 +0000 (Fri, 16 Sep 2011) Log Message: ----------- Give a list of modules to query and action into paraminfo Modified Paths: -------------- trunk/phase3/includes/api/ApiParamInfo.php trunk/phase3/includes/api/ApiQuery.php Modified: trunk/phase3/includes/api/ApiParamInfo.php =================================================================== --- trunk/phase3/includes/api/ApiParamInfo.php 2011-09-16 18:04:03 UTC (rev 97302) +++ trunk/phase3/includes/api/ApiParamInfo.php 2011-09-16 18:11:47 UTC (rev 97303) @@ -34,15 +34,21 @@ */ 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 @@ $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 @@ $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 @@ $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 @@ } 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, Modified: trunk/phase3/includes/api/ApiQuery.php =================================================================== --- trunk/phase3/includes/api/ApiQuery.php 2011-09-16 18:04:03 UTC (rev 97302) +++ trunk/phase3/includes/api/ApiQuery.php 2011-09-16 18:11:47 UTC (rev 97303) @@ -179,7 +179,7 @@ /** * 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 ); _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs