r86036 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86035‎ | r86036 | r86037 >
Date:09:47, 14 April 2011
Author:ashley
Status:ok
Tags:
Comment:
CustomUserSignup: initial cleanup
Modified paths:
  • /trunk/extensions/CustomUserSignup/CustomUserSignup.hooks.php (modified) (history)
  • /trunk/extensions/CustomUserSignup/CustomUserSignup.i18n.php (modified) (history)
  • /trunk/extensions/CustomUserSignup/CustomUserSignup.php (modified) (history)
  • /trunk/extensions/CustomUserSignup/CustomUserTemplate.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CustomUserSignup/CustomUserSignup.i18n.php
@@ -1,4 +1,11 @@
22 <?php
 3+/**
 4+ * Internationalization file for the CustomUserSignup extension.
 5+ *
 6+ * @file
 7+ * @ingroup Extensions
 8+ */
 9+
310 $messages = array();
411
512 /** English
Index: trunk/extensions/CustomUserSignup/CustomUserSignup.php
@@ -1,10 +1,24 @@
22 <?php
 3+/**
 4+ * CustomUserSignup extension -- allows for customizable messages during the
 5+ * account creation process
 6+ *
 7+ * @file
 8+ * @ingroup Extensions
 9+ * @version 0.1.0
 10+ * @author Nimish Gautam
 11+ * @link http://www.mediawiki.org/wiki/Extension:CustomUserSignup Documentation
 12+ */
 13+
 14+if ( !defined( 'MEDIAWIKI' ) ) {
 15+ die( 'This is not a valid entry point to MediaWiki.' );
 16+}
 17+
 18+// Extension credits that will show up on Special:Version
