API: Changing all modules' getParamDescription(), getAllowedParams() and getDescripti...
authorRoan Kattouw <catrope@users.mediawiki.org>
Mon, 28 Jan 2008 19:05:26 +0000 (19:05 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Mon, 28 Jan 2008 19:05:26 +0000 (19:05 +0000)
53 files changed:
includes/api/ApiBlock.php
includes/api/ApiChangeRights.php
includes/api/ApiDelete.php
includes/api/ApiExpandTemplates.php
includes/api/ApiFeedWatchlist.php
includes/api/ApiFormatBase.php
includes/api/ApiFormatDbg.php
includes/api/ApiFormatJson.php
includes/api/ApiFormatPhp.php
includes/api/ApiFormatTxt.php
includes/api/ApiFormatWddx.php
includes/api/ApiFormatXml.php
includes/api/ApiFormatYaml.php
includes/api/ApiHelp.php
includes/api/ApiLogin.php
includes/api/ApiLogout.php
includes/api/ApiMain.php
includes/api/ApiMove.php
includes/api/ApiOpenSearch.php
includes/api/ApiParamInfo.php
includes/api/ApiParse.php
includes/api/ApiProtect.php
includes/api/ApiQuery.php
includes/api/ApiQueryAllCategories.php
includes/api/ApiQueryAllLinks.php
includes/api/ApiQueryAllUsers.php
includes/api/ApiQueryAllmessages.php
includes/api/ApiQueryAllpages.php
includes/api/ApiQueryBacklinks.php
includes/api/ApiQueryBlocks.php
includes/api/ApiQueryCategories.php
includes/api/ApiQueryCategoryMembers.php
includes/api/ApiQueryDeletedrevs.php
includes/api/ApiQueryExtLinksUsage.php
includes/api/ApiQueryExternalLinks.php
includes/api/ApiQueryImageInfo.php
includes/api/ApiQueryImages.php
includes/api/ApiQueryInfo.php
includes/api/ApiQueryLangLinks.php
includes/api/ApiQueryLinks.php
includes/api/ApiQueryLogEvents.php
includes/api/ApiQueryRandom.php
includes/api/ApiQueryRecentChanges.php
includes/api/ApiQueryRevisions.php
includes/api/ApiQuerySearch.php
includes/api/ApiQuerySiteinfo.php
includes/api/ApiQueryUserContributions.php
includes/api/ApiQueryUserInfo.php
includes/api/ApiQueryUsers.php
includes/api/ApiQueryWatchlist.php
includes/api/ApiRollback.php
includes/api/ApiUnblock.php
includes/api/ApiUndelete.php

index 43103d0..5d6b161 100644 (file)
@@ -115,7 +115,7 @@ class ApiBlock extends ApiBase {
 
        public function mustBePosted() { return true; }
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'user' => null,
                        'token' => null,
@@ -130,7 +130,7 @@ class ApiBlock extends ApiBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'user' => 'Username, IP address or IP range you want to block',
                        'token' => 'A block token previously obtained through the gettoken parameter',
@@ -145,7 +145,7 @@ class ApiBlock extends ApiBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return array(
                        'Block a user.'
                );
index f51bc04..647a519 100644 (file)
@@ -108,7 +108,7 @@ class ApiChangeRights extends ApiBase {
                $this->getResult()->addValue(null, $this->getModuleName(), $res);
        }
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'user' => null,
                        'token' => null,
@@ -124,7 +124,7 @@ class ApiChangeRights extends ApiBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'user' => 'The user you want to add to or remove from groups.',
                        'token' => 'A changerights token previously obtained through the gettoken parameter.',
@@ -136,7 +136,7 @@ class ApiChangeRights extends ApiBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return array(
                        'Add or remove a user from certain groups.'
                );
index 1ae5876..a80a43a 100644 (file)
@@ -120,7 +120,7 @@ class ApiDelete extends ApiBase {
        
        public function mustBePosted() { return true; }
        
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'title' => null,
                        'token' => null,
@@ -128,7 +128,7 @@ class ApiDelete extends ApiBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'title' => 'Title of the page you want to delete.',
                        'token' => 'A delete token previously retrieved through prop=info',
@@ -136,7 +136,7 @@ class ApiDelete extends ApiBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return array(
                        'Deletes a page. You need to be logged in as a sysop to use this function, see also action=login.'
                );
index 9d8a7af..6d83810 100644 (file)
@@ -64,7 +64,7 @@ class ApiExpandTemplates extends ApiBase {
                $result->addValue( null, $this->getModuleName(), $retval_array );
        }
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'title' => array( 
                                ApiBase :: PARAM_DFLT => 'API',
@@ -73,14 +73,14 @@ class ApiExpandTemplates extends ApiBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'text' => 'Wikitext to convert',
                        'title' => 'Title of page',
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return 'This module expand all templates in wikitext';
        }
 
index 8c7bf81..96a5a8a 100644 (file)
@@ -138,7 +138,7 @@ class ApiFeedWatchlist extends ApiBase {
                return new FeedItem($titleStr, $completeText, $titleUrl, $timestamp, $user);
        }
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                global $wgFeedClasses;
                $feedFormatNames = array_keys($wgFeedClasses);
                return array (
@@ -156,7 +156,7 @@ class ApiFeedWatchlist extends ApiBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'feedformat' => 'The format of the feed',
                        'hours'      => 'List pages modified within this many hours from now',
@@ -164,7 +164,7 @@ class ApiFeedWatchlist extends ApiBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return 'This module returns a watchlist feed';
        }
 
index 78b3198..4bc06e2 100644 (file)
@@ -215,7 +215,7 @@ See <a href='http://www.mediawiki.org/wiki/API'>complete documentation</a>, or
                return 'api.php?action=query&meta=siteinfo&siprop=namespaces&format=' . $this->getModuleName();
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return $this->getIsHtml() ? ' (pretty-print in HTML)' : '';
        }
 
index e4bfbdb..f0fc5e9 100644 (file)
@@ -1,59 +1,59 @@
-<?php\r
-\r
-/*\r
- * Created on Oct 22, 2006\r
- *\r
- * API for MediaWiki 1.8+\r
- *\r
- * Copyright (C) 2008 Roan Kattouw <Firstname>.<Lastname>@home.nl\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License along\r
- * with this program; if not, write to the Free Software Foundation, Inc.,\r
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\r
- * http://www.gnu.org/copyleft/gpl.html\r
- */\r
-\r
-if (!defined('MEDIAWIKI')) {\r
-       // Eclipse helper - will be ignored in production\r
-       require_once ('ApiFormatBase.php');\r
-}\r
-\r
-/**\r
- * @addtogroup API\r
- */\r
-class ApiFormatDbg extends ApiFormatBase {\r
-\r
-       public function __construct($main, $format) {\r
-               parent :: __construct($main, $format);\r
-       }\r
-\r
-       public function getMimeType() {\r
-               # This looks like it should be text/plain, but IE7 is so\r
-               # brain-damaged it tries to parse text/plain as HTML if it\r
-               # contains HTML tags. Using MIME text/text works around this bug\r
-               return 'text/text';\r
-       }\r
-\r
-       public function execute() {\r
-               $this->printText(var_export($this->getResultData(), true));\r
-       }\r
-\r
-       protected function getDescription() {\r
-               return 'Output data in PHP\'s var_export() format' . parent :: getDescription();\r
-       }\r
-\r
-       public function getVersion() {\r
-               return __CLASS__ . ': $Id: ApiFormatPhp.php 23531 2007-06-29 01:19:14Z simetrical $';\r
-       }\r
-}\r
-\r
+<?php
+
+/*
+ * Created on Oct 22, 2006
+ *
+ * API for MediaWiki 1.8+
+ *
+ * Copyright (C) 2008 Roan Kattouw <Firstname>.<Lastname>@home.nl
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+if (!defined('MEDIAWIKI')) {
+       // Eclipse helper - will be ignored in production
+       require_once ('ApiFormatBase.php');
+}
+
+/**
+ * @addtogroup API
+ */
+class ApiFormatDbg extends ApiFormatBase {
+
+       public function __construct($main, $format) {
+               parent :: __construct($main, $format);
+       }
+
+       public function getMimeType() {
+               # This looks like it should be text/plain, but IE7 is so
+               # brain-damaged it tries to parse text/plain as HTML if it
+               # contains HTML tags. Using MIME text/text works around this bug
+               return 'text/text';
+       }
+
+       public function execute() {
+               $this->printText(var_export($this->getResultData(), true));
+       }
+
+       public function getDescription() {
+               return 'Output data in PHP\'s var_export() format' . parent :: getDescription();
+       }
+
+       public function getVersion() {
+               return __CLASS__ . ': $Id: ApiFormatPhp.php 23531 2007-06-29 01:19:14Z simetrical $';
+       }
+}
+
index 23fbb1e..eae68fb 100644 (file)
@@ -66,19 +66,19 @@ class ApiFormatJson extends ApiFormatBase {
                }
        }
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'callback' => null
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'callback' => 'If specified, wraps the output into a given function call',
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                if ($this->mIsRaw)
                        return 'Output data with the debuging elements in JSON format' . parent :: getDescription();
                else
index 043cab5..c4f36e1 100644 (file)
@@ -45,7 +45,7 @@ class ApiFormatPhp extends ApiFormatBase {
                $this->printText(serialize($this->getResultData()));
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return 'Output data in serialized PHP format' . parent :: getDescription();
        }
 
index 38d1364..c4c45f6 100644 (file)
@@ -1,59 +1,59 @@
-<?php\r
-\r
-/*\r
- * Created on Oct 22, 2006\r
- *\r
- * API for MediaWiki 1.8+\r
- *\r
- * Copyright (C) 2008 Roan Kattouw <Firstname>.<Lastname>@home.nl\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License along\r
- * with this program; if not, write to the Free Software Foundation, Inc.,\r
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\r
- * http://www.gnu.org/copyleft/gpl.html\r
- */\r
-\r
-if (!defined('MEDIAWIKI')) {\r
-       // Eclipse helper - will be ignored in production\r
-       require_once ('ApiFormatBase.php');\r
-}\r
-\r
-/**\r
- * @addtogroup API\r
- */\r
-class ApiFormatTxt extends ApiFormatBase {\r
-\r
-       public function __construct($main, $format) {\r
-               parent :: __construct($main, $format);\r
-       }\r
-\r
-       public function getMimeType() {\r
-               # This looks like it should be text/plain, but IE7 is so\r
-               # brain-damaged it tries to parse text/plain as HTML if it\r
-               # contains HTML tags. Using MIME text/text works around this bug\r
-               return 'text/text';\r
-       }\r
-\r
-       public function execute() {\r
-               $this->printText(print_r($this->getResultData(), true));\r
-       }\r
-\r
-       protected function getDescription() {\r
-               return 'Output data in PHP\'s print_r() format' . parent :: getDescription();\r
-       }\r
-\r
-       public function getVersion() {\r
-               return __CLASS__ . ': $Id: ApiFormatPhp.php 23531 2007-06-29 01:19:14Z simetrical $';\r
-       }\r
-}\r
-\r
+<?php
+
+/*
+ * Created on Oct 22, 2006
+ *
+ * API for MediaWiki 1.8+
+ *
+ * Copyright (C) 2008 Roan Kattouw <Firstname>.<Lastname>@home.nl
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+if (!defined('MEDIAWIKI')) {
+       // Eclipse helper - will be ignored in production
+       require_once ('ApiFormatBase.php');
+}
+
+/**
+ * @addtogroup API
+ */
+class ApiFormatTxt extends ApiFormatBase {
+
+       public function __construct($main, $format) {
+               parent :: __construct($main, $format);
+       }
+
+       public function getMimeType() {
+               # This looks like it should be text/plain, but IE7 is so
+               # brain-damaged it tries to parse text/plain as HTML if it
+               # contains HTML tags. Using MIME text/text works around this bug
+               return 'text/text';
+       }
+
+       public function execute() {
+               $this->printText(print_r($this->getResultData(), true));
+       }
+
+       public function getDescription() {
+               return 'Output data in PHP\'s print_r() format' . parent :: getDescription();
+       }
+
+       public function getVersion() {
+               return __CLASS__ . ': $Id: ApiFormatPhp.php 23531 2007-06-29 01:19:14Z simetrical $';
+       }
+}
+
index 344fd4a..5c5cff4 100644 (file)
@@ -80,7 +80,7 @@ class ApiFormatWddx extends ApiFormatBase {
                }
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return 'Output data in WDDX format' . parent :: getDescription();
        }
 
