r86159 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86158‎ | r86159 | r86160 >
Date:23:58, 15 April 2011
Author:nimishg
Status:deferred
Tags:
Comment:
Added account creation project sample code
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 (added) (history)
  • /trunk/extensions/CustomUserSignup/modules/AccountCreationUserBucket.js (added) (history)

Diff [purge]

Index: trunk/extensions/CustomUserSignup/CustomUserSignup.php
@@ -35,3 +35,21 @@
3636 $wgHooks['UserCreateForm'][] = 'CustomUserSignupHooks::userCreateForm';
3737 $wgHooks['UserLoginForm'][] = 'CustomUserSignupHooks::userCreateForm';
3838 $wgHooks['BeforeWelcomeCreation'][] = 'CustomUserSignupHooks::welcomeScreen';
 39+
 40+// NOTE: This hook includes JS for the account creation project
 41+//$wgHooks['BeforePageDisplay'][] = 'CustomUserSignupHooks::beforePageDisplay';
 42+
 43+
 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'));
 56+
Index: trunk/extensions/CustomUserSignup/CustomUserSignup.hooks.php
@@ -89,5 +89,9 @@
9090 }
9191 return true;
9292 }
93 -
 93+
 94+ public static function beforePageDisplay( $out, $skin ) {
 95+ $out->addModules( 'ext.UserBuckets' );
 96+ return true;
 97+ }
9498 }
\ No newline at end of file
Index: trunk/extensions/CustomUserSignup/modules/AccountCreationUserBucket.js
@@ -0,0 +1,55 @@
 2+
 3+//checks
 4+if(typeof(MW) == "undefined"){ MW={};}
 5+if(!MW.activeCampaigns){ MW.activeCampaigns ={}; }
 6+
 7+//define new active campaign
 8+MW.activeCampaigns.AccountCreation =
 9+
 10+{
 11+ //Treatment name
 12+ "name": "AccountCreation",
 13+
 14+ //Treatment version. Increment this when altering rates
 15+ "version": 1,
 16+
 17+ // Rates are calculated out of the total sum, so
 18+ // rates of x:10000, y:3, and z:1 mean users have a
 19+ // chance of being in bucket x at 10000/10004,
 20+ // y at 3/10004 and z at 1/10004
 21+ // The algorithm is faster if these are ordered in descending order,
 22+ // particularly if there are orders of magnitude differences in the
 23+ // bucket sizes
 24+ // "none" is reserved for control
 25+ "rates": {"NiceMsg1": 1, "NiceMsg2": 1 },
 26+
 27+ // individual changes, function names corresponding
 28+ // to what is in "rates" object
 29+ // (note: "none" function not needed or used)
 30+
 31+ "NiceMsg1": function(){
 32+ //change to NiceMsg1 campaign
 33+ $j("#pt-anonlogin a").attr("href", $j("#pt-anonlogin a").attr("href") + "&campaign=NiceMsg1" );
 34+ },
 35+ "NiceMsg2": function(){
 36+ //change to NiceMsg2 campaign
 37+ $j("#pt-anonlogin a").attr("href", $j("#pt-anonlogin a").attr("href") + "&campaign=NiceMsg2" );
 38+ },
 39+
 40+ // "allActive" is reserved.
 41+ // If this function exists, it will be apply to every user not in the "none" bucket
 42+ "allActive": function(){
 43+ //add click tracking to save
 44+ $j("#wpSave").click(function(){ $j.trackAction('save'); });
 45+
 46+ //track login attempt
 47+ $j("#wpLoginAttempt").click(function(){ $j.trackAction('login-attempt'); });
 48+
 49+ //track account creation
 50+ $j("#wpCreateaccount").click(function(){ $j.trackAction('account-created'); });
 51+
 52+ //add click tracking to preview
 53+ $j("#wpPreview").click(function(){ $j.trackAction('preview'); });
 54+ }
 55+
 56+};
\ No newline at end of file
Property changes on: trunk/extensions/CustomUserSignup/modules/AccountCreationUserBucket.js
___________________________________________________________________
Added: svn:eol-style
157 + native
Index: trunk/extensions/CustomUserSignup/CustomUserTemplate.php
@@ -39,7 +39,9 @@
4040 $wgOut->parserOptions(), true );
4141 $parsedText = $parserOutput->getText();
4242 if( $checkifplain &&
43 - ( strlen(strip_tags($parsedText)) == (strlen($parsedText)-7) )) {
 43+ ( strlen(strip_tags($parsedText)) == (strlen($parsedText)-7) )) {
 44+ // the parser encapsulates text in <p></p> (7 chars) If these
 45+ // were the only chars added to the text, then it was plaintext
4446 echo htmlspecialchars( $text );
4547 } else {
4648 echo $parsedText;
@@ -87,6 +89,8 @@
8890 $parsedText = $parserOutput->getText();
8991 if( $checkifplain &&
9092 ( strlen(strip_tags($parsedText)) == (strlen($parsedText)-7) )) {
 93+ // the parser encapsulates text in <p></p> (7 chars) If these
 94+ // were the only chars added to the text, then it was plaintext
9195 echo htmlspecialchars( $text );
9296 } else {
9397 echo $parsedText;

Status & tagging log