mediawiki-extensions-Confir.../ConfirmEditHooks.php

106 lines
2.9 KiB
PHP
Raw Normal View History

2011-04-23 11:44:47 +00:00
<?php
class ConfirmEditHooks {
/**
* Get the global Captcha instance
*
* @return SimpleCaptcha
*/
2011-04-23 11:44:47 +00:00
static function getInstance() {
global $wgCaptcha, $wgCaptchaClass;
2011-04-23 11:44:47 +00:00
static $done = false;
2011-04-23 11:44:47 +00:00
if ( !$done ) {
$done = true;
$wgCaptcha = new $wgCaptchaClass;
}
2011-04-23 11:44:47 +00:00
return $wgCaptcha;
}
static function confirmEditMerged( $context, $content, $status, $summary, $user, $minorEdit ) {
return self::getInstance()->confirmEditMerged( $context, $content, $status, $summary,
$user, $minorEdit );
2011-04-23 11:44:47 +00:00
}
static function confirmEditPage( $editpage, $buttons, $tabindex ) {
self::getInstance()->editShowCaptcha( $editpage );
}
2011-04-23 11:44:47 +00:00
static function confirmEditAPI( $editPage, $newtext, &$resultArr ) {
return self::getInstance()->confirmEditAPI( $editPage, $newtext, $resultArr );
}
static function showEditFormFields( &$editPage, &$out ) {
return self::getInstance()->showEditFormFields( $editPage, $out );
}
static function addNewAccountApiForm( $apiModule, $loginForm ) {
return self::getInstance()->addNewAccountApiForm( $apiModule, $loginForm );
}
static function addNewAccountApiResult( $apiModule, $loginPage, &$result ) {
return self::getInstance()->addNewAccountApiResult( $apiModule, $loginPage, $result );
}
2011-04-23 11:44:47 +00:00
static function injectUserCreate( &$template ) {
return self::getInstance()->injectUserCreate( $template );
}
static function confirmUserCreate( $u, &$message, &$status = null ) {
return self::getInstance()->confirmUserCreate( $u, $message, $status );
2011-04-23 11:44:47 +00:00
}
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 );
}
// Default $flags to 1 for backwards-compatible behavior
public static function APIGetAllowedParams( &$module, &$params, $flags = 1 ) {
return self::getInstance()->APIGetAllowedParams( $module, $params, $flags );
}
public static function APIGetParamDescription( &$module, &$desc ) {
return self::getInstance()->APIGetParamDescription( $module, $desc );
}
2011-04-23 11:44:47 +00:00
}
class CaptchaSpecialPage extends UnlistedSpecialPage {
public function __construct() {
2011-04-23 11:44:47 +00:00
parent::__construct( 'Captcha' );
}
2011-04-23 11:44:47 +00:00
function execute( $par ) {
$this->setHeaders();
2011-04-23 11:44:47 +00:00
$instance = ConfirmEditHooks::getInstance();
2011-04-23 11:44:47 +00:00
switch( $par ) {
case "image":
if ( method_exists( $instance, 'showImage' ) ) {
return $instance->showImage();
}
case "help":
default:
return $instance->showHelp();
2011-04-23 11:44:47 +00:00
}
}
}