Index: trunk/extensions/CustomUserSignup/CustomUserSignup.php |
— | — | @@ -37,19 +37,9 @@ |
38 | 38 | $wgHooks['BeforeWelcomeCreation'][] = 'CustomUserSignupHooks::welcomeScreen'; |
39 | 39 | |
40 | 40 | // NOTE: This hook includes JS for the account creation project |
41 | | -//$wgHooks['BeforePageDisplay'][] = 'CustomUserSignupHooks::beforePageDisplay'; |
| 41 | +$wgHooks['BeforePageDisplay'][] = 'CustomUserSignupHooks::beforePageDisplay'; |
42 | 42 | |
43 | 43 | |
44 | 44 | // For Account Creation Project |
45 | | -$cusResourceTemplate = array( |
46 | | - 'localBasePath' => $dir . 'modules', |
47 | | - 'remoteExtPath' => 'CustomUserSignup/modules', |
48 | | -); |
49 | | -$wgResourceModules['ext.AccountCreationUserBucket'] = array( |
50 | | - 'scripts' => 'AccountCreationUserBucket.js', |
51 | | - 'dependencies' => 'jquery.clickTracking', |
52 | | -) + $cusResourceTemplate; |
53 | | -$wgResourceModules['ext.UserBuckets']['dependencies'] = array_merge( |
54 | | - ( array ) $wgResourceModules['ext.UserBuckets']['dependencies'], |
55 | | - array('ext.AccountCreationUserBucket')); |
| 45 | +ClickTrackingHooks::addCampaign($dir. 'modules', 'CustomUserSignup/modules', 'AccountCreationUserBucket' ); |
56 | 46 | |
Index: trunk/extensions/CustomUserSignup/CustomUserSignup.hooks.php |
— | — | @@ -8,6 +8,17 @@ |
9 | 9 | |
10 | 10 | class CustomUserSignupHooks { |
11 | 11 | |
| 12 | + public static function getCampaign(){ |
| 13 | + global $wgRequest; |
| 14 | + $campaign = ""; |
| 15 | + if( $wgRequest->getVal( 'campaign' ) ) { |
| 16 | + preg_match( '/[A-Za-z0-9]+/', $wgRequest->getVal( 'campaign' ), $matches ); |
| 17 | + $campaign = $matches[0]; |
| 18 | + } |
| 19 | + return $campaign; |
| 20 | + } |
| 21 | + |
| 22 | + |
12 | 23 | public static function userCreateForm( &$template ) { |
13 | 24 | global $wgRequest; |
14 | 25 | $titleObj = SpecialPage::getTitleFor( 'Userlogin' ); |
— | — | @@ -15,9 +26,9 @@ |
16 | 27 | $newTemplate; |
17 | 28 | $linkmsg; |
18 | 29 | |
19 | | - if( $wgRequest->getVal( 'campaign' ) ) { |
20 | | - $campaign = $wgRequest->getVal( 'campaign' ); |
21 | | - if( get_class( $template ) == 'UserloginTemplate' ) { |
| 30 | + $campaign = CustomUserSignupHooks::getCampaign(); |
| 31 | + if( $campaign != "" ) { |
| 32 | + if( $template instanceof UserloginTemplate ) { |
22 | 33 | $newTemplate = new CustomUserloginTemplate(); |
23 | 34 | $linkmsg = 'nologin'; |
24 | 35 | $template->data['action'] = "{$template->data['action']}&campaign=$campaign"; |
— | — | @@ -27,7 +38,7 @@ |
28 | 39 | "campaign=$campaign&type=signup", |
29 | 40 | $template->data['link'] |
30 | 41 | ); |
31 | | - } elseif( get_class( $template ) == 'UsercreateTemplate' ) { |
| 42 | + } elseif( $template instanceof UsercreateTemplate ) { |
32 | 43 | $newTemplate = new CustomUsercreateTemplate(); |
33 | 44 | $linkmsg = 'gotaccount'; |
34 | 45 | $template->data['action'] = "{$template->data['action']}&campaign=$campaign"; |
— | — | @@ -80,9 +91,8 @@ |
81 | 92 | |
82 | 93 | public static function welcomeScreen( &$welcomeCreationMsg, &$injected_html ) { |
83 | 94 | global $wgRequest; |
84 | | - if( $wgRequest->getVal( 'campaign' ) ) { |
85 | | - $campaign = $wgRequest->getVal( 'campaign' ); |
86 | | - |
| 95 | + $campaign = CustomUserSignupHooks::getCampaign(); |
| 96 | + if( $campaign != "" ) { |
87 | 97 | if( wfMessage( "customusertemplate-$campaign-welcomecreation" )->exists() ) { |
88 | 98 | $welcomeCreationMsg = "customusertemplate-$campaign-welcomecreation"; |
89 | 99 | } |
Index: trunk/extensions/CustomUserSignup/modules/AccountCreationUserBucket.js |
— | — | @@ -39,6 +39,7 @@ |
40 | 40 | // "allActive" is reserved. |
41 | 41 | // If this function exists, it will be apply to every user not in the "none" bucket |
42 | 42 | "allActive": function(){ |
| 43 | + |
43 | 44 | //add click tracking to save |
44 | 45 | $j("#wpSave").click(function(){ $j.trackAction('save'); }); |
45 | 46 | |
— | — | @@ -50,6 +51,7 @@ |
51 | 52 | |
52 | 53 | //add click tracking to preview |
53 | 54 | $j("#wpPreview").click(function(){ $j.trackAction('preview'); }); |
| 55 | + |
54 | 56 | } |
55 | 57 | |
56 | 58 | }; |
\ No newline at end of file |
Index: trunk/extensions/CustomUserSignup/CustomUserTemplate.php |
— | — | @@ -7,10 +7,7 @@ |
8 | 8 | function __construct() { |
9 | 9 | global $wgRequest; |
10 | 10 | parent::__construct(); |
11 | | - if( $wgRequest->getVal( 'campaign' ) ) { |
12 | | - preg_match( '/[A-Za-z0-9]+/', $wgRequest->getVal( 'campaign' ), $matches ); |
13 | | - $this->campaign = $matches[0]; |
14 | | - } |
| 11 | + $this->campaign = CustomUserSignupHooks::getCampaign(); |
15 | 12 | } |
16 | 13 | |
17 | 14 | function msg( $str ) { |
— | — | @@ -56,10 +53,7 @@ |
57 | 54 | function __construct() { |
58 | 55 | global $wgRequest; |
59 | 56 | parent::__construct(); |
60 | | - if( $wgRequest->getVal( 'campaign' ) ) { |
61 | | - preg_match( '/[A-Za-z0-9]+/', $wgRequest->getVal( 'campaign' ), $matches ); |
62 | | - $this->campaign = $matches[0]; |
63 | | - } |
| 57 | + $this->campaign = CustomUserSignupHooks::getCampaign(); |
64 | 58 | } |
65 | 59 | |
66 | 60 | function msg( $str ) { |