index c811444..165e2c3 100644 (file)
@@ -136,7 +136,7 @@ class ApiFormatXml extends ApiFormatBase {
                                break;
                }
        }
-       protected function getDescription() {
+       public function getDescription() {
                return 'Output data in XML format' . parent :: getDescription();
        }
 
index d8c110b..66486fe 100644 (file)
@@ -45,7 +45,7 @@ class ApiFormatYaml extends ApiFormatBase {
                $this->printText(Spyc :: YAMLDump($this->getResultData()));
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return 'Output data in YAML format' . parent :: getDescription();
        }
 
index 21150a6..1ee58d3 100644 (file)
@@ -50,7 +50,7 @@ class ApiHelp extends ApiBase {
                return false;
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return array (
                        'Display this help screen.'
                );
index 54a8a5d..d124556 100644 (file)
@@ -220,7 +220,7 @@ class ApiLogin extends ApiBase {
        
        public function mustBePosted() { return true; }
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'name' => null,
                        'password' => null,
@@ -228,7 +228,7 @@ class ApiLogin extends ApiBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'name' => 'User Name',
                        'password' => 'Password',
@@ -236,7 +236,7 @@ class ApiLogin extends ApiBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return array (
                        'This module is used to login and get the authentication tokens. ',
                        'In the event of a successful log-in, a cookie will be attached',
index 6b09e8f..d578acf 100644 (file)
@@ -45,15 +45,15 @@ class ApiLogout extends ApiBase {
                $wgUser->logout();
        }
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array ();
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array ();
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return array (
                        'This module is used to logout and clear session data'
                );
index fed2f36..2d630b8 100644 (file)
@@ -377,7 +377,7 @@ class ApiMain extends ApiBase {
        /**
         * See ApiBase for description.
         */
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'format' => array (
                                ApiBase :: PARAM_DFLT => ApiMain :: API_DEFAULT_FORMAT,
@@ -397,7 +397,7 @@ class ApiMain extends ApiBase {
        /**
         * See ApiBase for description.
         */
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'format' => 'The format of the output',
                        'action' => 'What action you would like to perform',
@@ -409,7 +409,7 @@ class ApiMain extends ApiBase {
        /**
         * See ApiBase for description.
         */
-       protected function getDescription() {
+       public function getDescription() {
                return array (
                        '',
                        '',
index 0c219d3..2c63efe 100644 (file)
@@ -112,7 +112,7 @@ class ApiMove extends ApiBase {
        
        public function mustBePosted() { return true; }
        
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'from' => null,
                        'to' => null,
@@ -123,7 +123,7 @@ class ApiMove extends ApiBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'from' => 'Title of the page you want to move.',
                        'to' => 'Title you want to rename the page to.',
@@ -134,7 +134,7 @@ class ApiMove extends ApiBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return array(
                        'Moves a page.'
                );
index 7ecf922..bfeb2a5 100644 (file)
@@ -82,7 +82,7 @@ class ApiOpenSearch extends ApiBase {
                $result->addValue(null, 1, $srchres);
        }
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'search' => null,
                        'limit' => array (
@@ -95,14 +95,14 @@ class ApiOpenSearch extends ApiBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'search' => 'Search string',
                        'limit' => 'Maximum amount of results to return'
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return 'This module implements OpenSearch protocol';
        }
 
index 563c20f..7de2225 100644 (file)
-<?php\r
-\r
-/*\r
- * Created on Dec 01, 2007\r
- *\r
- * API for MediaWiki 1.8+\r
- *\r
- * Copyright (C) 2008 Roan Kattouw <Firstname>.<Lastname>@home.nl\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License along\r
- * with this program; if not, write to the Free Software Foundation, Inc.,\r
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\r
- * http://www.gnu.org/copyleft/gpl.html\r
- */\r
-\r
-if (!defined('MEDIAWIKI')) {\r
-       // Eclipse helper - will be ignored in production\r
-       require_once ("ApiBase.php");\r
-}\r
-\r
-/**\r
- * @addtogroup API\r
- */\r
-class ApiParamInfo extends ApiBase {\r
-\r
-       public function __construct($main, $action) {\r
-               parent :: __construct($main, $action);\r
-       }\r
-\r
-       public function execute() {\r
-               // Get parameters\r
-               $params = $this->extractRequestParams();\r
-               $result = $this->getResult();\r
-               $r = array();\r
-               if(is_array($params['modules']))\r
-               {\r
-                       $modArr = $this->getMain()->getModules();\r
-                       foreach($params['modules'] as $m)\r
-                       {\r
-                               if(!isset($modArr[$m]))\r
-                               {\r
-                                       $r['modules'][] = array('name' => $m, 'missing' => '');\r
-                                       continue;\r
-                               }\r
-                               $obj = new $modArr[$m]($this->getMain(), $m);\r
-                               $a = $this->getClassInfo($obj);\r
-                               $a['name'] = $m;\r
-                               $r['modules'][] = $a;                           \r
-                       }\r
-                       $result->setIndexedTagName($r['modules'], 'module');\r
-               }\r
-               if(is_array($params['querymodules']))\r
-               {\r
-                       $queryObj = new ApiQuery($this->getMain(), 'query');\r
-                       $qmodArr = $queryObj->getModules();\r
-                       foreach($params['querymodules'] as $qm)\r
-                       {\r
-                               if(!isset($qmodArr[$qm]))\r
-                               {\r
-                                       $r['querymodules'][] = array('name' => $qm, 'missing' => '');\r
-                                       continue;\r
-                               }\r
-                               $obj = new $qmodArr[$qm]($this, $qm);\r
-                               $a = $this->getClassInfo($obj);\r
-                               $a['name'] = $qm;\r
-                               $r['querymodules'][] = $a;\r
-                       }\r
-                       $result->setIndexedTagName($r['querymodules'], 'module');\r
-               }\r
-               $result->addValue(null, $this->getModuleName(), $r);\r
-       }\r
-\r
-       function getClassInfo($obj)\r
-       {\r
-               $result = $this->getResult();\r
-               $retval['classname'] = get_class($obj);\r
-               $retval['description'] = (is_array($obj->getDescription()) ? implode("\n", $obj->getDescription()) : $obj->getDescription());\r
-               $retval['prefix'] = $obj->getModulePrefix();\r
-               $allowedParams = $obj->getAllowedParams();\r
-               if(!is_array($allowedParams))\r
-                       return $retval;\r
-               $retval['parameters'] = array();\r
-               $paramDesc = $obj->getParamDescription();\r
-               foreach($obj->getAllowedParams() as $n => $p)\r
-               {\r
-                       $a = array('name' => $n);\r
-                       if(!is_array($p))\r
-                       {\r
-                               if(is_bool($p))\r
-                               {\r
-                                       $a['type'] = 'bool';\r
-                                       $a['default'] = ($p ? 'true' : 'false');\r
-                               }\r
-                               if(is_string($p))\r
-                                       $a['default'] = $p;\r
-                               $retval['parameters'][] = $a;\r
-                               continue;\r
-                       }\r
-                                       \r
-                       if(isset($p[ApiBase::PARAM_DFLT]))\r
-                               $a['default'] = $p[ApiBase::PARAM_DFLT];\r
-                       if(isset($p[ApiBase::PARAM_ISMULTI]))\r
-                               if($p[ApiBase::PARAM_ISMULTI])\r
-                                       $a['multi'] = '';\r
-                       if(isset($p[ApiBase::PARAM_TYPE]))\r
-                       {\r
-                               $a['type'] = $p[ApiBase::PARAM_TYPE];\r
-                               if(is_array($a['type']))\r
-                                       $result->setIndexedTagName($a['type'], 't');\r
-                       }\r
-                       if(isset($p[ApiBase::PARAM_MAX]))\r
-                               $a['max'] = $p[ApiBase::PARAM_MAX];\r
-                       if(isset($p[ApiBase::PARAM_MAX2]))\r
-                               $a['highmax'] = $p[ApiBase::PARAM_MAX2];\r
-                       if(isset($p[ApiBase::PARAM_MIN]))\r
-                               $a['min'] = $p[ApiBase::PARAM_MIN];\r
-                       if(isset($paramDesc[$n]))\r
-                               $a['description'] = (is_array($paramDesc[$n]) ? implode("\n", $paramDesc[$n]) : $paramDesc[$n]);\r
-                       $retval['parameters'][] = $a;\r
-               }\r
-               $result->setIndexedTagName($retval['parameters'], 'param');\r
-               return $retval;\r
-       }\r
-       \r
-       protected function getAllowedParams() {\r
-               return array (\r
-                       'modules' => array(\r
-                               ApiBase :: PARAM_ISMULTI => true\r
-                       ),\r
-                       'querymodules' => array(\r
-                               ApiBase :: PARAM_ISMULTI => true\r
-                       )\r
-               );\r
-       }\r
-\r
-       protected function getParamDescription() {\r
-               return array (\r
-                       'modules' => 'List of module names (value of the action= parameter)',\r
-                       'querymodules' => 'List of query module names (value of prop=, meta= or list= parameter)',\r
-               );\r
-       }\r
-\r
-       protected function getDescription() {\r
-               return 'Obtain information about certain API parameters';\r
-       }\r
-\r
-       protected function getExamples() {\r
-               return array (\r
-                       'api.php?action=paraminfo&modules=parse&querymodules=allpages|siteinfo'\r
-               );\r
-       }\r
-\r
-       public function getVersion() {\r
-               return __CLASS__ . ': $Id: ApiParse.php 29810 2008-01-15 21:33:08Z catrope $';\r
-       }\r
-}\r
-\r
+<?php
+
+/*
+ * Created on Dec 01, 2007
+ *
+ * API for MediaWiki 1.8+
+ *
+ * Copyright (C) 2008 Roan Kattouw <Firstname>.<Lastname>@home.nl
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+if (!defined('MEDIAWIKI')) {
+       // Eclipse helper - will be ignored in production
+       require_once ("ApiBase.php");
+}
+
+/**
+ * @addtogroup API
+ */
+class ApiParamInfo extends ApiBase {
+
+       public function __construct($main, $action) {
+               parent :: __construct($main, $action);
+       }
+
+       public function execute() {
+               // Get parameters
+               $params = $this->extractRequestParams();
+               $result = $this->getResult();
+               $r = array();
+               if(is_array($params['modules']))
+               {
+                       $modArr = $this->getMain()->getModules();
+                       foreach($params['modules'] as $m)
+                       {
+                               if(!isset($modArr[$m]))
+                               {
+                                       $r['modules'][] = array('name' => $m, 'missing' => '');
+                                       continue;
+                               }
+                               $obj = new $modArr[$m]($this->getMain(), $m);
+                               $a = $this->getClassInfo($obj);
+                               $a['name'] = $m;
+                               $r['modules'][] = $a;                           
+                       }
+                       $result->setIndexedTagName($r['modules'], 'module');
+               }
+               if(is_array($params['querymodules']))
+               {
+                       $queryObj = new ApiQuery($this->getMain(), 'query');
+                       $qmodArr = $queryObj->getModules();
+                       foreach($params['querymodules'] as $qm)
+                       {
+                               if(!isset($qmodArr[$qm]))
+                               {
+                                       $r['querymodules'][] = array('name' => $qm, 'missing' => '');
+                                       continue;
+                               }
+                               $obj = new $qmodArr[$qm]($this, $qm);
+                               $a = $this->getClassInfo($obj);
+                               $a['name'] = $qm;
+                               $r['querymodules'][] = $a;
+                       }
+                       $result->setIndexedTagName($r['querymodules'], 'module');
+               }
+               $result->addValue(null, $this->getModuleName(), $r);
+       }
+
+       function getClassInfo($obj)
+       {
+               $result = $this->getResult();
+               $retval['classname'] = get_class($obj);
+               $retval['description'] = (is_array($obj->getDescription()) ? implode("\n", $obj->getDescription()) : $obj->getDescription());
+               $retval['prefix'] = $obj->getModulePrefix();
+               $allowedParams = $obj->getAllowedParams();
+               if(!is_array($allowedParams))
+                       return $retval;
+               $retval['parameters'] = array();
+               $paramDesc = $obj->getParamDescription();
+               foreach($obj->getAllowedParams() as $n => $p)
+               {
+                       $a = array('name' => $n);
+                       if(!is_array($p))
+                       {
+                               if(is_bool($p))
+                               {
+                                       $a['type'] = 'bool';
+                                       $a['default'] = ($p ? 'true' : 'false');
+                               }
+                               if(is_string($p))
+                                       $a['default'] = $p;
+                               $retval['parameters'][] = $a;
+                               continue;
+                       }
+                                       
+                       if(isset($p[ApiBase::PARAM_DFLT]))
+                               $a['default'] = $p[ApiBase::PARAM_DFLT];
+                       if(isset($p[ApiBase::PARAM_ISMULTI]))
+                               if($p[ApiBase::PARAM_ISMULTI])
+                                       $a['multi'] = '';
+                       if(isset($p[ApiBase::PARAM_TYPE]))
+                       {
+                               $a['type'] = $p[ApiBase::PARAM_TYPE];
+                               if(is_array($a['type']))
+                                       $result->setIndexedTagName($a['type'], 't');
+                       }
+                       if(isset($p[ApiBase::PARAM_MAX]))
+                               $a['max'] = $p[ApiBase::PARAM_MAX];
+                       if(isset($p[ApiBase::PARAM_MAX2]))
+                               $a['highmax'] = $p[ApiBase::PARAM_MAX2];
+                       if(isset($p[ApiBase::PARAM_MIN]))
+                               $a['min'] = $p[ApiBase::PARAM_MIN];
+                       if(isset($paramDesc[$n]))
+                               $a['description'] = (is_array($paramDesc[$n]) ? implode("\n", $paramDesc[$n]) : $paramDesc[$n]);
+                       $retval['parameters'][] = $a;
+               }
+               $result->setIndexedTagName($retval['parameters'], 'param');
+               return $retval;
+       }
+       
+       public function getAllowedParams() {
+               return array (
+                       'modules' => array(
+                               ApiBase :: PARAM_ISMULTI => true
+                       ),
+                       'querymodules' => array(
+                               ApiBase :: PARAM_ISMULTI => true
+                       )
+               );
+       }
+
+       public function getParamDescription() {
+               return array (
+                       'modules' => 'List of module names (value of the action= parameter)',
+                       'querymodules' => 'List of query module names (value of prop=, meta= or list= parameter)',
+               );
+       }
+
+       public function getDescription() {
+               return 'Obtain information about certain API parameters';
+       }
+
+       protected function getExamples() {
+               return array (
+                       'api.php?action=paraminfo&modules=parse&querymodules=allpages|siteinfo'
+               );
+       }
+
+       public function getVersion() {
+               return __CLASS__ . ': $Id: ApiParse.php 29810 2008-01-15 21:33:08Z catrope $';
+       }
+}
+
index 04915e5..205fa0b 100644 (file)
@@ -133,7 +133,7 @@ class ApiParse extends ApiBase {
                }
        }
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'title' => array( 
                                ApiBase :: PARAM_DFLT => 'API',
@@ -156,7 +156,7 @@ class ApiParse extends ApiBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'text' => 'Wikitext to parse',
                        'title' => 'Title of page',
@@ -164,7 +164,7 @@ class ApiParse extends ApiBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return 'This module parses wikitext and returns parser output';
        }
 
index 6a32434..bd7fa90 100644 (file)
@@ -111,7 +111,7 @@ class ApiProtect extends ApiBase {
 
        public function mustBePosted() { return true; }
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'title' => null,
                        'token' => null,
@@ -124,7 +124,7 @@ class ApiProtect extends ApiBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'title' => 'Title of the page you want to restore.',
                        'token' => 'A protect token previously retrieved through prop=info',
@@ -135,7 +135,7 @@ class ApiProtect extends ApiBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return array(
                        'Change the protection level of a page.'
                );
index 57d29bf..d3110a5 100644 (file)
@@ -388,7 +388,7 @@ class ApiQuery extends ApiBase {
         * Returns the list of allowed parameters for this module.
         * Qurey module also lists all ApiPageSet parameters as its own. 
         */
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'prop' => array (
                                ApiBase :: PARAM_ISMULTI => true,
@@ -475,7 +475,7 @@ class ApiQuery extends ApiBase {
                return true;
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'prop' => 'Which properties to get for the titles/revisions/pageids',
                        'list' => 'Which lists to get',
@@ -486,7 +486,7 @@ class ApiQuery extends ApiBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return array (
                        'Query API module allows applications to get needed pieces of data from the MediaWiki databases,',
                        'and is loosely based on the Query API interface currently available on all MediaWiki servers.',
index e65ffe0..8449487 100644 (file)
@@ -96,7 +96,7 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase {
                }
        }
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'from' => null,
                        'prefix' => null,
@@ -117,7 +117,7 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'from' => 'The category to start enumerating from.',
                        'prefix' => 'Search for all category titles that begin with this value.',
@@ -126,7 +126,7 @@ class ApiQueryAllCategories extends ApiQueryGeneratorBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return 'Enumerate all categories';
        }
 
index a0c8766..e40cc15 100644 (file)
@@ -125,7 +125,7 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase {
                }
        }
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'from' => null,
                        'prefix' => null,
@@ -152,7 +152,7 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'from' => 'The page title to start enumerating from.',
                        'prefix' => 'Search for all page titles that begin with this value.',
@@ -163,7 +163,7 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return 'Enumerate all links that point to a given namespace';
        }
 
index 7d55491..c715141 100644 (file)
@@ -158,7 +158,7 @@ class ApiQueryAllUsers extends ApiQueryBase {
                $result->addValue('query', $this->getModuleName(), $data);
        }
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'from' => null,
                        'prefix' => null,
@@ -183,7 +183,7 @@ class ApiQueryAllUsers extends ApiQueryBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'from' => 'The user name to start enumerating from.',
                        'prefix' => 'Search for all page titles that begin with this value.',
@@ -195,7 +195,7 @@ class ApiQueryAllUsers extends ApiQueryBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return 'Enumerate all registered users';
        }
 
index 0095787..ce4f6c5 100644 (file)
@@ -94,7 +94,7 @@ class ApiQueryAllmessages extends ApiQueryBase {
                $result->addValue( 'query', $this->getModuleName(), $messages_out );
        }
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'messages' => array (
                                ApiBase :: PARAM_DFLT => '*',
@@ -104,7 +104,7 @@ class ApiQueryAllmessages extends ApiQueryBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'messages' => 'Which messages to output. "*" means all messages',
                        'filter' => 'Return only messages that contains specified string',
@@ -112,7 +112,7 @@ class ApiQueryAllmessages extends ApiQueryBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return 'Return messages from this site.';
        }
 
index d21657f..0100ef3 100644 (file)
@@ -158,7 +158,7 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase {
                }
        }
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                global $wgRestrictionTypes, $wgRestrictionLevels;
                
                return array (
@@ -215,7 +215,7 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'from' => 'The page title to start enumerating from.',
                        'prefix' => 'Search for all page titles that begin with this value.',
@@ -231,7 +231,7 @@ class ApiQueryAllpages extends ApiQueryGeneratorBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return 'Enumerate all pages sequentially in a given namespace';
        }
 
index bdd72ac..924725c 100644 (file)
@@ -315,7 +315,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
                '|' . $lastPageID;
        }
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
 
                return array (
                        'title' => null,
@@ -343,7 +343,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'title' => 'Title to search. If null, titles= parameter will be used instead, but will be obsolete soon.',
                        'continue' => 'When more results are available, use this to continue.',
@@ -354,7 +354,7 @@ class ApiQueryBacklinks extends ApiQueryGeneratorBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                switch ($this->getModuleName()) {
                        case 'backlinks' :
                                return 'Find all pages that link to the given page';
index 0595957..8924289 100644 (file)
@@ -166,7 +166,7 @@ class ApiQueryBlocks extends ApiQueryBase {
                return implode('.', $parts);
        }
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'start' => array(
                                ApiBase :: PARAM_TYPE => 'timestamp'
@@ -212,7 +212,7 @@ class ApiQueryBlocks extends ApiQueryBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'start' => 'The timestamp to start enumerating from',
                        'end' => 'The timestamp to stop enumerating at',
@@ -224,7 +224,7 @@ class ApiQueryBlocks extends ApiQueryBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return 'List all blocked users and IP addresses.';
        }
 
index 2283a8b..eec03bb 100644 (file)
@@ -120,7 +120,7 @@ class ApiQueryCategories extends ApiQueryGeneratorBase {
                $db->freeResult($res);
        }
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'prop' => array (
                                ApiBase :: PARAM_ISMULTI => true,
@@ -131,13 +131,13 @@ class ApiQueryCategories extends ApiQueryGeneratorBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'prop' => 'Which additional properties to get for each category.',
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return 'List all categories the page(s) belong to';
        }
 
index 487fea8..93c91c1 100644 (file)
@@ -172,7 +172,7 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
                }
        }
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'category' => null,
                        'prop' => array (
@@ -214,7 +214,7 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'category' => 'Which category to enumerate (required)',
                        'prop' => 'What pieces of information to include',
@@ -226,7 +226,7 @@ class ApiQueryCategoryMembers extends ApiQueryGeneratorBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return 'List all pages in a given category';
        }
 
index 14dd26b..a8c8f65 100644 (file)
@@ -163,7 +163,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
                $result->addValue('query', $this->getModuleName(), $data);
                }
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'start' => array(
                                ApiBase :: PARAM_TYPE => 'timestamp'
@@ -205,7 +205,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'start' => 'The timestamp to start enumerating from',
                        'end' => 'The timestamp to stop enumerating at',
@@ -216,7 +216,7 @@ class ApiQueryDeletedrevs extends ApiQueryBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return 'List deleted revisions.';
        }
 
index 2e47a57..2c9b3be 100644 (file)
@@ -134,7 +134,7 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase {
                }
        }
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                global $wgUrlProtocols;
                $protocols = array();
                foreach ($wgUrlProtocols as $p) {
@@ -173,7 +173,7 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'prop' => 'What pieces of information to include',
                        'offset' => 'Used for paging. Use the value returned for "continue"',
@@ -184,7 +184,7 @@ class ApiQueryExtLinksUsage extends ApiQueryGeneratorBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return 'Enumerate pages that contain a given URL';
        }
 
index ad4634e..1b88937 100644 (file)
@@ -75,7 +75,7 @@ class ApiQueryExternalLinks extends ApiQueryBase {
                $db->freeResult($res);
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return 'Returns all external urls (not interwikies) from the given page(s)';
        }
 
index c8dfc52..f1a335e 100644 (file)
@@ -140,7 +140,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
                return $vals;
        }
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'prop' => array (
                                ApiBase :: PARAM_ISMULTI => true,
@@ -179,7 +179,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'prop' => 'What image information to get.',
                        'limit' => 'How many image revisions to return',
@@ -190,7 +190,7 @@ class ApiQueryImageInfo extends ApiQueryBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return array (
                        'Returns image information and upload history'
                );
index 10a5885..da32e89 100644 (file)
@@ -98,7 +98,7 @@ class ApiQueryImages extends ApiQueryGeneratorBase {
                $db->freeResult($res);
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return 'Returns all images contained on the given page(s)';
        }
 
index f6a5019..b7e4d61 100644 (file)
@@ -217,7 +217,7 @@ class ApiQueryInfo extends ApiQueryBase {
                }
        }
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'prop' => array (
                                ApiBase :: PARAM_DFLT => NULL,
@@ -237,7 +237,7 @@ class ApiQueryInfo extends ApiQueryBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'prop' => array (
                                'Which additional properties to get:',
@@ -248,7 +248,7 @@ class ApiQueryInfo extends ApiQueryBase {
        }
 
 
-       protected function getDescription() {
+       public function getDescription() {
                return 'Get basic page information such as namespace, title, last touched date, ...';
        }
 
index 99457ae..777cbe0 100644 (file)
@@ -76,7 +76,7 @@ class ApiQueryLangLinks extends ApiQueryBase {
                $db->freeResult($res);
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return 'Returns all interlanguage links from the given page(s)';
        }
 
index e3a4027..1d31737 100644 (file)
@@ -123,7 +123,7 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
                $db->freeResult($res);
        }
 
-       protected function getAllowedParams()
+       public function getAllowedParams()
        {
                return array(
                                'namespace' => array(
@@ -133,14 +133,14 @@ class ApiQueryLinks extends ApiQueryGeneratorBase {
                        );
        }
 
-       protected function getParamDescription()
+       public function getParamDescription()
        {
                return array(
                                'namespace' => "Show {$this->description}s in this namespace(s) only"
                        );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return "Returns all {$this->description}s from the given page(s)";
        }
 
index b23b6a5..1290c6c 100644 (file)
@@ -198,7 +198,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
        }
 
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                global $wgLogTypes;
                return array (
                        'prop' => array (
@@ -243,7 +243,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'prop' => 'Which properties to get',
                        'type' => 'Filter log entries to only this type(s)',
@@ -256,7 +256,7 @@ class ApiQueryLogEvents extends ApiQueryBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return 'Get events from logs.';
        }
 
index 5741ed5..813cd16 100644 (file)
-<?php\r
-\r
-/*\r
- * Created on Monday, January 28, 2008\r
- *\r
- * API for MediaWiki 1.8+\r
- *\r
- * Copyright (C) 2008 Brent Garber\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License along\r
- * with this program; if not, write to the Free Software Foundation, Inc.,\r
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\r
- * http://www.gnu.org/copyleft/gpl.html\r
- */\r
-\r
-if (!defined('MEDIAWIKI')) {\r
-       // Eclipse helper - will be ignored in production\r
-       require_once ('ApiQueryBase.php');\r
-}\r
-\r
-/**\r
- * Query module to get list of random pages\r
- * \r
- * @addtogroup API\r
- */\r
\r
- class ApiQueryRandom extends ApiQueryGeneratorBase {\r
-\r
-       public function __construct($query, $moduleName) {\r
-               parent :: __construct($query, $moduleName, 'rn');\r
-       }\r
-       \r
-       public function execute() {\r
-               $this->run();\r
-       }\r
-       \r
-       public function executeGenerator($resultPageSet) {\r
-               $this->run($resultPageSet);\r
-       }\r
-\r
-       public function run($resultPageSet = null) {\r
-               $params = $this->extractRequestParams();\r
-               $result = $this->getResult();\r
-               $randstr = wfRandom();\r
-               $data = array();\r
-\r
-               $this->addTables('page');\r
-               $this->addOption('LIMIT', $params['limit']);\r
-               $this->addWhereFld('page_namespace', $params['namespace']);\r
-               $this->addWhereRange('page_random', 'newer', $randstr, null);\r
-               $this->addWhere(array('page_is_redirect' => 0));\r
-               $this->addOption('USE INDEX', 'page_random');\r
-               if(is_null($resultPageSet))\r
-                       $this->addFields(array('page_id', 'page_title', 'page_namespace'));\r
-               else\r
-                       $this->addFields($resultPageSet->getPageTableFields());\r
-\r
-               $db = $this->getDB();\r
-               $res = $this->select(__METHOD__);\r
-               while($row = $db->fetchObject($res)) {\r
-                       if(is_null($resultPageSet))\r
-                               $data[] = $this->extractRowInfo($row);\r
-                       else\r
-                               $resultPageSet->processDbRow($row);\r
-               }\r
-               $db->freeResult($res);\r
-\r
-               if(is_null($resultPageSet)) {\r
-                       $result->setIndexedTagName($data, 'page');\r
-                       $result->addValue('query', $this->getModuleName(), $data);\r
-               }               \r
-       }\r
-\r
-       private function extractRowInfo($row) {\r
-               $title = Title::makeTitle($row->page_namespace, $row->page_title);\r
-               $vals = array();\r
-               $vals['title'] = $title->getPrefixedText();\r
-               $vals['ns'] = $row->page_namespace;\r
-               $vals['id'] = $row->page_id;\r
-               return $vals;\r
-       }\r
-               \r
-       protected function getAllowedParams() {\r
-               return array (\r
-                       'namespace' => array(\r
-                               ApiBase :: PARAM_TYPE => 'namespace',\r
-                               ApiBase :: PARAM_ISMULTI => true\r
-                       ),\r
-                       'limit' => array (\r
-                               ApiBase :: PARAM_TYPE => 'limit',\r
-                               ApiBase :: PARAM_DFLT => 1,\r
-                               ApiBase :: PARAM_MIN => 1,\r
-                               ApiBase :: PARAM_MAX => 10,\r
-                               ApiBase :: PARAM_MAX2 => 20\r
-                       ),\r
-               );\r
-       }\r
-\r
-       protected function getParamDescription() {\r
-               return array (\r
-                       'namespace' => 'Return pages in these namespaces only',\r
-                       'limit' => 'Limit how many random pages will be returned'\r
-               );\r
-       }\r
-\r
-       protected function getDescription() {\r
-               return array(   'Get a set of random pages',\r
-                               'NOTE: When using a namespace filter, this module may return an empty result. In that case, retry the request'\r
-               );\r
-       }\r
-\r
-       protected function getExamples() {\r
-               return 'api.php?action=query&list=random&rnnamespace=0&rnlimit=2';\r
-       }\r
-\r
-       public function getVersion() {\r
-               return __CLASS__ . ': $Id: ApiQueryRandom.php overlordq$';\r
-       }\r
-}\r
+<?php
+
+/*
+ * Created on Monday, January 28, 2008
+ *
+ * API for MediaWiki 1.8+
+ *
+ * Copyright (C) 2008 Brent Garber
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+if (!defined('MEDIAWIKI')) {
+       // Eclipse helper - will be ignored in production
+       require_once ('ApiQueryBase.php');
+}
+
+/**
+ * Query module to get list of random pages
+ * 
+ * @addtogroup API
+ */
+ class ApiQueryRandom extends ApiQueryGeneratorBase {
+
+       public function __construct($query, $moduleName) {
+               parent :: __construct($query, $moduleName, 'rn');
+       }
+       
+       public function execute() {
+               $this->run();
+       }
+       
+       public function executeGenerator($resultPageSet) {
+               $this->run($resultPageSet);
+       }
+
+       public function run($resultPageSet = null) {
+               $params = $this->extractRequestParams();
+               $result = $this->getResult();
+               $randstr = wfRandom();
+               $data = array();
+
+               $this->addTables('page');
+               $this->addOption('LIMIT', $params['limit']);
+               $this->addWhereFld('page_namespace', $params['namespace']);
+               $this->addWhereRange('page_random', 'newer', $randstr, null);
+               $this->addWhere(array('page_is_redirect' => 0));
+               $this->addOption('USE INDEX', 'page_random');
+               if(is_null($resultPageSet))
+                       $this->addFields(array('page_id', 'page_title', 'page_namespace'));
+               else
+                       $this->addFields($resultPageSet->getPageTableFields());
+
+               $db = $this->getDB();
+               $res = $this->select(__METHOD__);
+               while($row = $db->fetchObject($res)) {
+                       if(is_null($resultPageSet))
+                               $data[] = $this->extractRowInfo($row);
+                       else
+                               $resultPageSet->processDbRow($row);
+               }
+               $db->freeResult($res);
+
+               if(is_null($resultPageSet)) {
+                       $result->setIndexedTagName($data, 'page');
+                       $result->addValue('query', $this->getModuleName(), $data);
+               }               
+       }
+
+       private function extractRowInfo($row) {
+               $title = Title::makeTitle($row->page_namespace, $row->page_title);
+               $vals = array();
+               $vals['title'] = $title->getPrefixedText();
+               $vals['ns'] = $row->page_namespace;
+               $vals['id'] = $row->page_id;
+               return $vals;
+       }
+               
+       public function getAllowedParams() {
+               return array (
+                       'namespace' => array(
+                               ApiBase :: PARAM_TYPE => 'namespace',
+                               ApiBase :: PARAM_ISMULTI => true
+                       ),
+                       'limit' => array (
+                               ApiBase :: PARAM_TYPE => 'limit',
+                               ApiBase :: PARAM_DFLT => 1,
+                               ApiBase :: PARAM_MIN => 1,
+                               ApiBase :: PARAM_MAX => 10,
+                               ApiBase :: PARAM_MAX2 => 20
+                       ),
+               );
+       }
+
+       public function getParamDescription() {
+               return array (
+                       'namespace' => 'Return pages in these namespaces only',
+                       'limit' => 'Limit how many random pages will be returned'
+               );
+       }
+
+       public function getDescription() {
+               return array(   'Get a set of random pages',
+                               'NOTE: When using a namespace filter, this module may return an empty result. In that case, retry the request'
+               );
+       }
+
+       protected function getExamples() {
+               return 'api.php?action=query&list=random&rnnamespace=0&rnlimit=2';
+       }
+
+       public function getVersion() {
+               return __CLASS__ . ': $Id: ApiQueryRandom.php overlordq$';
+       }
+}
index a80b6c7..d01b7a5 100644 (file)
@@ -260,7 +260,7 @@ class ApiQueryRecentChanges extends ApiQueryBase {
                        }
        }                       
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'start' => array (
                                ApiBase :: PARAM_TYPE => 'timestamp'
@@ -321,7 +321,7 @@ class ApiQueryRecentChanges extends ApiQueryBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'start' => 'The timestamp to start enumerating from.',
                        'end' => 'The timestamp to end enumerating.',
@@ -337,7 +337,7 @@ class ApiQueryRecentChanges extends ApiQueryBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return 'Enumerate recent changes';
        }
 
index 14da7f9..3dff0bc 100644 (file)
@@ -280,7 +280,7 @@ class ApiQueryRevisions extends ApiQueryBase {
                return $vals;
        }
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'prop' => array (
                                ApiBase :: PARAM_ISMULTI => true,
@@ -337,7 +337,7 @@ class ApiQueryRevisions extends ApiQueryBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'prop' => 'Which properties to get for each revision.',
                        'limit' => 'limit how many revisions will be returned (enum)',
@@ -353,7 +353,7 @@ class ApiQueryRevisions extends ApiQueryBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return array (
                        'Get revision information.',
                        'This module may be used in several ways:',
index 0352a55..b2a10b5 100644 (file)
@@ -94,7 +94,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
                }
        }
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'search' => null,
                        'namespace' => array (
@@ -121,7 +121,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'search' => 'Search for all page titles (or content) that has this value.',
                        'namespace' => 'The namespace(s) to enumerate.',
@@ -132,7 +132,7 @@ class ApiQuerySearch extends ApiQueryGeneratorBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return 'Perform a full text search';
        }
 
index 1bd34cd..e8ca0d2 100644 (file)
@@ -181,7 +181,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                $this->getResult()->addValue('query', $property, $data);
        }       
        
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                
                        'prop' => array (
@@ -205,7 +205,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'prop' => array (
                                'Which sysinfo properties to get:',
@@ -220,7 +220,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return 'Return general information about the site.';
        }
 
index 6c3d356..91e8451 100644 (file)
@@ -196,7 +196,7 @@ class ApiQueryContributions extends ApiQueryBase {
                return $vals;
        }
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'limit' => array (
                                ApiBase :: PARAM_DFLT => 10,
@@ -246,7 +246,7 @@ class ApiQueryContributions extends ApiQueryBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'limit' => 'The maximum number of contributions to return.',
                        'start' => 'The start timestamp to return from.',
@@ -259,7 +259,7 @@ class ApiQueryContributions extends ApiQueryBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return 'Get all edits by a user';
        }
 
index 1cc8cba..e5f38fe 100644 (file)
@@ -87,7 +87,7 @@ class ApiQueryUserInfo extends ApiQueryBase {
                return $vals;
        }
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'prop' => array (
                                ApiBase :: PARAM_DFLT => NULL,
@@ -107,7 +107,7 @@ class ApiQueryUserInfo extends ApiQueryBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'prop' => array(
                                'What pieces of information to include',
@@ -122,7 +122,7 @@ class ApiQueryUserInfo extends ApiQueryBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return 'Get information about the current user';
        }
 
index 20bad51..144bfba 100644 (file)
-<?php\r
-\r
-/*\r
- * Created on July 30, 2007\r
- *\r
- * API for MediaWiki 1.8+\r
- *\r
- * Copyright (C) 2007 Roan Kattouw <Firstname>.<Lastname>@home.nl\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License along\r
- * with this program; if not, write to the Free Software Foundation, Inc.,\r
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\r
- * http://www.gnu.org/copyleft/gpl.html\r
- */\r
-\r
-if (!defined('MEDIAWIKI')) {\r
-       // Eclipse helper - will be ignored in production\r
-       require_once ('ApiQueryBase.php');\r
-}\r
-\r
-/**\r
- * Query module to get information about a list of users\r
- * \r
- * @addtogroup API\r
- */\r
\r
- class ApiQueryUsers extends ApiQueryBase {\r
-\r
-       public function __construct($query, $moduleName) {\r
-               parent :: __construct($query, $moduleName, 'us');\r
-       }\r
-\r
-       public function execute() {\r
-               $params = $this->extractRequestParams();\r
-               $result = $this->getResult();\r
-               $r = array();\r
-\r
-               if (!is_null($params['prop'])) {\r
-                       $this->prop = array_flip($params['prop']);\r
-               } else {\r
-                       $this->prop = array();\r
-               }\r
-       \r
-               if(is_array($params['users'])) {\r
-                       $r = $this->getOtherUsersInfo($params['users']);\r
-                       $result->setIndexedTagName($r, 'user');\r
-               }\r
-               $result->addValue("query", $this->getModuleName(), $r);\r
-       }\r
-\r
-       protected function getOtherUsersInfo($users) {\r
-               $goodNames = $retval = array();\r
-               // Canonicalize user names\r
-               foreach($users as $u) {\r
-                       $n = User::getCanonicalName($u);\r
-                       if($n === false) \r
-                               $retval[] = array('name' => $u, 'invalid' => '');\r
-                        else\r
-                               $goodNames[] = $n;\r
-               }\r
-\r
-               $db = $this->getDb();\r
-               $userTable = $db->tableName('user');\r
-               $tables = "$userTable AS u1";\r
-               $this->addFields('u1.user_name');\r
-               $this->addWhereFld('u1.user_name', $goodNames);\r
-               $this->addFieldsIf('u1.user_editcount', isset($this->prop['editcount']));\r
-               \r
-               if(isset($this->prop['groups'])) {\r
-                       $ug = $db->tableName('user_groups');\r
-                       $tables = "$tables LEFT JOIN $ug ON ug_user=u1.user_id";\r
-                       $this->addFields('ug_group');\r
-               }\r
-               if(isset($this->prop['blockinfo'])) {\r
-                       $ipb = $db->tableName('ipblocks');\r
-                       $tables = "$tables LEFT JOIN $ipb ON ipb_user=u1.user_id";\r
-                       $tables = "$tables LEFT JOIN $userTable AS u2 ON ipb_by=u2.user_id";\r
-                       $this->addFields(array('ipb_reason', 'u2.user_name AS blocker_name'));\r
-               }\r
-               $this->addTables($tables);\r
-               \r
-               $data = array();\r
-               $res = $this->select(__METHOD__);\r
-               while(($r = $db->fetchObject($res))) {\r
-                       $data[$r->user_name]['name'] = $r->user_name;\r
-                       if(isset($this->prop['editcount']))\r
-                               $data[$r->user_name]['editcount'] = $r->user_editcount;\r
-                       if(isset($this->prop['groups']))\r
-                               // This row contains only one group, others will be added from other rows\r
-                               if(!is_null($r->ug_group))\r
-                                       $data[$r->user_name]['groups'][] = $r->ug_group;\r
-                       if(isset($this->prop['blockinfo']))\r
-                               if(!is_null($r->blocker_name)) {\r
-                                       $data[$r->user_name]['blockedby'] = $r->blocker_name;\r
-                                       $data[$r->user_name]['blockreason'] = $r->ipb_reason;\r
-                               }\r
-               }\r
-               \r
-               // Second pass: add result data to $retval\r
-               foreach($goodNames as $u) {\r
-                       if(!isset($data[$u]))\r
-                               $retval[] = array('name' => $u, 'missing' => '');\r
-                       else {\r
-                               if(isset($this->prop['groups']) && isset($data[$u]['groups']))\r
-                                       $this->getResult()->setIndexedTagName($data[$u]['groups'], 'g');\r
-                               $retval[] = $data[$u];\r
-                       }\r
-               }\r
-               return $retval;         \r
-       }\r
-\r
-       protected function getAllowedParams() {\r
-               return array (\r
-                       'prop' => array (\r
-                               ApiBase :: PARAM_DFLT => NULL,\r
-                               ApiBase :: PARAM_ISMULTI => true,\r
-                               ApiBase :: PARAM_TYPE => array (\r
-                                       'blockinfo',\r
-                                       'groups',\r
-                                       'editcount'\r
-                               )\r
-                       ),\r
-                       'users' => array(\r
-                               ApiBase :: PARAM_ISMULTI => true\r
-                       )\r
-               );\r
-       }\r
-\r
-       protected function getParamDescription() {\r
-               return array (\r
-                       'prop' => array(\r
-                               'What pieces of information to include',\r
-                               '  blockinfo - tags if the user is blocked, by whom, and for what reason',\r
-                               '  groups    - lists all the groups the user belongs to',\r
-                               '  editcount - adds the user\'s edit count'\r
-                       ),\r
-                       'users' => 'A list of users to obtain the same information for'\r
-               );\r
-       }\r
-\r
-       protected function getDescription() {\r
-               return 'Get information about a list of users';\r
-       }\r
-\r
-       protected function getExamples() {\r
-               return 'api.php?action=query&list=users&ususers=brion|TimStarling&usprop=groups|editcount';\r
-       }\r
-\r
-       public function getVersion() {\r
-               return __CLASS__ . ': $Id: ApiQueryUserInfo.php 30128 2008-01-24 17:59:07Z catrope $';\r
-       }\r
-}\r
+<?php
+
+/*
+ * Created on July 30, 2007
+ *
+ * API for MediaWiki 1.8+
+ *
+ * Copyright (C) 2007 Roan Kattouw <Firstname>.<Lastname>@home.nl
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+if (!defined('MEDIAWIKI')) {
+       // Eclipse helper - will be ignored in production
+       require_once ('ApiQueryBase.php');
+}
+
+/**
+ * Query module to get information about a list of users
+ * 
+ * @addtogroup API
+ */
+ class ApiQueryUsers extends ApiQueryBase {
+
+       public function __construct($query, $moduleName) {
+               parent :: __construct($query, $moduleName, 'us');
+       }
+
+       public function execute() {
+               $params = $this->extractRequestParams();
+               $result = $this->getResult();
+               $r = array();
+
+               if (!is_null($params['prop'])) {
+                       $this->prop = array_flip($params['prop']);
+               } else {
+                       $this->prop = array();
+               }
+       
+               if(is_array($params['users'])) {
+                       $r = $this->getOtherUsersInfo($params['users']);
+                       $result->setIndexedTagName($r, 'user');
+               }
+               $result->addValue("query", $this->getModuleName(), $r);
+       }
+
+       protected function getOtherUsersInfo($users) {
+               $goodNames = $retval = array();
+               // Canonicalize user names
+               foreach($users as $u) {
+                       $n = User::getCanonicalName($u);
+                       if($n === false) 
+                               $retval[] = array('name' => $u, 'invalid' => '');
+                        else
+                               $goodNames[] = $n;
+               }
+
+               $db = $this->getDb();
+               $userTable = $db->tableName('user');
+               $tables = "$userTable AS u1";
+               $this->addFields('u1.user_name');
+               $this->addWhereFld('u1.user_name', $goodNames);
+               $this->addFieldsIf('u1.user_editcount', isset($this->prop['editcount']));
+               
+               if(isset($this->prop['groups'])) {
+                       $ug = $db->tableName('user_groups');
+                       $tables = "$tables LEFT JOIN $ug ON ug_user=u1.user_id";
+                       $this->addFields('ug_group');
+               }
+               if(isset($this->prop['blockinfo'])) {
+                       $ipb = $db->tableName('ipblocks');
+                       $tables = "$tables LEFT JOIN $ipb ON ipb_user=u1.user_id";
+                       $tables = "$tables LEFT JOIN $userTable AS u2 ON ipb_by=u2.user_id";
+                       $this->addFields(array('ipb_reason', 'u2.user_name AS blocker_name'));
+               }
+               $this->addTables($tables);
+               
+               $data = array();
+               $res = $this->select(__METHOD__);
+               while(($r = $db->fetchObject($res))) {
+                       $data[$r->user_name]['name'] = $r->user_name;
+                       if(isset($this->prop['editcount']))
+                               $data[$r->user_name]['editcount'] = $r->user_editcount;
+                       if(isset($this->prop['groups']))
+                               // This row contains only one group, others will be added from other rows
+                               if(!is_null($r->ug_group))
+                                       $data[$r->user_name]['groups'][] = $r->ug_group;
+                       if(isset($this->prop['blockinfo']))
+                               if(!is_null($r->blocker_name)) {
+                                       $data[$r->user_name]['blockedby'] = $r->blocker_name;
+                                       $data[$r->user_name]['blockreason'] = $r->ipb_reason;
+                               }
+               }
+               
+               // Second pass: add result data to $retval
+               foreach($goodNames as $u) {
+                       if(!isset($data[$u]))
+                               $retval[] = array('name' => $u, 'missing' => '');
+                       else {
+                               if(isset($this->prop['groups']) && isset($data[$u]['groups']))
+                                       $this->getResult()->setIndexedTagName($data[$u]['groups'], 'g');
+                               $retval[] = $data[$u];
+                       }
+               }
+               return $retval;         
+       }
+
+       public function getAllowedParams() {
+               return array (
+                       'prop' => array (
+                               ApiBase :: PARAM_DFLT => NULL,
+                               ApiBase :: PARAM_ISMULTI => true,
+                               ApiBase :: PARAM_TYPE => array (
+                                       'blockinfo',
+                                       'groups',
+                                       'editcount'
+                               )
+                       ),
+                       'users' => array(
+                               ApiBase :: PARAM_ISMULTI => true
+                       )
+               );
+       }
+
+       public function getParamDescription() {
+               return array (
+                       'prop' => array(
+                               'What pieces of information to include',
+                               '  blockinfo - tags if the user is blocked, by whom, and for what reason',
+                               '  groups    - lists all the groups the user belongs to',
+                               '  editcount - adds the user\'s edit count'
+                       ),
+                       'users' => 'A list of users to obtain the same information for'
+               );
+       }
+
+       public function getDescription() {
+               return 'Get information about a list of users';
+       }
+
+       protected function getExamples() {
+               return 'api.php?action=query&list=users&ususers=brion|TimStarling&usprop=groups|editcount';
+       }
+
+       public function getVersion() {
+               return __CLASS__ . ': $Id: ApiQueryUserInfo.php 30128 2008-01-24 17:59:07Z catrope $';
+       }
+}
index 12ac7a1..8960664 100644 (file)
@@ -243,7 +243,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                return $vals;
        }
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'allrev' => false,
                        'start' => array (
@@ -298,7 +298,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'allrev' => 'Include multiple revisions of the same page within given timeframe.',
                        'start' => 'The timestamp to start enumerating from.',
@@ -314,7 +314,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return '';
        }
 
index 0f37ef9..5e21789 100644 (file)
@@ -88,7 +88,7 @@ class ApiRollback extends ApiBase {
        
        public function mustBePosted() { return true; }
        
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'title' => null,
                        'user' => null,
@@ -98,7 +98,7 @@ class ApiRollback extends ApiBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'title' => 'Title of the page you want to rollback.',
                        'user' => 'Name of the user whose edits are to be rolled back. If set incorrectly, you\'ll get a badtoken error.',
@@ -108,7 +108,7 @@ class ApiRollback extends ApiBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return array(
                                'Undoes the last edit to the page. If the last user who edited the page made multiple edits in a row,',
                                'they will all be rolled back. You need to be logged in as a sysop to use this function, see also action=login.'
index 7aaa1d5..f1d8753 100644 (file)
@@ -85,7 +85,7 @@ class ApiUnblock extends ApiBase {
        
        public function mustBePosted() { return true; }
 
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'id' => null,
                        'user' => null,
@@ -95,7 +95,7 @@ class ApiUnblock extends ApiBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'id' => 'ID of the block you want to unblock (obtained through list=blocks). Cannot be used together with user',
                        'user' => 'Username, IP address or IP range you want to unblock. Cannot be used together with id',
@@ -105,7 +105,7 @@ class ApiUnblock extends ApiBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return array(
                        'Unblock a user.'
                );
index 510b777..04ba074 100644 (file)
@@ -83,7 +83,7 @@ class ApiUndelete extends ApiBase {
        
        public function mustBePosted() { return true; }
        
-       protected function getAllowedParams() {
+       public function getAllowedParams() {
                return array (
                        'title' => null,
                        'token' => null,
@@ -94,7 +94,7 @@ class ApiUndelete extends ApiBase {
                );
        }
 
-       protected function getParamDescription() {
+       public function getParamDescription() {
                return array (
                        'title' => 'Title of the page you want to restore.',
                        'token' => 'An undelete token previously retrieved through list=deletedrevs',
@@ -103,7 +103,7 @@ class ApiUndelete extends ApiBase {
                );
        }
 
-       protected function getDescription() {
+       public function getDescription() {
                return array(
                        'Restore certain revisions of a deleted page. A list of deleted revisions (including timestamps) can be',
                        'retrieved through list=deletedrevs'