Index: trunk/extensions/CustomUserSignup/CustomUserSignup.i18n.php |
— | — | @@ -1,4 +1,11 @@ |
2 | 2 | <?php |
| 3 | +/** |
| 4 | + * Internationalization file for the CustomUserSignup extension. |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
| 9 | + |
3 | 10 | $messages = array(); |
4 | 11 | |
5 | 12 | /** English |
Index: trunk/extensions/CustomUserSignup/CustomUserSignup.php |
— | — | @@ -1,10 +1,24 @@ |
2 | 2 | <?php |
| 3 | +/** |
| 4 | + * CustomUserSignup extension -- allows for customizable messages during the |
| 5 | + * account creation process |
| 6 | + * |
| 7 | + * @file |
| 8 | + * @ingroup Extensions |
| 9 | + * @version 0.1.0 |
| 10 | + * @author Nimish Gautam |
| 11 | + * @link http://www.mediawiki.org/wiki/Extension:CustomUserSignup Documentation |
| 12 | + */ |
| 13 | + |
| 14 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 15 | + die( 'This is not a valid entry point to MediaWiki.' ); |
| 16 | +} |
| 17 | + |
| 18 | +// Extension credits that will show up on Special:Version |
3 | 19 | $wgExtensionCredits['other'][] = array( |
4 | 20 | 'path' => __FILE__, |
5 | 21 | 'name' => 'CustomUserSignup', |
6 | | - 'author' => array( |
7 | | - 'Nimish Gautam', |
8 | | - ), |
| 22 | + 'author' => 'Nimish Gautam', |
9 | 23 | 'version' => '0.1.0', |
10 | 24 | 'descriptionmsg' => 'customusersignup-desc', |
11 | 25 | 'url' => 'http://www.mediawiki.org/wiki/Extension:CustomUserSignup' |
— | — | @@ -19,5 +33,5 @@ |
20 | 34 | |
21 | 35 | // Hooks |
22 | 36 | $wgHooks['UserCreateForm'][] = 'CustomUserSignupHooks::userCreateForm'; |
23 | | -$wgHooks['UserLoginForm'][] = 'CustomUserSignupHooks::userCreateForm'; |
| 37 | +$wgHooks['UserLoginForm'][] = 'CustomUserSignupHooks::userCreateForm'; |
24 | 38 | $wgHooks['BeforeWelcomeCreation'][] = 'CustomUserSignupHooks::welcomeScreen'; |
Index: trunk/extensions/CustomUserSignup/CustomUserSignup.hooks.php |
— | — | @@ -7,42 +7,50 @@ |
8 | 8 | */ |
9 | 9 | |
10 | 10 | class CustomUserSignupHooks { |
11 | | - |
12 | | - public static function userCreateForm(&$template){ |
13 | | - if(isset($_GET["campaign"])){ |
14 | | - $campaign = $_GET["campaign"]; |
| 11 | + |
| 12 | + public static function userCreateForm( &$template ) { |
| 13 | + if( isset( $_GET['campaign'] ) ) { |
| 14 | + $campaign = $_GET['campaign']; |
15 | 15 | $newTemplate; |
16 | | - if(get_class($template) == "UserloginTemplate"){ |
| 16 | + if( get_class( $template ) == 'UserloginTemplate' ) { |
17 | 17 | $newTemplate = new CustomUserloginTemplate(); |
18 | | - $template->data["action"] = "{$template->data["action"]}&campaign=$campaign"; |
19 | | - $template->data["link"] = |
20 | | - preg_replace("/type\=signup/", "campaign=$campaign&type=signup", $template->data["link"]); |
21 | | - } |
22 | | - else if(get_class($template) == "UsercreateTemplate"){ |
| 18 | + $template->data['action'] = "{$template->data['action']}&campaign=$campaign"; |
| 19 | + $template->data['link'] = |
| 20 | + preg_replace( |
| 21 | + '/type\=signup/', |
| 22 | + "campaign=$campaign&type=signup", |
| 23 | + $template->data['link'] |
| 24 | + ); |
| 25 | + } elseif( get_class( $template ) == 'UsercreateTemplate' ) { |
23 | 26 | $newTemplate = new CustomUsercreateTemplate(); |
24 | | - $template->data["action"] = "{$template->data["action"]}&campaign=$campaign"; |
25 | | - $template->data["link"] = |
26 | | - preg_replace("/type\=login\&/", "type=login&campaign=$campaign&", $template->data["link"]); |
| 27 | + $template->data['action'] = "{$template->data['action']}&campaign=$campaign"; |
| 28 | + $template->data['link'] = |
| 29 | + preg_replace( |
| 30 | + '/type\=login\&/', |
| 31 | + "type=login&campaign=$campaign&", |
| 32 | + $template->data['link'] |
| 33 | + ); |
| 34 | + } else { |
| 35 | + return true; |
27 | 36 | } |
28 | | - else return true; |
29 | | - |
| 37 | + |
30 | 38 | $newTemplate->data = $template->data; |
31 | 39 | $newTemplate->translator = $template->translator; |
32 | 40 | $template = $newTemplate; |
33 | 41 | } |
34 | | - |
35 | | - return true; |
| 42 | + |
| 43 | + return true; |
36 | 44 | } |
37 | | - |
38 | | - public static function welcomeScreen(&$welcome_creation_msg, &$injected_html){ |
39 | | - if(isset($_GET["campaign"])){ |
40 | | - $campaign = $_GET["campaign"]; |
41 | | - |
42 | | - if(wfMsg( "customusertemplate-$campaign-welcomecreation") != "<customusertemplate-$campaign-welcomecreation>"){ |
43 | | - $welcome_creation_msg = "customusertemplate-$campaign-welcomecreation"; |
| 45 | + |
| 46 | + public static function welcomeScreen( &$welcomeCreationMsg, &$injected_html ) { |
| 47 | + if( isset( $_GET['campaign'] ) ) { |
| 48 | + $campaign = $_GET['campaign']; |
| 49 | + |
| 50 | + if( wfMsg( "customusertemplate-$campaign-welcomecreation" ) != "<customusertemplate-$campaign-welcomecreation>" ) { |
| 51 | + $welcomeCreationMsg = "customusertemplate-$campaign-welcomecreation"; |
44 | 52 | } |
45 | | - } |
| 53 | + } |
46 | 54 | return true; |
47 | 55 | } |
48 | | - |
| 56 | + |
49 | 57 | } |
\ No newline at end of file |
Index: trunk/extensions/CustomUserSignup/CustomUserTemplate.php |
— | — | @@ -1,37 +1,35 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -class CustomUserloginTemplate extends UserloginTemplate{ |
5 | | - |
| 4 | +class CustomUserloginTemplate extends UserloginTemplate { |
| 5 | + |
6 | 6 | protected $campaign = null; |
7 | | - |
8 | | - function __construct(){ |
| 7 | + |
| 8 | + function __construct() { |
9 | 9 | parent::__construct(); |
10 | | - if(isset($_GET["campaign"])){ |
11 | | - preg_match("/[A-Za-z0-9]+/", $_GET["campaign"], $matches); |
| 10 | + if( isset( $_GET['campaign'] ) ) { |
| 11 | + preg_match( '/[A-Za-z0-9]+/', $_GET['campaign'], $matches ); |
12 | 12 | $this->campaign = $matches[0]; |
13 | | - } |
| 13 | + } |
14 | 14 | } |
15 | | - |
| 15 | + |
16 | 16 | function msg( $str ) { |
17 | | - //doesn't exist |
18 | | - if($this->campaign && (wfMsg( "customusertemplate-{$this->campaign}-$str" ) == "<customusertemplate-{$this->campaign}-$str>") ){ |
| 17 | + // doesn't exist |
| 18 | + if( $this->campaign && ( wfMsg( "customusertemplate-{$this->campaign}-$str" ) == "<customusertemplate-{$this->campaign}-$str>" ) ) { |
19 | 19 | parent::msg( $str ); |
| 20 | + } else { |
| 21 | + $this->msgWikiCustom( "customusertemplate-{$this->campaign}-$str" ); |
20 | 22 | } |
21 | | - else{ |
22 | | - $this->msgWikiCustom( "customusertemplate-{$this->campaign}-$str" ); |
23 | | - } |
24 | 23 | } |
25 | 24 | |
26 | 25 | function msgWiki( $str ) { |
27 | | - //doesn't exist |
28 | | - if($this->campaign && (wfMsg( "customusertemplate-{$this->campaign}-$str" ) == "<customusertemplate-{$this->campaign}-$str>") ){ |
| 26 | + // doesn't exist |
| 27 | + if( $this->campaign && ( wfMsg( "customusertemplate-{$this->campaign}-$str" ) == "<customusertemplate-{$this->campaign}-$str>" ) ) { |
29 | 28 | parent::msgWiki( $str ); |
30 | | - } |
31 | | - else{ |
| 29 | + } else { |
32 | 30 | $this->msgWikiCustom( "customusertemplate-{$this->campaign}-$str" ); |
33 | 31 | } |
34 | 32 | } |
35 | | - |
| 33 | + |
36 | 34 | function msgWikiCustom( $str ) { |
37 | 35 | global $wgParser, $wgOut; |
38 | 36 | |
— | — | @@ -40,41 +38,38 @@ |
41 | 39 | $wgOut->parserOptions(), true ); |
42 | 40 | echo $parserOutput->getText(); |
43 | 41 | } |
44 | | - |
| 42 | + |
45 | 43 | } |
46 | 44 | |
| 45 | +class CustomUsercreateTemplate extends UsercreateTemplate { |
| 46 | + protected $campaign = null; |
47 | 47 | |
48 | | -class CustomUsercreateTemplate extends UsercreateTemplate{ |
49 | | -protected $campaign = null; |
50 | | - |
51 | | - function __construct(){ |
| 48 | + function __construct() { |
52 | 49 | parent::__construct(); |
53 | | - if(isset($_GET["campaign"])){ |
54 | | - preg_match("/[A-Za-z0-9]+/", $_GET["campaign"], $matches); |
| 50 | + if( isset( $_GET['campaign'] ) ) { |
| 51 | + preg_match( '/[A-Za-z0-9]+/', $_GET['campaign'], $matches ); |
55 | 52 | $this->campaign = $matches[0]; |
56 | | - } |
| 53 | + } |
57 | 54 | } |
58 | | - |
| 55 | + |
59 | 56 | function msg( $str ) { |
60 | | - //doesn't exist |
61 | | - if($this->campaign && (wfMsg( "customusertemplate-{$this->campaign}-$str" ) == "<customusertemplate-{$this->campaign}-$str>") ){ |
| 57 | + // doesn't exist |
| 58 | + if( $this->campaign && ( wfMsg( "customusertemplate-{$this->campaign}-$str" ) == "<customusertemplate-{$this->campaign}-$str>" ) ) { |
62 | 59 | parent::msg( $str ); |
| 60 | + } else { |
| 61 | + $this->msgWikiCustom( "customusertemplate-{$this->campaign}-$str" ); |
63 | 62 | } |
64 | | - else{ |
65 | | - $this->msgWikiCustom( "customusertemplate-{$this->campaign}-$str" ); |
66 | | - } |
67 | 63 | } |
68 | 64 | |
69 | 65 | function msgWiki( $str ) { |
70 | | - //doesn't exist |
71 | | - if($this->campaign && (wfMsg( "customusertemplate-{$this->campaign}-$str" ) == "<customusertemplate-{$this->campaign}-$str>") ){ |
| 66 | + // doesn't exist |
| 67 | + if( $this->campaign && (wfMsg( "customusertemplate-{$this->campaign}-$str" ) == "<customusertemplate-{$this->campaign}-$str>" ) ) { |
72 | 68 | parent::msgWiki( $str ); |
73 | | - } |
74 | | - else{ |
| 69 | + } else { |
75 | 70 | $this->msgWikiCustom( "customusertemplate-{$this->campaign}-$str" ); |
76 | 71 | } |
77 | 72 | } |
78 | | - |
| 73 | + |
79 | 74 | function msgWikiCustom( $str ) { |
80 | 75 | global $wgParser, $wgOut; |
81 | 76 | |