r86437 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86436‎ | r86437 | r86438 >
Date:21:14, 19 April 2011
Author:nimishg
Status:deferred
Tags:
Comment:
centralized campaign checks, some refactoring
Modified paths:
  • /trunk/extensions/CustomUserSignup/CustomUserSignup.hooks.php (modified) (history)
  • /trunk/extensions/CustomUserSignup/CustomUserSignup.php (modified) (history)
  • /trunk/extensions/CustomUserSignup/CustomUserTemplate.php (modified) (history)
  • /trunk/extensions/CustomUserSignup/modules/AccountCreationUserBucket.js (modified) (history)

Diff [purge]

Index: trunk/extensions/CustomUserSignup/CustomUserSignup.php
@@ -37,19 +37,9 @@
3838 $wgHooks['BeforeWelcomeCreation'][] = 'CustomUserSignupHooks::welcomeScreen';
3939
4040 // NOTE: This hook includes JS for the account creation project
41 -//$wgHooks['BeforePageDisplay'][] = 'CustomUserSignupHooks::beforePageDisplay';
 41+$wgHooks['BeforePageDisplay'][] = 'CustomUserSignupHooks::beforePageDisplay';
4242
4343
4444 // 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' );
5646
Index: trunk/extensions/CustomUserSignup/CustomUserSignup.hooks.php
@@ -8,6 +8,17 @@
99
1010 class CustomUserSignupHooks {
1111
 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+
1223 public static function userCreateForm( &$template ) {
1324 global $wgRequest;
1425 $titleObj = SpecialPage::getTitleFor( 'Userlogin' );
@@ -15,9 +26,9 @@
1627 $newTemplate;
1728 $linkmsg;
1829
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 ) {
2233 $newTemplate = new CustomUserloginTemplate();
2334 $linkmsg = 'nologin';
2435 $template->data['action'] = "{$template->data['action']}&campaign=$campaign";
@@ -27,7 +38,7 @@
2839 "campaign=$campaign&type=signup",
2940 $template->data['link']
3041 );
31 - } elseif( get_class( $template ) == 'UsercreateTemplate' ) {
 42+ } elseif( $template instanceof UsercreateTemplate ) {
3243 $newTemplate = new CustomUsercreateTemplate();
3344 $linkmsg = 'gotaccount';
3445 $template->data['action'] = "{$template->data['action']}&campaign=$campaign";
@@ -80,9 +91,8 @@
8192
8293 public static function welcomeScreen( &$welcomeCreationMsg, &$injected_html ) {
8394 global $wgRequest;
84 - if( $wgRequest->getVal( 'campaign' ) ) {
85 - $campaign = $wgRequest->getVal( 'campaign' );
86 -
 95+ $campaign = CustomUserSignupHooks::getCampaign();
 96+ if( $campaign != "" ) {
8797 if( wfMessage( "customusertemplate-$campaign-welcomecreation" )->exists() ) {
8898 $welcomeCreationMsg = "customusertemplate-$campaign-welcomecreation";
8999 }
Index: trunk/extensions/CustomUserSignup/modules/AccountCreationUserBucket.js
@@ -39,6 +39,7 @@
4040 // "allActive" is reserved.
4141 // If this function exists, it will be apply to every user not in the "none" bucket
4242 "allActive": function(){
 43+
4344 //add click tracking to save
4445 $j("#wpSave").click(function(){ $j.trackAction('save'); });
4546
@@ -50,6 +51,7 @@
5152
5253 //add click tracking to preview
5354 $j("#wpPreview").click(function(){ $j.trackAction('preview'); });
 55+
5456 }
5557
5658 };
\ No newline at end of file
Index: trunk/extensions/CustomUserSignup/CustomUserTemplate.php
@@ -7,10 +7,7 @@
88 function __construct() {
99 global $wgRequest;
1010 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();
1512 }
1613
1714 function msg( $str ) {
@@ -56,10 +53,7 @@
5754 function __construct() {
5855 global $wgRequest;
5956 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();
6458 }
6559
6660 function msg( $str ) {

Status & tagging log