Reorganise files in ConfirmEdit
[toast/cookiecaptcha.git] / ConfirmEditHooks.php
1 <?php
2
3 class ConfirmEditHooks {
4         static function getInstance() {
5                 global $wgCaptcha, $wgCaptchaClass;
6                 static $done = false;
7                 if ( !$done ) {
8                         $done = true;
9                         $wgCaptcha = new $wgCaptchaClass;
10                 }
11                 return $wgCaptcha;
12         }
13
14         static function confirmEdit( $editPage, $newtext, $section ) {
15                 return self::getInstance()->confirmEdit( $editPage, $newtext, $section );
16         }
17
18         static function confirmEditMerged( $editPage, $newtext ) {
19                 return self::getInstance()->confirmEditMerged( $editPage, $newtext );
20         }
21
22         static function confirmEditAPI( $editPage, $newtext, &$resultArr ) {
23                 return self::getInstance()->confirmEditAPI( $editPage, $newtext, $resultArr );
24         }
25
26         static function injectUserCreate( &$template ) {
27                 return self::getInstance()->injectUserCreate( $template );
28         }
29
30         static function confirmUserCreate( $u, &$message ) {
31                 return self::getInstance()->confirmUserCreate( $u, $message );
32         }
33
34         static function triggerUserLogin( $user, $password, $retval ) {
35                 return self::getInstance()->triggerUserLogin( $user, $password, $retval );
36         }
37
38         static function injectUserLogin( &$template ) {
39                 return self::getInstance()->injectUserLogin( $template );
40         }
41
42         static function confirmUserLogin( $u, $pass, &$retval ) {
43                 return self::getInstance()->confirmUserLogin( $u, $pass, $retval );
44         }
45
46         static function injectEmailUser( &$form ) {
47                 return self::getInstance()->injectEmailUser( $form );
48         }
49
50         static function confirmEmailUser( $from, $to, $subject, $text, &$error ) {
51                 return self::getInstance()->confirmEmailUser( $from, $to, $subject, $text, $error );
52         }
53 }
54
55 class CaptchaSpecialPage extends UnlistedSpecialPage {
56         public function __construct(){
57                 parent::__construct( 'Captcha' );
58         }
59         function execute( $par ) {
60                 $this->setHeaders();
61                 $instance = ConfirmEditHooks::getInstance();
62                 switch( $par ) {
63                 case "image":
64                         if ( method_exists( $instance, 'showImage' ) )
65                                 return $instance->showImage();
66                 case "help":
67                 default:
68                         return $instance->showHelp();
69                 }
70         }
71 }
72