}
$wgAutoloadClasses = array_merge($wgAutoloadClasses, $wgApiAutoloadClasses);
-$processor = new ApiMain($wgApiStartTime, $wgApiModules, $wgApiFormats);
+
+if (!isset($wgEnableWriteAPI))
+ $wgEnableWriteAPI = false; // This should be 'true' later, once the api is stable.
+
+$processor = new ApiMain($wgApiStartTime, $wgApiModules, $wgApiFormats, $wgEnableWriteAPI);
$processor->execute();
wfProfileOut('api.php');
return $this->mDBTime;
}
- public function getVersion() {
+ public abstract function getVersion();
+
+ public static function getBaseVersion() {
return __CLASS__ . ': $Id$';
}
}
$text = ereg_replace("api\\.php\\?[^ ()<\n\t]+", '<a href="\\0">\\0</a>', $text);
// make strings inside * bold
$text = ereg_replace("\\*[^<>\n]+\\*", '<b>\\0</b>', $text);
+ // make strings inside $ italic
+ $text = ereg_replace("\\$[^<>\n]+\\$", '<b><i>\\0</i></b>', $text);
return $text;
}
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);
$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 (
}
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;
}
}
}
public function getVersion() {
- return array (
- parent :: getVersion(), __CLASS__ . ': $Id$');
+ return __CLASS__ . ': $Id$';
}
}
?>
\ No newline at end of file
public function getVersion() {
$psModule = new ApiPageSet($this);
- $vers = $psModule->getVersion();
+ $vers = array();
$vers[] = __CLASS__ . ': $Id$';
+ $vers[] = $psModule->getVersion();
return $vers;
}
}
}
protected function getParamDescription() {
- return array ();
+ 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'
+ );
}
protected function getDescription() {
return str_replace('_', ' ', $key);
}
- public function getVersion() {
+ public static function getBaseVersion() {
return __CLASS__ . ': $Id$';
}
}
$showComment = true;
break;
case 'content' :
- // todo: check the page count/limit when requesting content
- //$this->validateLimit( 'content: (rvlimit*pages)+revids',
- //$rvlimit * count($this->existingPageIds) + count($this->revIdsArray), 50, 200 );
$tables[] = 'text';
$conds[] = 'rev_text_id=old_id';
$fields[] = 'old_id';
if ($rvendid !== 0 && isset ($rvend))
$this->dieUsage('rvend and rvend cannot be used together', 'rv_badparams');
- $options['ORDER BY'] = 'rev_timestamp' . ($dirNewer ? '' : ' DESC');
+ // 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,
+ // but to page through results use the rev_id returned after each page.
+ // 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');
+
$before = ($dirNewer ? '<=' : '>=');
$after = ($dirNewer ? '>=' : '<=');