http://www.mediawiki.org/wiki/Special:Code/MediaWiki/86036

Revision: 86036
Author:   ashley
Date:     2011-04-14 09:47:46 +0000 (Thu, 14 Apr 2011)
Log Message:
-----------
CustomUserSignup: initial cleanup

Modified Paths:
--------------
    trunk/extensions/CustomUserSignup/CustomUserSignup.hooks.php
    trunk/extensions/CustomUserSignup/CustomUserSignup.i18n.php
    trunk/extensions/CustomUserSignup/CustomUserSignup.php
    trunk/extensions/CustomUserSignup/CustomUserTemplate.php

Modified: trunk/extensions/CustomUserSignup/CustomUserSignup.hooks.php
===================================================================
--- trunk/extensions/CustomUserSignup/CustomUserSignup.hooks.php        
2011-04-14 07:37:55 UTC (rev 86035)
+++ trunk/extensions/CustomUserSignup/CustomUserSignup.hooks.php        
2011-04-14 09:47:46 UTC (rev 86036)
@@ -7,42 +7,50 @@
  */
 
 class CustomUserSignupHooks {
-       
-       public static function userCreateForm(&$template){
-               if(isset($_GET["campaign"])){
-                       $campaign = $_GET["campaign"];
+
+       public static function userCreateForm( &$template ) {
+               if( isset( $_GET['campaign'] ) ) {
+                       $campaign = $_GET['campaign'];
                        $newTemplate;
-                       if(get_class($template) == "UserloginTemplate"){
+                       if( get_class( $template ) == 'UserloginTemplate' ) {
                                $newTemplate = new CustomUserloginTemplate();
-                               $template->data["action"] = 
"{$template->data["action"]}&campaign=$campaign";
-                               $template->data["link"] =
-                                       preg_replace("/type\=signup/", 
"campaign=$campaign&type=signup", $template->data["link"]);
-                       }
-                       else if(get_class($template) == "UsercreateTemplate"){
+                               $template->data['action'] = 
"{$template->data['action']}&campaign=$campaign";
+                               $template->data['link'] =
+                                       preg_replace(
+                                               '/type\=signup/',
+                                               
"campaign=$campaign&type=signup",
+                                               $template->data['link']
+                                       );
+                       } elseif( get_class( $template ) == 
'UsercreateTemplate' ) {
                                $newTemplate = new CustomUsercreateTemplate();
-                               $template->data["action"] = 
"{$template->data["action"]}&campaign=$campaign";
-                               $template->data["link"] =
-                                       preg_replace("/type\=login\&/", 
"type=login&campaign=$campaign&", $template->data["link"]);
+                               $template->data['action'] = 
"{$template->data['action']}&campaign=$campaign";
+                               $template->data['link'] =
+                                       preg_replace(
+                                               '/type\=login\&/',
+                                               
"type=login&campaign=$campaign&",
+                                               $template->data['link']
+                                       );
+                       } else {
+                               return true;
                        }
-                       else return true;
-                       
+
                        $newTemplate->data = $template->data;
                        $newTemplate->translator = $template->translator;
                        $template = $newTemplate;
                }
-               
-               return true;    
+
+               return true;
        }
-       
-       public static function welcomeScreen(&$welcome_creation_msg, 
&$injected_html){
-               if(isset($_GET["campaign"])){
-                       $campaign = $_GET["campaign"];
-                       
-                       if(wfMsg( 
"customusertemplate-$campaign-welcomecreation") != 
"<customusertemplate-$campaign-welcomecreation>"){
-                               $welcome_creation_msg = 
"customusertemplate-$campaign-welcomecreation"; 
+
+       public static function welcomeScreen( &$welcomeCreationMsg, 
&$injected_html ) {
+               if( isset( $_GET['campaign'] ) ) {
+                       $campaign = $_GET['campaign'];
+
+                       if( wfMsg( 
"customusertemplate-$campaign-welcomecreation" ) != 
"<customusertemplate-$campaign-welcomecreation>" ) {
+                               $welcomeCreationMsg = 
"customusertemplate-$campaign-welcomecreation";
                        }
-               }       
+               }
                return true;
        }
-       
+
 }
\ No newline at end of file

Modified: trunk/extensions/CustomUserSignup/CustomUserSignup.i18n.php
===================================================================
--- trunk/extensions/CustomUserSignup/CustomUserSignup.i18n.php 2011-04-14 
07:37:55 UTC (rev 86035)
+++ trunk/extensions/CustomUserSignup/CustomUserSignup.i18n.php 2011-04-14 
09:47:46 UTC (rev 86036)
@@ -1,4 +1,11 @@
 <?php
+/**
+ * Internationalization file for the CustomUserSignup extension.
+ *
+ * @file
+ * @ingroup Extensions
+ */
+
 $messages = array();
 
 /** English

Modified: trunk/extensions/CustomUserSignup/CustomUserSignup.php
===================================================================
--- trunk/extensions/CustomUserSignup/CustomUserSignup.php      2011-04-14 
07:37:55 UTC (rev 86035)
+++ trunk/extensions/CustomUserSignup/CustomUserSignup.php      2011-04-14 
09:47:46 UTC (rev 86036)
@@ -1,10 +1,24 @@
 <?php
+/**
+ * CustomUserSignup extension -- allows for customizable messages during the
+ * account creation process
+ *
+ * @file
+ * @ingroup Extensions
+ * @version 0.1.0
+ * @author Nimish Gautam
+ * @link http://www.mediawiki.org/wiki/Extension:CustomUserSignup Documentation
+ */
+
+if ( !defined( 'MEDIAWIKI' ) ) {
+       die( 'This is not a valid entry point to MediaWiki.' );
+}
+
+// Extension credits that will show up on Special:Version
 $wgExtensionCredits['other'][] = array(
        'path' => __FILE__,
        'name' => 'CustomUserSignup',
-       'author' => array(
-               'Nimish Gautam',
-       ),
+       'author' => 'Nimish Gautam',
        'version' => '0.1.0',
        'descriptionmsg' => 'customusersignup-desc',
        'url' => 'http://www.mediawiki.org/wiki/Extension:CustomUserSignup'
@@ -19,5 +33,5 @@
 
 // Hooks
 $wgHooks['UserCreateForm'][] = 'CustomUserSignupHooks::userCreateForm';
-$wgHooks['UserLoginForm'][] = 'CustomUserSignupHooks::userCreateForm'; 
+$wgHooks['UserLoginForm'][] = 'CustomUserSignupHooks::userCreateForm';
 $wgHooks['BeforeWelcomeCreation'][] = 'CustomUserSignupHooks::welcomeScreen';

Modified: trunk/extensions/CustomUserSignup/CustomUserTemplate.php
===================================================================
--- trunk/extensions/CustomUserSignup/CustomUserTemplate.php    2011-04-14 
07:37:55 UTC (rev 86035)
+++ trunk/extensions/CustomUserSignup/CustomUserTemplate.php    2011-04-14 
09:47:46 UTC (rev 86036)
@@ -1,37 +1,35 @@
 <?php
 
-class CustomUserloginTemplate extends UserloginTemplate{
-       
+class CustomUserloginTemplate extends UserloginTemplate {
+
        protected $campaign = null;
-       
-       function __construct(){
+
+       function __construct() {
                parent::__construct();
-               if(isset($_GET["campaign"])){
-                       preg_match("/[A-Za-z0-9]+/", $_GET["campaign"], 
$matches);
+               if( isset( $_GET['campaign'] ) ) {
+                       preg_match( '/[A-Za-z0-9]+/', $_GET['campaign'], 
$matches );
                        $this->campaign = $matches[0];
-               }               
+               }
        }
-       
+
        function msg( $str ) {
-               //doesn't exist
-               if($this->campaign && (wfMsg( 
"customusertemplate-{$this->campaign}-$str"  )  == 
"&lt;customusertemplate-{$this->campaign}-$str&gt;")  ){
+               // doesn't exist
+               if( $this->campaign && ( wfMsg( 
"customusertemplate-{$this->campaign}-$str" ) == 
"&lt;customusertemplate-{$this->campaign}-$str&gt;" ) ) {
                        parent::msg( $str );
+               } else {
+                       $this->msgWikiCustom( 
"customusertemplate-{$this->campaign}-$str" );
                }
-               else{
-                       $this->msgWikiCustom( 
"customusertemplate-{$this->campaign}-$str" );    
-               }
        }
 
        function msgWiki( $str ) {
-               //doesn't exist
-               if($this->campaign && (wfMsg( 
"customusertemplate-{$this->campaign}-$str"  )  == 
"&lt;customusertemplate-{$this->campaign}-$str&gt;")  ){
+               // doesn't exist
+               if( $this->campaign && ( wfMsg( 
"customusertemplate-{$this->campaign}-$str" ) == 
"&lt;customusertemplate-{$this->campaign}-$str&gt;" ) ) {
                        parent::msgWiki( $str );
-               }
-               else{
+               } else {
                        $this->msgWikiCustom( 
"customusertemplate-{$this->campaign}-$str" );
                }
        }
-       
+
        function msgWikiCustom( $str ) {
                global $wgParser, $wgOut;
 
@@ -40,41 +38,38 @@
                        $wgOut->parserOptions(), true );
                echo $parserOutput->getText();
        }
-       
+
 }
 
+class CustomUsercreateTemplate extends UsercreateTemplate {
+       protected $campaign = null;
 
-class CustomUsercreateTemplate extends UsercreateTemplate{
-protected $campaign = null;
-       
-       function __construct(){
+       function __construct() {
                parent::__construct();
-               if(isset($_GET["campaign"])){
-                       preg_match("/[A-Za-z0-9]+/", $_GET["campaign"], 
$matches);
+               if( isset( $_GET['campaign'] ) ) {
+                       preg_match( '/[A-Za-z0-9]+/', $_GET['campaign'], 
$matches );
                        $this->campaign = $matches[0];
-               }               
+               }
        }
-       
+
        function msg( $str ) {
-               //doesn't exist
-               if($this->campaign && (wfMsg( 
"customusertemplate-{$this->campaign}-$str"  )  == 
"&lt;customusertemplate-{$this->campaign}-$str&gt;")  ){
+               // doesn't exist
+               if( $this->campaign && ( wfMsg( 
"customusertemplate-{$this->campaign}-$str" ) == 
"&lt;customusertemplate-{$this->campaign}-$str&gt;" ) ) {
                        parent::msg( $str );
+               } else {
+                       $this->msgWikiCustom( 
"customusertemplate-{$this->campaign}-$str" );
                }
-               else{
-                       $this->msgWikiCustom( 
"customusertemplate-{$this->campaign}-$str" );    
-               }
        }
 
        function msgWiki( $str ) {
-               //doesn't exist
-               if($this->campaign && (wfMsg( 
"customusertemplate-{$this->campaign}-$str"  )  == 
"&lt;customusertemplate-{$this->campaign}-$str&gt;")  ){
+               // doesn't exist
+               if( $this->campaign && (wfMsg( 
"customusertemplate-{$this->campaign}-$str" ) == 
"&lt;customusertemplate-{$this->campaign}-$str&gt;" ) ) {
                        parent::msgWiki( $str );
-               }
-               else{
+               } else {
                        $this->msgWikiCustom( 
"customusertemplate-{$this->campaign}-$str" );
                }
        }
-       
+
        function msgWikiCustom( $str ) {
                global $wgParser, $wgOut;
 


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to