| Index: trunk/phase3/includes/api/ApiQueryBase.php |
| — | — | @@ -98,7 +98,7 @@ |
| 99 | 99 | return str_replace('_', ' ', $key); |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | | - public function getVersion() { |
| | 102 | + public static function getBaseVersion() { |
| 103 | 103 | return __CLASS__ . ': $Id$'; |
| 104 | 104 | } |
| 105 | 105 | } |
| Index: trunk/phase3/includes/api/ApiQuery.php |
| — | — | @@ -331,8 +331,9 @@ |
| 332 | 332 | |
| 333 | 333 | public function getVersion() { |
| 334 | 334 | $psModule = new ApiPageSet($this); |
| 335 | | - $vers = $psModule->getVersion(); |
| | 335 | + $vers = array(); |
| 336 | 336 | $vers[] = __CLASS__ . ': $Id$'; |
| | 337 | + $vers[] = $psModule->getVersion(); |
| 337 | 338 | return $vers; |
| 338 | 339 | } |
| 339 | 340 | } |
| Index: trunk/phase3/includes/api/ApiQueryRevisions.php |
| — | — | @@ -99,9 +99,6 @@ |
| 100 | 100 | $showComment = true; |
| 101 | 101 | break; |
| 102 | 102 | case 'content' : |
| 103 | | - // todo: check the page count/limit when requesting content |
| 104 | | - //$this->validateLimit( 'content: (rvlimit*pages)+revids', |
| 105 | | - //$rvlimit * count($this->existingPageIds) + count($this->revIdsArray), 50, 200 ); |
| 106 | 103 | $tables[] = 'text'; |
| 107 | 104 | $conds[] = 'rev_text_id=old_id'; |
| 108 | 105 | $fields[] = 'old_id'; |
| — | — | @@ -127,7 +124,14 @@ |
| 128 | 125 | if ($rvendid !== 0 && isset ($rvend)) |
| 129 | 126 | $this->dieUsage('rvend and rvend cannot be used together', 'rv_badparams'); |
| 130 | 127 | |
| 131 | | - $options['ORDER BY'] = 'rev_timestamp' . ($dirNewer ? '' : ' DESC'); |
| | 128 | + // This code makes an assumption that sorting by rev_id and rev_timestamp produces |
| | 129 | + // the same result. This way users may request revisions starting at a given time, |
| | 130 | + // but to page through results use the rev_id returned after each page. |
| | 131 | + // Switching to rev_id removes the potential problem of having more than |
| | 132 | + // one row with the same timestamp for the same page. |
| | 133 | + // The order needs to be the same as start parameter to avoid SQL filesort. |
| | 134 | + $options['ORDER BY'] = ($rvstartid !== 0 ? 'rev_id' : 'rev_timestamp') . ($dirNewer ? '' : ' DESC'); |
| | 135 | + |
| 132 | 136 | $before = ($dirNewer ? '<=' : '>='); |
| 133 | 137 | $after = ($dirNewer ? '>=' : '<='); |
| 134 | 138 | |
| Index: trunk/phase3/includes/api/ApiBase.php |
| — | — | @@ -398,7 +398,9 @@ |
| 399 | 399 | return $this->mDBTime; |
| 400 | 400 | } |
| 401 | 401 | |
| 402 | | - public function getVersion() { |
| | 402 | + public abstract function getVersion(); |
| | 403 | + |
| | 404 | + public static function getBaseVersion() { |
| 403 | 405 | return __CLASS__ . ': $Id$'; |
| 404 | 406 | } |
| 405 | 407 | } |
| Index: trunk/phase3/includes/api/ApiQueryAllpages.php |
| — | — | @@ -127,7 +127,12 @@ |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | protected function getParamDescription() { |
| 131 | | - return array (); |
| | 131 | + return array ( |
| | 132 | + 'apfrom' => 'The page title to start enumerating from.', |
| | 133 | + 'apnamespace' => 'The namespace to enumerate. Default 0 (Main).', |
| | 134 | + 'apfilterredir' => 'Which pages to list: "all" (default), "redirects", or "nonredirects"', |
| | 135 | + 'aplimit' => 'How many total pages to return' |
| | 136 | + ); |
| 132 | 137 | } |
| 133 | 138 | |
| 134 | 139 | protected function getDescription() { |
| Index: trunk/phase3/includes/api/ApiFormatBase.php |
| — | — | @@ -142,6 +142,8 @@ |
| 143 | 143 | $text = ereg_replace("api\\.php\\?[^ ()<\n\t]+", '<a href="\\0">\\0</a>', $text); |
| 144 | 144 | // make strings inside * bold |
| 145 | 145 | $text = ereg_replace("\\*[^<>\n]+\\*", '<b>\\0</b>', $text); |
| | 146 | + // make strings inside $ italic |
| | 147 | + $text = ereg_replace("\\$[^<>\n]+\\$", '<b><i>\\0</i></b>', $text); |
| 146 | 148 | |
| 147 | 149 | return $text; |
| 148 | 150 | } |
| Index: trunk/phase3/includes/api/ApiMain.php |
| — | — | @@ -31,14 +31,15 @@ |
| 32 | 32 | |
| 33 | 33 | class ApiMain extends ApiBase { |
| 34 | 34 | |
| 35 | | - private $mPrinter, $mModules, $mModuleNames, $mFormats, $mFormatNames, $mApiStartTime, $mResult, $mShowVersions; |
| | 35 | + private $mPrinter, $mModules, $mModuleNames, $mFormats, $mFormatNames; |
| | 36 | + private $mApiStartTime, $mResult, $mShowVersions, $mEnableWrite; |
| 36 | 37 | |
| 37 | 38 | /** |
| 38 | 39 | * Constructor |
| 39 | 40 | * $apiStartTime - time of the originating call for profiling purposes |
| 40 | 41 | * $modules - an array of actions (keys) and classes that handle them (values) |
| 41 | 42 | */ |
| 42 | | - public function __construct($apiStartTime, $modules, $formats) { |
| | 43 | + public function __construct($apiStartTime, $modules, $formats, $enableWrite) { |
| 43 | 44 | // Special handling for the main module: $parent === $this |
| 44 | 45 | parent :: __construct($this); |
| 45 | 46 | |
| — | — | @@ -49,6 +50,7 @@ |
| 50 | 51 | $this->mApiStartTime = $apiStartTime; |
| 51 | 52 | $this->mResult = new ApiResult($this); |
| 52 | 53 | $this->mShowVersions = false; |
| | 54 | + $this->mEnableWrite = $enableWrite; |
| 53 | 55 | } |
| 54 | 56 | |
| 55 | 57 | public function & getResult() { |
| — | — | @@ -59,6 +61,12 @@ |
| 60 | 62 | return $this->mShowVersions; |
| 61 | 63 | } |
| 62 | 64 | |
| | 65 | + public function requestWriteMode() { |
| | 66 | + if (!$this->mEnableWrite) |
| | 67 | + $this->dieUsage('Editing of this site is disabled. Make sure the $wgEnableWriteAPI=true; ' . |
| | 68 | + 'statement is included in the site\'s LocalSettings.php file', 'readonly'); |
| | 69 | + } |
| | 70 | + |
| 63 | 71 | protected function getAllowedParams() { |
| 64 | 72 | return array ( |
| 65 | 73 | 'format' => array ( |
| — | — | @@ -190,9 +198,12 @@ |
| 191 | 199 | } |
| 192 | 200 | |
| 193 | 201 | public function getVersion() { |
| 194 | | - |
| 195 | | - return array ( |
| 196 | | - parent :: getVersion(), __CLASS__ . ': $Id$', ApiFormatBase :: getBaseVersion()); |
| | 202 | + $vers = array (); |
| | 203 | + $vers[] = __CLASS__ . ': $Id$'; |
| | 204 | + $vers[] = ApiBase :: getBaseVersion(); |
| | 205 | + $vers[] = ApiFormatBase :: getBaseVersion(); |
| | 206 | + $vers[] = ApiQueryBase :: getBaseVersion(); |
| | 207 | + return $vers; |
| 197 | 208 | } |
| 198 | 209 | } |
| 199 | 210 | |
| Index: trunk/phase3/includes/api/ApiPageSet.php |
| — | — | @@ -401,8 +401,7 @@ |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | public function getVersion() { |
| 405 | | - return array ( |
| 406 | | - parent :: getVersion(), __CLASS__ . ': $Id$'); |
| | 405 | + return __CLASS__ . ': $Id$'; |
| 407 | 406 | } |
| 408 | 407 | } |
| 409 | 408 | ?> |
| \ No newline at end of file |
| Index: trunk/phase3/api.php |
| — | — | @@ -103,7 +103,11 @@ |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | $wgAutoloadClasses = array_merge($wgAutoloadClasses, $wgApiAutoloadClasses); |
| 107 | | -$processor = new ApiMain($wgApiStartTime, $wgApiModules, $wgApiFormats); |
| | 107 | + |
| | 108 | +if (!isset($wgEnableWriteAPI)) |
| | 109 | + $wgEnableWriteAPI = false; // This should be 'true' later, once the api is stable. |
| | 110 | + |
| | 111 | +$processor = new ApiMain($wgApiStartTime, $wgApiModules, $wgApiFormats, $wgEnableWriteAPI); |
| 108 | 112 | $processor->execute(); |
| 109 | 113 | |
| 110 | 114 | wfProfileOut('api.php'); |