mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-11-24 00:04:15 +00:00
Reorganise files in ConfirmEdit
This commit is contained in:
parent
0c92596494
commit
1bbd72e5fd
|
@ -1,75 +1,5 @@
|
|||
<?php
|
||||
|
||||
class ConfirmEditHooks {
|
||||
static function getInstance() {
|
||||
global $wgCaptcha, $wgCaptchaClass;
|
||||
static $done = false;
|
||||
if ( !$done ) {
|
||||
$done = true;
|
||||
$wgCaptcha = new $wgCaptchaClass;
|
||||
}
|
||||
return $wgCaptcha;
|
||||
}
|
||||
|
||||
static function confirmEdit( $editPage, $newtext, $section ) {
|
||||
return self::getInstance()->confirmEdit( $editPage, $newtext, $section );
|
||||
}
|
||||
|
||||
static function confirmEditMerged( $editPage, $newtext ) {
|
||||
return self::getInstance()->confirmEditMerged( $editPage, $newtext );
|
||||
}
|
||||
|
||||
static function confirmEditAPI( $editPage, $newtext, &$resultArr ) {
|
||||
return self::getInstance()->confirmEditAPI( $editPage, $newtext, $resultArr );
|
||||
}
|
||||
|
||||
static function injectUserCreate( &$template ) {
|
||||
return self::getInstance()->injectUserCreate( $template );
|
||||
}
|
||||
|
||||
static function confirmUserCreate( $u, &$message ) {
|
||||
return self::getInstance()->confirmUserCreate( $u, $message );
|
||||
}
|
||||
|
||||
static function triggerUserLogin( $user, $password, $retval ) {
|
||||
return self::getInstance()->triggerUserLogin( $user, $password, $retval );
|
||||
}
|
||||
|
||||
static function injectUserLogin( &$template ) {
|
||||
return self::getInstance()->injectUserLogin( $template );
|
||||
}
|
||||
|
||||
static function confirmUserLogin( $u, $pass, &$retval ) {
|
||||
return self::getInstance()->confirmUserLogin( $u, $pass, $retval );
|
||||
}
|
||||
|
||||
static function injectEmailUser( &$form ) {
|
||||
return self::getInstance()->injectEmailUser( $form );
|
||||
}
|
||||
|
||||
static function confirmEmailUser( $from, $to, $subject, $text, &$error ) {
|
||||
return self::getInstance()->confirmEmailUser( $from, $to, $subject, $text, $error );
|
||||
}
|
||||
}
|
||||
|
||||
class CaptchaSpecialPage extends UnlistedSpecialPage {
|
||||
public function __construct(){
|
||||
parent::__construct( 'Captcha' );
|
||||
}
|
||||
function execute( $par ) {
|
||||
$this->setHeaders();
|
||||
$instance = ConfirmEditHooks::getInstance();
|
||||
switch( $par ) {
|
||||
case "image":
|
||||
if ( method_exists( $instance, 'showImage' ) )
|
||||
return $instance->showImage();
|
||||
case "help":
|
||||
default:
|
||||
return $instance->showHelp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SimpleCaptcha {
|
||||
function __construct() {
|
||||
global $wgCaptchaStorageClass;
|
||||
|
@ -748,52 +678,3 @@ class SimpleCaptcha {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
class CaptchaSessionStore {
|
||||
function store( $index, $info ) {
|
||||
$_SESSION['captcha' . $info['index']] = $info;
|
||||
}
|
||||
|
||||
function retrieve( $index ) {
|
||||
if ( isset( $_SESSION['captcha' . $index] ) ) {
|
||||
return $_SESSION['captcha' . $index];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function clear( $index ) {
|
||||
unset( $_SESSION['captcha' . $index] );
|
||||
}
|
||||
|
||||
function cookiesNeeded() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class CaptchaCacheStore {
|
||||
function store( $index, $info ) {
|
||||
global $wgMemc, $wgCaptchaSessionExpiration;
|
||||
$wgMemc->set( wfMemcKey( 'captcha', $index ), $info,
|
||||
$wgCaptchaSessionExpiration );
|
||||
}
|
||||
|
||||
function retrieve( $index ) {
|
||||
global $wgMemc;
|
||||
$info = $wgMemc->get( wfMemcKey( 'captcha', $index ) );
|
||||
if ( $info ) {
|
||||
return $info;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function clear( $index ) {
|
||||
global $wgMemc;
|
||||
$wgMemc->delete( wfMemcKey( 'captcha', $index ) );
|
||||
}
|
||||
|
||||
function cookiesNeeded() {
|
||||
return false;
|
||||
}
|
||||
}
|
51
CaptchaStore.php
Normal file
51
CaptchaStore.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
class CaptchaSessionStore {
|
||||
|
||||
function store( $index, $info ) {
|
||||
$_SESSION['captcha' . $info['index']] = $info;
|
||||
}
|
||||
|
||||
function retrieve( $index ) {
|
||||
if ( isset( $_SESSION['captcha' . $index] ) ) {
|
||||
return $_SESSION['captcha' . $index];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function clear( $index ) {
|
||||
unset( $_SESSION['captcha' . $index] );
|
||||
}
|
||||
|
||||
function cookiesNeeded() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class CaptchaCacheStore {
|
||||
|
||||
function store( $index, $info ) {
|
||||
global $wgMemc, $wgCaptchaSessionExpiration;
|
||||
$wgMemc->set( wfMemcKey( 'captcha', $index ), $info,
|
||||
$wgCaptchaSessionExpiration );
|
||||
}
|
||||
|
||||
function retrieve( $index ) {
|
||||
global $wgMemc;
|
||||
$info = $wgMemc->get( wfMemcKey( 'captcha', $index ) );
|
||||
if ( $info ) {
|
||||
return $info;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function clear( $index ) {
|
||||
global $wgMemc;
|
||||
$wgMemc->delete( wfMemcKey( 'captcha', $index ) );
|
||||
}
|
||||
|
||||
function cookiesNeeded() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -200,12 +200,11 @@ $wgHooks['EmailUser'][] = 'ConfirmEditHooks::confirmEmailUser';
|
|||
# Register API hook
|
||||
$wgHooks['APIEditBeforeSave'][] = 'ConfirmEditHooks::confirmEditAPI';
|
||||
|
||||
$wgAutoloadClasses['ConfirmEditHooks']
|
||||
= $wgAutoloadClasses['SimpleCaptcha']
|
||||
= $wgAutoloadClasses['CaptchaSessionStore']
|
||||
= $wgAutoloadClasses['CaptchaCacheStore']
|
||||
= $wgAutoloadClasses['CaptchaSpecialPage']
|
||||
= "$wgConfirmEditIP/ConfirmEdit_body.php";
|
||||
$wgAutoloadClasses['ConfirmEditHooks'] = "$wgConfirmEditIP/ConfirmEditHooks.php";
|
||||
$wgAutoloadClasses['SimpleCaptcha']= "$wgConfirmEditIP/Captcha.php";
|
||||
$wgAutoloadClasses['CaptchaSessionStore']= "$wgConfirmEditIP/CaptchaStore.php";
|
||||
$wgAutoloadClasses['CaptchaCacheStore']= "$wgConfirmEditIP/CaptchaStore.php";
|
||||
$wgAutoloadClasses['CaptchaSpecialPage'] = "$wgConfirmEditIP/ConfirmEditHooks.php";
|
||||
|
||||
/**
|
||||
* Set up $wgWhitelistRead
|
||||
|
|
72
ConfirmEditHooks.php
Normal file
72
ConfirmEditHooks.php
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
|
||||
class ConfirmEditHooks {
|
||||
static function getInstance() {
|
||||
global $wgCaptcha, $wgCaptchaClass;
|
||||
static $done = false;
|
||||
if ( !$done ) {
|
||||
$done = true;
|
||||
$wgCaptcha = new $wgCaptchaClass;
|
||||
}
|
||||
return $wgCaptcha;
|
||||
}
|
||||
|
||||
static function confirmEdit( $editPage, $newtext, $section ) {
|
||||
return self::getInstance()->confirmEdit( $editPage, $newtext, $section );
|
||||
}
|
||||
|
||||
static function confirmEditMerged( $editPage, $newtext ) {
|
||||
return self::getInstance()->confirmEditMerged( $editPage, $newtext );
|
||||
}
|
||||
|
||||
static function confirmEditAPI( $editPage, $newtext, &$resultArr ) {
|
||||
return self::getInstance()->confirmEditAPI( $editPage, $newtext, $resultArr );
|
||||
}
|
||||
|
||||
static function injectUserCreate( &$template ) {
|
||||
return self::getInstance()->injectUserCreate( $template );
|
||||
}
|
||||
|
||||
static function confirmUserCreate( $u, &$message ) {
|
||||
return self::getInstance()->confirmUserCreate( $u, $message );
|
||||
}
|
||||
|
||||
static function triggerUserLogin( $user, $password, $retval ) {
|
||||
return self::getInstance()->triggerUserLogin( $user, $password, $retval );
|
||||
}
|
||||
|
||||
static function injectUserLogin( &$template ) {
|
||||
return self::getInstance()->injectUserLogin( $template );
|
||||
}
|
||||
|
||||
static function confirmUserLogin( $u, $pass, &$retval ) {
|
||||
return self::getInstance()->confirmUserLogin( $u, $pass, $retval );
|
||||
}
|
||||
|
||||
static function injectEmailUser( &$form ) {
|
||||
return self::getInstance()->injectEmailUser( $form );
|
||||
}
|
||||
|
||||
static function confirmEmailUser( $from, $to, $subject, $text, &$error ) {
|
||||
return self::getInstance()->confirmEmailUser( $from, $to, $subject, $text, $error );
|
||||
}
|
||||
}
|
||||
|
||||
class CaptchaSpecialPage extends UnlistedSpecialPage {
|
||||
public function __construct(){
|
||||
parent::__construct( 'Captcha' );
|
||||
}
|
||||
function execute( $par ) {
|
||||
$this->setHeaders();
|
||||
$instance = ConfirmEditHooks::getInstance();
|
||||
switch( $par ) {
|
||||
case "image":
|
||||
if ( method_exists( $instance, 'showImage' ) )
|
||||
return $instance->showImage();
|
||||
case "help":
|
||||
default:
|
||||
return $instance->showHelp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in a new issue