class ApiMain extends ApiBase {
- private $mPrinter, $mModules, $mModuleNames, $mFormats, $mFormatNames, $mApiStartTime, $mResult, $mShowVersions;
+ private $mPrinter, $mModules, $mModuleNames, $mFormats, $mFormatNames;
+ private $mApiStartTime, $mResult, $mShowVersions, $mEnableWrite;
/**
* Constructor
* $apiStartTime - time of the originating call for profiling purposes
* $modules - an array of actions (keys) and classes that handle them (values)
*/
- public function __construct($apiStartTime, $modules, $formats) {
+ 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);
$this->mApiStartTime = $apiStartTime;
$this->mResult = new ApiResult($this);
$this->mShowVersions = false;
+ $this->mEnableWrite = $enableWrite;
}
public function & getResult() {
return $this->mShowVersions;
}
+ public function requestWriteMode() {
+ if (!$this->mEnableWrite)
+ $this->dieUsage('Editing of this site is disabled. Make sure the $wgEnableWriteAPI=true; ' .
+ 'statement is included in the site\'s LocalSettings.php file', 'readonly');
+ }
+
protected function getAllowedParams() {
return array (
'format' => array (
header($errorCode, true, $httpRespCode);
$data = array (
- 'code' => $errorCode
+ 'code' => $errorCode,
+ 'info' => $description
);
ApiResult :: setContent($data, $this->makeHelpMsg());
$this->mResult->addValue(null, 'error', $data);
}
public function getVersion() {
-
- return array (
- parent :: getVersion(), __CLASS__ . ': $Id$', ApiFormatBase :: getBaseVersion());
+ $vers = array ();
+ $vers[] = __CLASS__ . ': $Id$';
+ $vers[] = ApiBase :: getBaseVersion();
+ $vers[] = ApiFormatBase :: getBaseVersion();
+ $vers[] = ApiQueryBase :: getBaseVersion();
+ return $vers;
}
}