Index: trunk/extensions/AssertEdit/AssertEditApi.php |
— | — | @@ -0,0 +1,58 @@ |
| 2 | +<?php |
| 3 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 4 | + // Eclipse helper - will be ignored in production |
| 5 | + require_once ( 'ApiBase.php' ); |
| 6 | +} |
| 7 | + |
| 8 | +class AssertEditApi extends ApiBase |
| 9 | +{ |
| 10 | + public function __construct( $main, $action ) { |
| 11 | + parent :: __construct( $main, $action ); |
| 12 | + } |
| 13 | + |
| 14 | + public function execute() { |
| 15 | + $this->dieUsage( '', 'assertedit' ); |
| 16 | + } |
| 17 | + |
| 18 | + public function getDescription() { |
| 19 | + return 'Allows bots to make assertions. Can only be used during of editing'; |
| 20 | + } |
| 21 | + |
| 22 | + public function isReadMode() { |
| 23 | + return false; |
| 24 | + } |
| 25 | + |
| 26 | + public function shouldCheckMaxlag() { |
| 27 | + return false; |
| 28 | + } |
| 29 | + |
| 30 | + public function getParamDescription() { |
| 31 | + return array( |
| 32 | + 'user' => 'Verify that bot is logged in, to prevent anonymous edits.', |
| 33 | + 'bot' => 'Verify that bot is logged in and has a bot flag.', |
| 34 | + 'true' => 'Always true; nassert=true will fail if the extension is installed.', |
| 35 | + 'false' => 'Always false; assert=false will fail if the extension is installed.', |
| 36 | + 'exists' => 'Verify that page exists. Could be useful from other extensions, i.e. adding nassert=exists to the inputbox extension.', |
| 37 | + 'test' => 'Verify that this wiki allows random testing. Defaults to false, but can be overridden in LocalSettings.php.' |
| 38 | + ); |
| 39 | + } |
| 40 | + |
| 41 | + public function getPossibleErrors() { |
| 42 | + return array(); |
| 43 | + } |
| 44 | + |
| 45 | + public function getAllowedParams() { |
| 46 | + return array( |
| 47 | + 'user' => null, |
| 48 | + 'bot' => null, |
| 49 | + 'true' => null, |
| 50 | + 'false' => null, |
| 51 | + 'exists' => null, |
| 52 | + 'test' => null |
| 53 | + ); |
| 54 | + } |
| 55 | + |
| 56 | + public function getVersion() { |
| 57 | + return __CLASS__ . ': $Id: $'; |
| 58 | + } |
| 59 | +} |
Property changes on: trunk/extensions/AssertEdit/AssertEditApi.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 60 | + native |
Index: trunk/extensions/AssertEdit/AssertEdit.php |
— | — | @@ -32,6 +32,9 @@ |
33 | 33 | $wgHooks['AlternateEdit'][] = 'efAssertEditHook'; |
34 | 34 | $wgHooks['APIEditBeforeSave'][] = 'efAssertApiEditHook'; |
35 | 35 | |
| 36 | +$wgAutoloadClasses['AssertEditApi'] = $dir . "AssertEditApi.php"; |
| 37 | +$wgAPIModules['assertedit'] = 'AssertEditApi'; |
| 38 | + |
36 | 39 | function efAssertEditHook( $editpage ) { |
37 | 40 | global $wgOut, $wgRequest; |
38 | 41 | |