Index: trunk/extensions/CustomUserSignup/CustomUserSignup.i18n.php |
— | — | @@ -0,0 +1,10 @@ |
| 2 | +<?php |
| 3 | +$messages = array(); |
| 4 | + |
| 5 | +/** English |
| 6 | + * @author Nimish Gautam |
| 7 | + */ |
| 8 | +$messages['en'] = array( |
| 9 | + 'customusersignup' => 'Custom User Signup', |
| 10 | + 'customusersignup-desc' => 'Allows for customizable messages during the account creation process', |
| 11 | +); |
\ No newline at end of file |
Property changes on: trunk/extensions/CustomUserSignup/CustomUserSignup.i18n.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 12 | + native |
Index: trunk/extensions/CustomUserSignup/CustomUserSignup.php |
— | — | @@ -0,0 +1,23 @@ |
| 2 | +<?php |
| 3 | +$wgExtensionCredits['other'][] = array( |
| 4 | + 'path' => __FILE__, |
| 5 | + 'name' => 'CustomUserSignup', |
| 6 | + 'author' => array( |
| 7 | + 'Nimish Gautam', |
| 8 | + ), |
| 9 | + 'version' => '0.1.0', |
| 10 | + 'descriptionmsg' => 'customusersignup-desc', |
| 11 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:CustomUserSignup' |
| 12 | +); |
| 13 | + |
| 14 | +// Autoloading |
| 15 | +$dir = dirname( __FILE__ ) . '/'; |
| 16 | +$wgAutoloadClasses['CustomUserSignupHooks'] = $dir . 'CustomUserSignup.hooks.php'; |
| 17 | +$wgAutoloadClasses['CustomUserloginTemplate'] = $dir . 'CustomUserTemplate.php'; |
| 18 | +$wgAutoloadClasses['CustomUsercreateTemplate'] = $dir . 'CustomUserTemplate.php'; |
| 19 | +$wgExtensionMessagesFiles['CustomUserSignup'] = $dir . 'CustomUserSignup.i18n.php'; |
| 20 | + |
| 21 | +// Hooks |
| 22 | +$wgHooks['UserCreateForm'][] = 'CustomUserSignupHooks::userCreateForm'; |
| 23 | +$wgHooks['UserLoginForm'][] = 'CustomUserSignupHooks::userCreateForm'; |
| 24 | +$wgHooks['BeforeWelcomeCreation'][] = 'CustomUserSignupHooks::welcomeScreen'; |
Property changes on: trunk/extensions/CustomUserSignup/CustomUserSignup.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 25 | + native |
Index: trunk/extensions/CustomUserSignup/CustomUserSignup.hooks.php |
— | — | @@ -0,0 +1,48 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Hooks for CustomUserSignup |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
| 9 | + |
| 10 | +class CustomUserSignupHooks { |
| 11 | + |
| 12 | + public static function userCreateForm(&$template){ |
| 13 | + if(isset($_GET["campaign"])){ |
| 14 | + $campaign = $_GET["campaign"]; |
| 15 | + $newTemplate; |
| 16 | + if(get_class($template) == "UserloginTemplate"){ |
| 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"){ |
| 23 | + $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 | + } |
| 28 | + else return true; |
| 29 | + |
| 30 | + $newTemplate->data = $template->data; |
| 31 | + $newTemplate->translator = $template->translator; |
| 32 | + $template = $newTemplate; |
| 33 | + } |
| 34 | + |
| 35 | + return true; |
| 36 | + } |
| 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"; |
| 44 | + } |
| 45 | + } |
| 46 | + return true; |
| 47 | + } |
| 48 | + |
| 49 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/CustomUserSignup/CustomUserSignup.hooks.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 50 | + native |
Index: trunk/extensions/CustomUserSignup/CustomUserTemplate.php |
— | — | @@ -0,0 +1,86 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +class CustomUserloginTemplate extends UserloginTemplate{ |
| 5 | + |
| 6 | + protected $campaign = null; |
| 7 | + |
| 8 | + function __construct(){ |
| 9 | + parent::__construct(); |
| 10 | + if(isset($_GET["campaign"])){ |
| 11 | + preg_match("/[A-Za-z0-9]+/", $_GET["campaign"], $matches); |
| 12 | + $this->campaign = $matches[0]; |
| 13 | + } |
| 14 | + } |
| 15 | + |
| 16 | + function msg( $str ) { |
| 17 | + //doesn't exist |
| 18 | + if($this->campaign && (wfMsg( "customusertemplate-{$this->campaign}-$str" ) == "<customusertemplate-{$this->campaign}-$str>") ){ |
| 19 | + parent::msg( $str ); |
| 20 | + } |
| 21 | + else{ |
| 22 | + $this->msgWikiCustom( "customusertemplate-{$this->campaign}-$str" ); |
| 23 | + } |
| 24 | + } |
| 25 | + |
| 26 | + function msgWiki( $str ) { |
| 27 | + //doesn't exist |
| 28 | + if($this->campaign && (wfMsg( "customusertemplate-{$this->campaign}-$str" ) == "<customusertemplate-{$this->campaign}-$str>") ){ |
| 29 | + parent::msgWiki( $str ); |
| 30 | + } |
| 31 | + else{ |
| 32 | + $this->msgWikiCustom( "customusertemplate-{$this->campaign}-$str" ); |
| 33 | + } |
| 34 | + } |
| 35 | + |
| 36 | + function msgWikiCustom( $str ) { |
| 37 | + global $wgParser, $wgOut; |
| 38 | + |
| 39 | + $text = $this->translator->translate( $str ); |
| 40 | + $parserOutput = $wgParser->parse( $text, $wgOut->getTitle(), |
| 41 | + $wgOut->parserOptions(), true ); |
| 42 | + echo $parserOutput->getText(); |
| 43 | + } |
| 44 | + |
| 45 | +} |
| 46 | + |
| 47 | + |
| 48 | +class CustomUsercreateTemplate extends UsercreateTemplate{ |
| 49 | +protected $campaign = null; |
| 50 | + |
| 51 | + function __construct(){ |
| 52 | + parent::__construct(); |
| 53 | + if(isset($_GET["campaign"])){ |
| 54 | + preg_match("/[A-Za-z0-9]+/", $_GET["campaign"], $matches); |
| 55 | + $this->campaign = $matches[0]; |
| 56 | + } |
| 57 | + } |
| 58 | + |
| 59 | + function msg( $str ) { |
| 60 | + //doesn't exist |
| 61 | + if($this->campaign && (wfMsg( "customusertemplate-{$this->campaign}-$str" ) == "<customusertemplate-{$this->campaign}-$str>") ){ |
| 62 | + parent::msg( $str ); |
| 63 | + } |
| 64 | + else{ |
| 65 | + $this->msgWikiCustom( "customusertemplate-{$this->campaign}-$str" ); |
| 66 | + } |
| 67 | + } |
| 68 | + |
| 69 | + function msgWiki( $str ) { |
| 70 | + //doesn't exist |
| 71 | + if($this->campaign && (wfMsg( "customusertemplate-{$this->campaign}-$str" ) == "<customusertemplate-{$this->campaign}-$str>") ){ |
| 72 | + parent::msgWiki( $str ); |
| 73 | + } |
| 74 | + else{ |
| 75 | + $this->msgWikiCustom( "customusertemplate-{$this->campaign}-$str" ); |
| 76 | + } |
| 77 | + } |
| 78 | + |
| 79 | + function msgWikiCustom( $str ) { |
| 80 | + global $wgParser, $wgOut; |
| 81 | + |
| 82 | + $text = $this->translator->translate( $str ); |
| 83 | + $parserOutput = $wgParser->parse( $text, $wgOut->getTitle(), |
| 84 | + $wgOut->parserOptions(), true ); |
| 85 | + echo $parserOutput->getText(); |
| 86 | + } |
| 87 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/CustomUserSignup/CustomUserTemplate.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 88 | + native |
Index: trunk/extensions/CustomUserSignup/README |
— | — | @@ -0,0 +1,8 @@ |
| 2 | +This extension lets you customize the messages seen in the user login process based on passing a "campaign" variable |
| 3 | +in to the Special:UserLogin page. |
| 4 | + |
| 5 | +So, if you append "&campaign={campaign}" to the user login process, any message created in includes/templates/Userlogin.php can be |
| 6 | +overridden with MediaWiki:customusertemplate-{campaign}-{message}. |
| 7 | + |
| 8 | +ex: If you wanted to change the text seen at the end of the signup page (a message called 'signupend') for users signing up from |
| 9 | +the "foo" campaign, you would edit MediaWiki:customusertemplate-foo-signupend page, and this would be substituted |
\ No newline at end of file |