Give a list of modules to query and action into paraminfo
authorSam Reed <reedy@users.mediawiki.org>
Fri, 16 Sep 2011 18:11:47 +0000 (18:11 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Fri, 16 Sep 2011 18:11:47 +0000 (18:11 +0000)
includes/api/ApiParamInfo.php
includes/api/ApiQuery.php

index 8e578c1..8ed75e7 100644 (file)
@@ -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,
index 5279db9..ea71282 100644 (file)
@@ -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 );