/**
* Executes this module
*/
- abstract function execute();
+ public abstract function execute();
/**
* Get main module
$msg .= 'Example' . (count($examples) > 1 ? 's' : '') . ":\n ";
$msg .= implode($lnPrfx, $examples) . "\n";
}
+
+ if ($this->getMain()->getShowVersions()) {
+ $versions = $this->getVersion();
+ if (is_array($versions))
+ $versions = implode("\n ", $versions);
+ $msg .= "Version:\n $versions\n";
+ }
}
return $msg;
ApiBase :: dieDebug(__METHOD__, 'called without calling profileDBOut() first');
return $this->mDBTime;
}
+
+ public function getVersion() {
+ return __CLASS__ . ': $Id$';
+ }
}
?>
\ No newline at end of file
protected function getExamples() {
return 'api.php?action=query&meta=siteinfo&si=namespaces&format=' . $this->mOriginalFormat;
}
+
+ public static function getBaseVersion() {
+ return __CLASS__ . ': $Id$';
+ }
}
?>
\ No newline at end of file
protected function getDescription() {
return 'Output data in JSON format';
}
+
+ public function getVersion() {
+ return __CLASS__ . ': $Id$';
+ }
}
?>
\ No newline at end of file
'xmlindent' => 'Enable XML indentation'
);
}
+
+ public function getVersion() {
+ return __CLASS__ . ': $Id$';
+ }
}
?>
\ No newline at end of file
protected function getDescription() {
return 'Output data in YAML format';
}
+
+ public function getVersion() {
+ return __CLASS__ . ': $Id$';
+ }
}
?>
\ No newline at end of file
'Display this help screen.'
);
}
+
+ public function getVersion() {
+ return __CLASS__ . ': $Id$';
+ }
}
?>
\ No newline at end of file
'This module is used to login and get the authentication tokens.'
);
}
+
+ public function getVersion() {
+ return __CLASS__ . ': $Id$';
+ }
}
?>
class ApiMain extends ApiBase {
- private $mPrinter, $mModules, $mModuleNames, $mFormats, $mFormatNames, $mApiStartTime, $mResult;
+ private $mPrinter, $mModules, $mModuleNames, $mFormats, $mFormatNames, $mApiStartTime, $mResult, $mShowVersions;
/**
* Constructor
$this->mFormatNames = array_keys($formats);
$this->mApiStartTime = $apiStartTime;
$this->mResult = new ApiResult($this);
+ $this->mShowVersions = false;
}
public function & getResult() {
return $this->mResult;
}
+ public function getShowVersions() {
+ return $this->mShowVersions;
+ }
+
protected function getAllowedParams() {
return array (
'format' => array (
'action' => array (
ApiBase :: PARAM_DFLT => 'help',
ApiBase :: PARAM_TYPE => $this->mModuleNames
- )
+ ),
+ 'version' => false
);
}
protected function getParamDescription() {
return array (
'format' => 'The format of the output',
- 'action' => 'What action you would like to perform'
+ 'action' => 'What action you would like to perform',
+ 'version' => 'When showing help, include version for each module'
);
}
public function execute() {
$this->profileIn();
- $action = $format = null;
+ $action = $format = $version = null;
try {
extract($this->extractRequestParams());
+ $this->mShowVersions = $version;
// Create an appropriate printer
$this->mPrinter = new $this->mFormats[$format] ($this, $format);
$module->execute();
$module->profileOut();
$this->printResult(false);
+
} catch (UsageException $e) {
+
// Printer may not be initialized if the extractRequestParams() fails for the main module
if (!isset ($this->mPrinter))
$this->mPrinter = new $this->mFormats[API_DEFAULT_FORMAT] ($this, API_DEFAULT_FORMAT);
$this->printResult(true);
+
}
$this->profileOut();
}
}
return $this->mIsBot;
}
+
+ public function getVersion() {
+
+ return array (
+ parent :: getVersion(), __CLASS__ . ': $Id$', ApiFormatBase :: getBaseVersion());
+ }
}
/**
'redirects' => 'Automatically resolve redirects'
);
}
+
+ public function getVersion() {
+ return array (
+ parent :: getVersion(), __CLASS__ . ': $Id$');
+ }
}
?>
\ No newline at end of file
* Override to add extra parameters from PageSet
*/
public function makeHelpMsgParameters() {
- $module = new ApiPageSet($this);
- return $module->makeHelpMsgParameters() . parent :: makeHelpMsgParameters();
+ $psModule = new ApiPageSet($this);
+ return $psModule->makeHelpMsgParameters() . parent :: makeHelpMsgParameters();
}
protected function getParamDescription() {
'api.php?action=query&prop=revisions&meta=siteinfo&titles=Main%20Page&rvprop=user|comment'
);
}
+
+ public function getVersion() {
+ $psModule = new ApiPageSet($this);
+ $vers = $psModule->getVersion();
+ $vers[] = __CLASS__ . ': $Id$';
+ return $vers;
+ }
}
?>
'api.php?action=query&list=allpages&apfrom=B&aplimit=5'
);
}
+
public function getCanGenerate() {
return true;
}
+
+ public function getVersion() {
+ return __CLASS__ . ': $Id$';
+ }
}
?>
\ No newline at end of file
public static function titleToKey($title) {
return str_replace(' ', '_', $title);
}
+
public static function keyToTitle($key) {
return str_replace('_', ' ', $key);
}
+
+ public function getVersion() {
+ return __CLASS__ . ': $Id$';
+ }
}
?>
'api.php?action=query&prop=info&titles=Main%20Page'
);
}
+
+ public function getVersion() {
+ return __CLASS__ . ': $Id$';
+ }
}
?>
\ No newline at end of file
' api.php?action=query&prop=revisions&titles=Main%20Page&rvlimit=5&rvprop=timestamp|user|comment&rvdir=newer&rvstart=20060501000000'
);
}
+
+ public function getVersion() {
+ return __CLASS__ . ': $Id$';
+ }
}
?>
\ No newline at end of file
protected function getExamples() {
return 'api.php?action=query&meta=siteinfo&siprop=general|namespaces';
}
+
+ public function getVersion() {
+ return __CLASS__ . ': $Id$';
+ }
}
?>
\ No newline at end of file
public function execute() {
ApiBase :: dieDebug(__METHOD__, 'execute() is not supported on Result object');
}
+
+ public function getVersion() {
+ return __CLASS__ . ': $Id$';
+ }
}
?>
\ No newline at end of file