319 $wgExtensionCredits['other'][] = array(
420 'path' => __FILE__,
521 'name' => 'CustomUserSignup',
6 - 'author' => array(
7 - 'Nimish Gautam',
8 - ),
 22+ 'author' => 'Nimish Gautam',
923 'version' => '0.1.0',
1024 'descriptionmsg' => 'customusersignup-desc',
1125 'url' => 'http://www.mediawiki.org/wiki/Extension:CustomUserSignup'
@@ -19,5 +33,5 @@
2034
2135 // Hooks
2236 $wgHooks['UserCreateForm'][] = 'CustomUserSignupHooks::userCreateForm';
23 -$wgHooks['UserLoginForm'][] = 'CustomUserSignupHooks::userCreateForm';
 37+$wgHooks['UserLoginForm'][] = 'CustomUserSignupHooks::userCreateForm';
2438 $wgHooks['BeforeWelcomeCreation'][] = 'CustomUserSignupHooks::welcomeScreen';
Index: trunk/extensions/CustomUserSignup/CustomUserSignup.hooks.php
@@ -7,42 +7,50 @@
88 */
99
1010 class CustomUserSignupHooks {
11 -
12 - public static function userCreateForm(&$template){
13 - if(isset($_GET["campaign"])){
14 - $campaign = $_GET["campaign"];
 11+
 12+ public static function userCreateForm( &$template ) {
 13+ if( isset( $_GET['campaign'] ) ) {
 14+ $campaign = $_GET['campaign'];
1515 $newTemplate;
16 - if(get_class($template) == "UserloginTemplate"){
 16+ if( get_class( $template ) == 'UserloginTemplate' ) {
1717 $newTemplate = new CustomUserloginTemplate();
18 - $template->data["action"] = "{$template->data["action"]}&campaign=$campaign";
19 - $template->data["link"] =
20 - preg_replace("/type\=signup/", "campaign=$campaign&amp;type=signup", $template->data["link"]);
21 - }
22 - else if(get_class($template) == "UsercreateTemplate"){
 18+ $template->data['action'] = "{$template->data['action']}&campaign=$campaign";
 19+ $template->data['link'] =
 20+ preg_replace(
 21+ '/type\=signup/',
 22+ "campaign=$campaign&amp;type=signup",
 23+ $template->data['link']
 24+ );
 25+ } elseif( get_class( $template ) == 'UsercreateTemplate' ) {
2326 $newTemplate = new CustomUsercreateTemplate();
24 - $template->data["action"] = "{$template->data["action"]}&campaign=$campaign";
25 - $template->data["link"] =
26 - preg_replace("/type\=login\&amp;/", "type=login&amp;campaign=$campaign&amp;", $template->data["link"]);
 27+ $template->data['action'] = "{$template->data['action']}&campaign=$campaign";
 28+ $template->data['link'] =
 29+ preg_replace(
 30+ '/type\=login\&amp;/',
 31+ "type=login&amp;campaign=$campaign&amp;",
 32+ $template->data['link']
 33+ );
 34+ } else {
 35+ return true;
2736 }
28 - else return true;
29 -
 37+
3038 $newTemplate->data = $template->data;
3139 $newTemplate->translator = $template->translator;
3240 $template = $newTemplate;
3341 }
34 -
35 - return true;
 42+
 43+ return true;
3644 }
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") != "&lt;customusertemplate-$campaign-welcomecreation&gt;"){
43 - $welcome_creation_msg = "customusertemplate-$campaign-welcomecreation";
 45+
 46+ public static function welcomeScreen( &$welcomeCreationMsg, &$injected_html ) {
 47+ if( isset( $_GET['campaign'] ) ) {
 48+ $campaign = $_GET['campaign'];
 49+
 50+ if( wfMsg( "customusertemplate-$campaign-welcomecreation" ) != "&lt;customusertemplate-$campaign-welcomecreation&gt;" ) {
 51+ $welcomeCreationMsg = "customusertemplate-$campaign-welcomecreation";
4452 }
45 - }
 53+ }
4654 return true;
4755 }
48 -
 56+
4957 }
\ No newline at end of file
Index: trunk/extensions/CustomUserSignup/CustomUserTemplate.php
@@ -1,37 +1,35 @@
22 <?php
33
4 -class CustomUserloginTemplate extends UserloginTemplate{
5 -
 4+class CustomUserloginTemplate extends UserloginTemplate {
 5+
66 protected $campaign = null;
7 -
8 - function __construct(){
 7+
 8+ function __construct() {
99 parent::__construct();
10 - if(isset($_GET["campaign"])){
11 - preg_match("/[A-Za-z0-9]+/", $_GET["campaign"], $matches);
 10+ if( isset( $_GET['campaign'] ) ) {
 11+ preg_match( '/[A-Za-z0-9]+/', $_GET['campaign'], $matches );
1212 $this->campaign = $matches[0];
13 - }
 13+ }
1414 }
15 -
 15+
1616 function msg( $str ) {
17 - //doesn't exist
18 - if($this->campaign && (wfMsg( "customusertemplate-{$this->campaign}-$str" ) == "&lt;customusertemplate-{$this->campaign}-$str&gt;") ){
 17+ // doesn't exist
 18+ if( $this->campaign && ( wfMsg( "customusertemplate-{$this->campaign}-$str" ) == "&lt;customusertemplate-{$this->campaign}-$str&gt;" ) ) {
1919 parent::msg( $str );
 20+ } else {
 21+ $this->msgWikiCustom( "customusertemplate-{$this->campaign}-$str" );
2022 }
21 - else{
22 - $this->msgWikiCustom( "customusertemplate-{$this->campaign}-$str" );
23 - }
2423 }
2524
2625 function msgWiki( $str ) {
27 - //doesn't exist
28 - if($this->campaign && (wfMsg( "customusertemplate-{$this->campaign}-$str" ) == "&lt;customusertemplate-{$this->campaign}-$str&gt;") ){
 26+ // doesn't exist
 27+ if( $this->campaign && ( wfMsg( "customusertemplate-{$this->campaign}-$str" ) == "&lt;customusertemplate-{$this->campaign}-$str&gt;" ) ) {
2928 parent::msgWiki( $str );
30 - }
31 - else{
 29+ } else {
3230 $this->msgWikiCustom( "customusertemplate-{$this->campaign}-$str" );
3331 }
3432 }
35 -
 33+
3634 function msgWikiCustom( $str ) {
3735 global $wgParser, $wgOut;
3836
@@ -40,41 +38,38 @@
4139 $wgOut->parserOptions(), true );
4240 echo $parserOutput->getText();
4341 }
44 -
 42+
4543 }
4644
 45+class CustomUsercreateTemplate extends UsercreateTemplate {
 46+ protected $campaign = null;
4747
48 -class CustomUsercreateTemplate extends UsercreateTemplate{
49 -protected $campaign = null;
50 -
51 - function __construct(){
 48+ function __construct() {
5249 parent::__construct();
53 - if(isset($_GET["campaign"])){
54 - preg_match("/[A-Za-z0-9]+/", $_GET["campaign"], $matches);
 50+ if( isset( $_GET['campaign'] ) ) {
 51+ preg_match( '/[A-Za-z0-9]+/', $_GET['campaign'], $matches );
5552 $this->campaign = $matches[0];
56 - }
 53+ }
5754 }
58 -
 55+
5956 function msg( $str ) {
60 - //doesn't exist
61 - if($this->campaign && (wfMsg( "customusertemplate-{$this->campaign}-$str" ) == "&lt;customusertemplate-{$this->campaign}-$str&gt;") ){
 57+ // doesn't exist
 58+ if( $this->campaign && ( wfMsg( "customusertemplate-{$this->campaign}-$str" ) == "&lt;customusertemplate-{$this->campaign}-$str&gt;" ) ) {
6259 parent::msg( $str );
 60+ } else {
 61+ $this->msgWikiCustom( "customusertemplate-{$this->campaign}-$str" );
6362 }
64 - else{
65 - $this->msgWikiCustom( "customusertemplate-{$this->campaign}-$str" );
66 - }
6763 }
6864
6965 function msgWiki( $str ) {
70 - //doesn't exist
71 - if($this->campaign && (wfMsg( "customusertemplate-{$this->campaign}-$str" ) == "&lt;customusertemplate-{$this->campaign}-$str&gt;") ){
 66+ // doesn't exist
 67+ if( $this->campaign && (wfMsg( "customusertemplate-{$this->campaign}-$str" ) == "&lt;customusertemplate-{$this->campaign}-$str&gt;" ) ) {
7268 parent::msgWiki( $str );
73 - }
74 - else{
 69+ } else {
7570 $this->msgWikiCustom( "customusertemplate-{$this->campaign}-$str" );
7671 }
7772 }
78 -
 73+
7974 function msgWikiCustom( $str ) {
8075 global $wgParser, $wgOut;
8176

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r86015Added code for CustomUserSignup, extension to allow custom user signup flowsnimishg23:57, 13 April 2011

Status & tagging log