const PARAM_MAX2 = 4;
const PARAM_MIN = 5;
- private $mMainModule;
+ private $mMainModule, $mModuleName, $mParamPrefix;
/**
* Constructor
*/
- public function __construct($mainModule) {
+ public function __construct($mainModule, $moduleName, $paramPrefix = '') {
$this->mMainModule = $mainModule;
+ $this->mModuleName = $moduleName;
+ $this->mParamPrefix = $paramPrefix;
}
/**
*/
public abstract function execute();
+ /**
+ * Get the name of the query being executed by this instance
+ */
+ public function getModuleName() {
+ return $this->mModuleName;
+ }
+
/**
* Get main module
*/
$desc = isset ($paramsDescription[$paramName]) ? $paramsDescription[$paramName] : '';
if (is_array($desc))
$desc = implode("\n" . str_repeat(' ', 19), $desc);
- $msg .= sprintf(" %-14s - %s\n", $paramName, $desc);
+ $msg .= sprintf(" %-14s - %s\n", $this->encodeParamName($paramName), $desc);
}
return $msg;
protected function getParamDescription() {
return false;
}
+
+ /**
+ * This method mangles parameter name based on the prefix supplied to the constructor.
+ * Override this method to change parameter name during runtime
+ */
+ public function encodeParamName($paramName) {
+ return $this->mParamPrefix . $paramName;
+ }
/**
* Using getAllowedParams(), makes an array of the values provided by the user,
* with key being the name of the variable, and value - validated value from user or default.
* This method can be used to generate local variables using extract().
- *
- * @param $prefix String: prepend this prefix to all parameter names.
*/
- public function extractRequestParams($prefix = '') {
+ public function extractRequestParams() {
$params = $this->getAllowedParams();
$results = array ();
foreach ($params as $paramName => $paramSettings)
- $results[$paramName] = $this->getParameterFromSettings($prefix . $paramName, $paramSettings);
+ $results[$paramName] = $this->getParameterFromSettings($paramName, $paramSettings);
return $results;
}
- protected function getParameter($paramName, $prefix = '') {
+ /**
+ * Get a value for the given parameter
+ */
+ protected function getParameter($paramName) {
$params = $this->getAllowedParams();
$paramSettings = $params[$paramName];
- return $this->getParameterFromSettings($prefix . $paramName, $paramSettings);
+ return $this->getParameterFromSettings($paramName, $paramSettings);
}
-
+
+ /**
+ * Using the settings determine the value for the given parameter
+ * @param $paramName String: parameter name
+ * @param $paramSettings Mixed: default value or an array of settings using PARAM_* constants.
+ */
protected function getParameterFromSettings($paramName, $paramSettings) {
global $wgRequest;
+ // Some classes may decide to change parameter names
+ $paramName = $this->encodeParamName($paramName);
+
if (!is_array($paramSettings)) {
$default = $paramSettings;
$multi = false;
* Call main module's error handler
*/
public function dieUsage($description, $errorCode, $httpRespCode = 0) {
- $this->getMain()->mainDieUsage($description, $errorCode, $httpRespCode);
+ $this->getMain()->mainDieUsage($description, $this->encodeParamName($errorCode), $httpRespCode);
}
/**
abstract class ApiFormatBase extends ApiBase {
- private $mIsHtml, $mFormat, $mOriginalFormat;
+ private $mIsHtml, $mFormat;
/**
* Constructor
*/
public function __construct($main, $format) {
- parent :: __construct($main);
+ parent :: __construct($main, $format);
- $this->mOriginalFormat = $format;
$this->mIsHtml = (substr($format, -2, 2) === 'fm'); // ends with 'fm'
if ($this->mIsHtml)
$this->mFormat = substr($format, 0, -2); // remove ending 'fm'
* Returns usage examples for this format.
*/
protected function getExamples() {
- return 'api.php?action=query&meta=siteinfo&si=namespaces&format=' . $this->mOriginalFormat;
+ return 'api.php?action=query&meta=siteinfo&si=namespaces&format=' . $this->getModuleName();
}
public static function getBaseVersion() {
class ApiHelp extends ApiBase {
public function __construct($main, $action) {
- parent :: __construct($main);
+ parent :: __construct($main, $action);
}
/**
class ApiLogin extends ApiBase {
public function __construct($main, $action) {
- parent :: __construct($main);
+ parent :: __construct($main, $action, 'lg');
}
public function execute() {
- $lgname = $lgpassword = $lgdomain = null;
+ $name = $password = $domain = null;
extract($this->extractRequestParams());
$params = new FauxRequest(array (
- 'wpName' => $lgname,
- 'wpPassword' => $lgpassword,
- 'wpDomain' => $lgdomain,
+ 'wpName' => $name,
+ 'wpPassword' => $password,
+ 'wpDomain' => $domain,
'wpRemember' => ''
));
protected function getAllowedParams() {
return array (
- 'lgname' => '',
- 'lgpassword' => '',
- 'lgdomain' => null
+ 'name' => '',
+ 'password' => '',
+ 'domain' => null
);
}
protected function getParamDescription() {
return array (
- 'lgname' => 'User Name',
- 'lgpassword' => 'Password',
- 'lgdomain' => 'Domain (optional)'
+ 'name' => 'User Name',
+ 'password' => 'Password',
+ 'domain' => 'Domain (optional)'
);
}
'This module is used to login and get the authentication tokens.'
);
}
+
+ protected function getExamples() {
+ return array(
+ 'api.php?action=login&lgname=user&lgpassword=password'
+ );
+ }
public function getVersion() {
return __CLASS__ . ': $Id$';
*/
public function __construct($apiStartTime, $modules, $formats, $enableWrite) {
// Special handling for the main module: $parent === $this
- parent :: __construct($this);
+ parent :: __construct($this, 'main');
$this->mModules = $modules;
$this->mModuleNames = array_keys($modules);
private $mSlaveDB = null;
public function __construct($main, $action) {
- parent :: __construct($main);
+ parent :: __construct($main, $action);
$this->mPropModuleNames = array_keys($this->mQueryPropModules);
$this->mListModuleNames = array_keys($this->mQueryListModules);
$this->mMetaModuleNames = array_keys($this->mQueryMetaModules);
//
$this->mPageSet = new ApiPageSet($this);
- //
- // If generator is provided, get a new dataset to work on
- //
- if (isset ($generator))
- $this->executeGenerator($generator);
-
// Instantiate required modules
$modules = array ();
if (isset ($prop))
}
//
- // Get page information for the given pageSet
+ // If given, execute generator to substitute user supplied data with generated data.
+ //
+ if (isset ($generator))
+ $this->executeGenerator($generator);
+
+ //
+ // Populate page information for the given pageSet
//
$this->mPageSet->execute();
//
- // Record page information
+ // Record page information (title, namespace, if exists, etc)
//
$this->outputGeneralPageInfo();
+ //
// Execute all requested modules.
+ //
foreach ($modules as $module) {
$module->profileIn();
$module->execute();
protected function executeGenerator($generatorName) {
// Find class that implements requested generator
- if (isset ($this->mQueryListModules[$generatorName]))
+ if (isset ($this->mQueryListModules[$generatorName])) {
$className = $this->mQueryListModules[$generatorName];
- elseif (isset ($this->mQueryPropModules[$generatorName])) $className = $this->mQueryPropModules[$generatorName];
- else
+ }
+ elseif (isset ($this->mQueryPropModules[$generatorName])) {
+ $className = $this->mQueryPropModules[$generatorName];
+ } else {
ApiBase :: dieDebug(__METHOD__, "Unknown generator=$generatorName");
+ }
- $generator = new $className ($this, $generatorName, true);
- if (!$generator->getCanGenerate())
+ // Use current pageset as the result, and create a new one just for the generator
+ $resultPageSet = $this->mPageSet;
+ $this->mPageSet = new ApiPageSet($this);
+
+ // Create and execute the generator
+ $generator = new $className ($this, $generatorName);
+ if (!$generator instanceof ApiQueryGeneratorBase)
$this->dieUsage("Module $generatorName cannot be used as a generator", "badgenerator");
-
+
+ $generator->setGeneratorMode();
$generator->requestExtraData();
- // execute pageSet here to get the data required by the generator module
+ // execute current pageSet to get the data for the generator module
$this->mPageSet->execute();
-
+
+ // populate resultPageSet with the generator output
$generator->profileIn();
- $this->mPageSet = $generator->execute();
+ $generator->executeGenerator($resultPageSet);
$generator->profileOut();
+
+ // Swap the resulting pageset back in
+ $this->mPageSet = $resultPageSet;
}
protected function getAllowedParams() {
ApiBase :: PARAM_TYPE => $this->mMetaModuleNames
),
'generator' => array (
- ApiBase::PARAM_TYPE => $this->mAllowedGenerators
- )
+ ApiBase :: PARAM_TYPE => $this->mAllowedGenerators
+ )
);
}
$msg2 = $module->makeHelpMsg();
if ($msg2 !== false)
$msg .= $msg2;
- if ($module->getCanGenerate())
+ if ($module instanceof ApiQueryGeneratorBase)
$msg .= "Generator:\n This module may be used as a generator\n";
$moduleDscriptions[] = $msg;
}
public function getVersion() {
$psModule = new ApiPageSet($this);
- $vers = array();
+ $vers = array ();
$vers[] = __CLASS__ . ': $Id$';
$vers[] = $psModule->getVersion();
return $vers;
}
}
-?>
\ No newline at end of file
+?>
require_once ('ApiQueryBase.php');
}
-class ApiQueryAllpages extends ApiQueryBase {
+class ApiQueryAllpages extends ApiQueryGeneratorBase {
- public function __construct($query, $moduleName, $generator = false) {
- parent :: __construct($query, $moduleName, $generator);
+ public function __construct($query, $moduleName) {
+ parent :: __construct($query, $moduleName, 'ap');
}
public function execute() {
- $aplimit = $apfrom = $apnamespace = $apfilterredir = null;
+ $this->run();
+ }
+
+ public function executeGenerator($resultPageSet) {
+ $this->run($resultPageSet);
+ }
+
+ private function run($resultPageSet = null) {
+ $limit = $from = $namespace = $filterredir = null;
extract($this->extractRequestParams());
$db = $this->getDB();
+
$where = array (
- 'page_namespace' => $apnamespace
+ 'page_namespace' => $namespace
);
- if (isset ($apfrom))
- $where[] = 'page_title>=' . $db->addQuotes(ApiQueryBase :: titleToKey($apfrom));
-
- if ($apfilterredir === 'redirects')
+ if (isset ($from)) {
+ $where[] = 'page_title>=' . $db->addQuotes(ApiQueryBase :: titleToKey($from));
+ }
+ if ($filterredir === 'redirects') {
$where['page_is_redirect'] = 1;
- elseif ($apfilterredir === 'nonredirects') $where['page_is_redirect'] = 0;
+ }
+ elseif ($filterredir === 'nonredirects') {
+ $where['page_is_redirect'] = 0;
+ }
$this->profileDBIn();
$res = $db->select('page', array (
'page_title'
), $where, __CLASS__ . '::' . __METHOD__, array (
'USE INDEX' => 'name_title',
- 'LIMIT' => $aplimit +1,
+ 'LIMIT' => $limit +1,
'ORDER BY' => 'page_namespace, page_title'
));
$this->profileDBOut();
$data = array ();
- if(!$this->isGenerator())
- ApiResult :: setIndexedTagName($data, 'p');
-
$count = 0;
while ($row = $db->fetchObject($res)) {
- if (++ $count > $aplimit) {
+ if (++ $count > $limit) {
// We've reached the one extra which shows that there are additional pages to be had. Stop here...
$msg = array (
- 'continue' => ($this->isGenerator() ? 'g' : '') . 'apfrom=' . ApiQueryBase :: keyToTitle($row->page_title
- ));
+ 'continue' => $this->encodeParamName('from') . '='. ApiQueryBase :: keyToTitle($row->page_title));
$this->getResult()->addValue('query-status', 'allpages', $msg);
break;
}
if ($title->userCanRead()) {
$id = intval($row->page_id);
- if ($this->isGenerator()) {
- $data[] = $id; // in generator mode, just assemble a list of page IDs.
- } else {
+ if (is_null($resultPageSet)) {
$pagedata = array ();
$pagedata['id'] = $id;
if ($title->getNamespace() !== 0)
$pagedata['ns'] = $title->getNamespace();
$pagedata['title'] = $title->getPrefixedText();
-
+
$data[$id] = $pagedata;
+ } else {
+ $data[] = $id; // in generator mode, just assemble a list of page IDs.
}
}
}
$db->freeResult($res);
- if ($this->isGenerator()) {
- $pageSet = new ApiPageSet($this->getQuery());
- $pageSet->executeForPageIDs($data);
- return $pageSet;
- } else {
+ if (is_null($resultPageSet)) {
+ ApiResult :: setIndexedTagName($data, 'p');
$this->getResult()->addValue('query', 'allpages', $data);
+ } else {
+ $resultPageSet->executeForPageIDs($data);
}
}
}
return array (
- 'apfrom' => null,
- 'apnamespace' => array (
+ 'from' => null,
+ 'namespace' => array (
ApiBase :: PARAM_DFLT => 0,
ApiBase :: PARAM_TYPE => $validNamespaces
),
- 'apfilterredir' => array (
+ 'filterredir' => array (
ApiBase :: PARAM_DFLT => 'all',
ApiBase :: PARAM_TYPE => array (
'all',
'nonredirects'
)
),
- 'aplimit' => array (
+ 'limit' => array (
ApiBase :: PARAM_DFLT => 10,
ApiBase :: PARAM_TYPE => 'limit',
ApiBase :: PARAM_MIN => 1,
protected function getParamDescription() {
return array (
- 'apfrom' => 'The page title to start enumerating from.',
- 'apnamespace' => 'The namespace to enumerate. Default 0 (Main).',
- 'apfilterredir' => 'Which pages to list: "all" (default), "redirects", or "nonredirects"',
- 'aplimit' => 'How many total pages to return'
+ 'from' => 'The page title to start enumerating from.',
+ 'namespace' => 'The namespace to enumerate. Default 0 (Main).',
+ 'filterredir' => 'Which pages to list: "all" (default), "redirects", or "nonredirects"',
+ 'limit' => 'How many total pages to return'
);
}
);
}
- public function getCanGenerate() {
- return true;
- }
-
public function getVersion() {
return __CLASS__ . ': $Id$';
}
abstract class ApiQueryBase extends ApiBase {
- private $mQueryModule, $mModuleName, $mIsGenerator;
-
- public function __construct($query, $moduleName, $isGenerator = false) {
- parent :: __construct($query->getMain());
+ private $mQueryModule;
+
+ public function __construct($query, $moduleName, $paramPrefix = '') {
+ parent :: __construct($query->getMain(), $moduleName, $paramPrefix);
$this->mQueryModule = $query;
- $this->mModuleName = $moduleName;
- $this->mIsGenerator = $isGenerator;
}
/**
return $this->mQueryModule;
}
- /**
- * Get the name of the query being executed by this instance
- */
- public function getModuleName() {
- return $this->mModuleName;
- }
-
- /**
- * Overrides base class to prepend 'g' to every generator parameter
- */
- public function extractRequestParams() {
- $prefix = '';
- if($this->isGenerator())
- $prefix = 'g';
- return parent :: extractRequestParams($prefix);
- }
-
/**
* Get the Query database connection (readonly)
*/
return $this->mQueryModule->getPageSet();
}
- /**
- * Return true if this instance is being used as a generator.
- */
- protected function isGenerator() {
- return $this->mIsGenerator;
- }
-
- /**
- * Derived classes return true when they can be used as title generators for other query modules.
- */
- public function getCanGenerate() {
- return false;
- }
-
public static function titleToKey($title) {
return str_replace(' ', '_', $title);
}
-
+
public static function keyToTitle($key) {
return str_replace('_', ' ', $key);
}
return __CLASS__ . ': $Id$';
}
}
-?>
+
+abstract class ApiQueryGeneratorBase extends ApiQueryBase {
+
+ private $mIsGenerator;
+
+ public function __construct($query, $moduleName, $paramPrefix = '') {
+ parent :: __construct($query, $moduleName, $paramPrefix);
+ $mIsGenerator = false;
+ }
+
+ public function setGeneratorMode() {
+ $this->mIsGenerator = true;
+ }
+
+ /**
+ * Overrides base class to prepend 'g' to every generator parameter
+ */
+ public function encodeParamName($paramName) {
+ if ($this->mIsGenerator)
+ return 'g' . parent :: encodeParamName($paramName);
+ else
+ return parent :: encodeParamName($paramName);
+ }
+
+ /**
+ * Execute this module as a generator
+ * @param $resultPageSet PageSet: All output should be appended to this object
+ */
+ public abstract function executeGenerator($resultPageSet);
+}
+?>
\ No newline at end of file
class ApiQueryInfo extends ApiQueryBase {
- // private $mParameters;
-
- public function __construct($query, $moduleName, $generator = false) {
- parent :: __construct($query, $moduleName, $generator);
+ public function __construct($query, $moduleName) {
+ parent :: __construct($query, $moduleName);
}
public function requestExtraData() {
class ApiQueryRevisions extends ApiQueryBase {
- public function __construct($query, $moduleName, $generator = false) {
- parent :: __construct($query, $moduleName, $generator);
+ public function __construct($query, $moduleName) {
+ parent :: __construct($query, $moduleName, 'rv');
}
public function execute() {
- $rvlimit = $rvstartid = $rvendid = $rvstart = $rvend = $rvdir = $rvprop = null;
+ $limit = $startid = $endid = $start = $end = $dir = $prop = null;
extract($this->extractRequestParams());
$db = $this->getDB();
// true when ordered by timestamp from older to newer, false otherwise
- $dirNewer = ($rvdir === 'newer');
+ $dirNewer = ($dir === 'newer');
// If any of those parameters are used, work in 'enumeration' mode.
// Enum mode can only be used when exactly one page is provided.
// Enumerating revisions on multiple pages make it extremelly
// difficult to manage continuations and require additional sql indexes
- $enumRevMode = ($rvlimit !== 0 || $rvstartid !== 0 || $rvendid !== 0 || $dirNewer || isset ($rvstart) || isset ($rvend));
+ $enumRevMode = ($limit !== 0 || $startid !== 0 || $endid !== 0 || $dirNewer || isset ($start) || isset ($end));
$pageSet = $this->getPageSet();
$pageCount = $pageSet->getGoodTitleCount();
return;
if ($revCount > 0 && $pageCount > 0)
- $this->dieUsage('The revids= parameter may not be used with titles, pageids, or generator options.', 'rv_revids');
+ $this->dieUsage('The revids= parameter may not be used with titles, pageids, or generator options.', 'revids');
if ($revCount > 0 && $enumRevMode)
- $this->dieUsage('The revids= parameter may not be used with the list options (rvlimit, rvstartid, rvendid, dirNewer, rvstart, rvend).', 'rv_revids');
+ $this->dieUsage('The revids= parameter may not be used with the list options (limit, startid, endid, dirNewer, start, end).', 'revids');
if ($revCount === 0 && $pageCount > 1 && $enumRevMode)
- $this->dieUsage('titles, pageids or a generator was used to supply multiple pages, but the rvlimit, rvstartid, rvendid, dirNewer, rvstart, and rvend parameters may only be used on a single page.', 'rv_multpages');
+ $this->dieUsage('titles, pageids or a generator was used to supply multiple pages, but the limit, startid, endid, dirNewer, start, and end parameters may only be used on a single page.', 'multpages');
$tables = array (
'revision'
$options = array ();
$showTimestamp = $showUser = $showComment = $showContent = false;
- if (isset ($rvprop)) {
- foreach ($rvprop as $prop) {
- switch ($prop) {
+ if (isset ($prop)) {
+ foreach ($prop as $p) {
+ switch ($p) {
case 'timestamp' :
$fields[] = 'rev_timestamp';
$showTimestamp = true;
$showContent = true;
break;
default :
- ApiBase :: dieDebug(__METHOD__, "unknown rvprop $prop");
+ ApiBase :: dieDebug(__METHOD__, "unknown prop $p");
}
}
}
if ($enumRevMode) {
// This is mostly to prevent parameter errors (and optimize sql?)
- if ($rvstartid !== 0 && isset ($rvstart))
- $this->dieUsage('rvstart and rvstartid cannot be used together', 'rv_badparams');
+ if ($startid !== 0 && isset ($start))
+ $this->dieUsage('start and startid cannot be used together', 'badparams');
- if ($rvendid !== 0 && isset ($rvend))
- $this->dieUsage('rvend and rvend cannot be used together', 'rv_badparams');
+ if ($endid !== 0 && isset ($end))
+ $this->dieUsage('end and endid cannot be used together', 'badparams');
// This code makes an assumption that sorting by rev_id and rev_timestamp produces
// the same result. This way users may request revisions starting at a given time,
// Switching to rev_id removes the potential problem of having more than
// one row with the same timestamp for the same page.
// The order needs to be the same as start parameter to avoid SQL filesort.
- $options['ORDER BY'] = ($rvstartid !== 0 ? 'rev_id' : 'rev_timestamp') . ($dirNewer ? '' : ' DESC');
+ $options['ORDER BY'] = ($startid !== 0 ? 'rev_id' : 'rev_timestamp') . ($dirNewer ? '' : ' DESC');
$before = ($dirNewer ? '<=' : '>=');
$after = ($dirNewer ? '>=' : '<=');
- if ($rvstartid !== 0)
- $conds[] = 'rev_id' . $after . intval($rvstartid);
- if ($rvendid !== 0)
- $conds[] = 'rev_id' . $before . intval($rvendid);
- if (isset ($rvstart))
- $conds[] = 'rev_timestamp' . $after . $db->addQuotes($rvstart);
- if (isset ($rvend))
- $conds[] = 'rev_timestamp' . $before . $db->addQuotes($rvend);
+ if ($startid !== 0)
+ $conds[] = 'rev_id' . $after . intval($startid);
+ if ($endid !== 0)
+ $conds[] = 'rev_id' . $before . intval($endid);
+ if (isset ($start))
+ $conds[] = 'rev_timestamp' . $after . $db->addQuotes($start);
+ if (isset ($end))
+ $conds[] = 'rev_timestamp' . $before . $db->addQuotes($end);
- // must manually initialize unset rvlimit
- if (!isset ($rvlimit))
- $rvlimit = 10;
+ // must manually initialize unset limit
+ if (!isset ($limit))
+ $limit = 10;
- $this->validateLimit('rvlimit', $rvlimit, 1, $userMax, $botMax);
+ $this->validateLimit($this->encodeParamName('limit'), $limit, 1, $userMax, $botMax);
// There is only one ID, use it
$conds['rev_page'] = array_pop(array_keys($pageSet->getGoodTitles()));
// Get all page IDs
$conds['page_id'] = array_keys($pageSet->getGoodTitles());
- $rvlimit = $pageCount; // assumption testing -- we should never get more then $pageCount rows.
+ $limit = $pageCount; // assumption testing -- we should never get more then $pageCount rows.
}
elseif ($revCount > 0) {
$this->validateLimit('rev_count', $revCount, 1, $userMax, $botMax);
// Get all revision IDs
$conds['rev_id'] = array_keys($pageSet->getRevisionIDs());
- $rvlimit = $revCount; // assumption testing -- we should never get more then $revCount rows.
+ $limit = $revCount; // assumption testing -- we should never get more then $revCount rows.
} else
ApiBase :: dieDebug(__METHOD__, 'param validation?');
- $options['LIMIT'] = $rvlimit +1;
+ $options['LIMIT'] = $limit +1;
$this->profileDBIn();
$res = $db->select($tables, $fields, $conds, __METHOD__, $options);
$count = 0;
while ($row = $db->fetchObject($res)) {
- if (++ $count > $rvlimit) {
+ if (++ $count > $limit) {
// We've reached the one extra which shows that there are additional pages to be had. Stop here...
if (!$enumRevMode)
ApiBase :: dieDebug(__METHOD__, 'Got more rows then expected'); // bug report
- $startStr = 'rvstartid=' . $row->rev_id;
+ $startStr = 'startid=' . $row->rev_id;
$msg = array (
'continue' => $startStr
);
protected function getAllowedParams() {
return array (
- 'rvprop' => array (
+ 'prop' => array (
ApiBase :: PARAM_ISMULTI => true,
ApiBase :: PARAM_TYPE => array (
'timestamp',
'content'
)
),
- 'rvlimit' => array (
+ 'limit' => array (
ApiBase :: PARAM_DFLT => 0,
ApiBase :: PARAM_TYPE => 'limit',
ApiBase :: PARAM_MIN => 0,
ApiBase :: PARAM_MAX1 => 50,
ApiBase :: PARAM_MAX2 => 500
),
- 'rvstartid' => 0,
- 'rvendid' => 0,
- 'rvstart' => array (
+ 'startid' => 0,
+ 'endid' => 0,
+ 'start' => array (
ApiBase :: PARAM_TYPE => 'timestamp'
),
- 'rvend' => array (
+ 'end' => array (
ApiBase :: PARAM_TYPE => 'timestamp'
),
- 'rvdir' => array (
+ 'dir' => array (
ApiBase :: PARAM_DFLT => 'older',
ApiBase :: PARAM_TYPE => array (
'newer',
protected function getParamDescription() {
return array (
- 'rvprop' => 'Which properties to get for each revision: user|timestamp|comment|content',
- 'rvlimit' => 'limit how many revisions will be returned (enum)',
- 'rvstartid' => 'from which revision id to start enumeration (enum)',
- 'rvendid' => 'stop revision enumeration on this revid (enum)',
- 'rvstart' => 'from which revision timestamp to start enumeration (enum)',
- 'rvend' => 'enumerate up to this timestamp (enum)',
- 'rvdir' => 'direction of enumeration - towards "newer" or "older" revisions (enum)'
+ 'prop' => 'Which properties to get for each revision: user|timestamp|comment|content',
+ 'limit' => 'limit how many revisions will be returned (enum)',
+ 'startid' => 'from which revision id to start enumeration (enum)',
+ 'endid' => 'stop revision enumeration on this revid (enum)',
+ 'start' => 'from which revision timestamp to start enumeration (enum)',
+ 'end' => 'enumerate up to this timestamp (enum)',
+ 'dir' => 'direction of enumeration - towards "newer" or "older" revisions (enum)'
);
}
'Get revision information.',
'This module may be used in several ways:',
' 1) Get data about a set of pages (last revision), by setting titles or pageids parameter.',
- ' 2) Get revisions for one given page, by using titles/pageids with rvstart/rvend/rvlimit params.',
+ ' 2) Get revisions for one given page, by using titles/pageids with start/end/limit params.',
' 3) Get data about a set of revisions by setting their IDs with revids parameter.',
'All parameters marked as (enum) may only be used with a single page (#2).'
);
class ApiQuerySiteinfo extends ApiQueryBase {
public function __construct($query, $moduleName) {
- parent :: __construct($query, $moduleName);
+ parent :: __construct($query, $moduleName, 'si');
}
public function execute() {
- $siprop = null;
+ $prop = null;
extract($this->extractRequestParams());
- foreach ($siprop as $prop) {
- switch ($prop) {
+ foreach ($prop as $p) {
+ switch ($p) {
case 'general' :
$data['sitename'] = $wgSitename;
$data['generator'] = "MediaWiki $wgVersion";
$data['case'] = $wgCapitalLinks ? 'first-letter' : 'case-sensitive'; // 'case-insensitive' option is reserved for future
- $this->getResult()->addValue('query', $prop, $data);
+ $this->getResult()->addValue('query', $p, $data);
break;
case 'namespaces' :
ApiResult :: setContent($data[$ns], $title);
}
ApiResult :: setIndexedTagName($data, 'ns');
- $this->getResult()->addValue('query', $prop, $data);
+ $this->getResult()->addValue('query', $p, $data);
break;
default :
- ApiBase :: dieDebug(__METHOD__, "Unknown siprop=$prop");
+ ApiBase :: dieDebug(__METHOD__, "Unknown prop=$p");
}
}
}
protected function getAllowedParams() {
return array (
- 'siprop' => array (
+ 'prop' => array (
ApiBase :: PARAM_DFLT => 'general',
ApiBase :: PARAM_ISMULTI => true,
ApiBase :: PARAM_TYPE => array (
protected function getParamDescription() {
return array (
- 'siprop' => array (
+ 'prop' => array (
'Which sysinfo properties to get:',
' "general" - Overall system information',
' "namespaces" - List of registered namespaces (localized)'
* Constructor
*/
public function __construct($main) {
- parent :: __construct($main);
+ parent :: __construct($main, 'result');
$this->Reset();
}