r113221 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113220‎ | r113221 | r113222 >
Date:09:56, 7 March 2012
Author:hashar
Status:ok (Comments)
Tags:
Comment:
(bug 34302) Add CSS classes to email fields in user preferences

Patch by Nischay Nahata whom I have mentored earlier this week.
Modified paths:
  • /trunk/phase3/CREDITS (modified) (history)
  • /trunk/phase3/RELEASE-NOTES-1.20 (modified) (history)
  • /trunk/phase3/includes/Preferences.php (modified) (history)
  • /trunk/phase3/resources/Resources.php (modified) (history)
  • /trunk/phase3/resources/mediawiki.special/mediawiki.special.changeemail.css (modified) (history)
  • /trunk/phase3/resources/mediawiki.special/mediawiki.special.preferences.css (added) (history)
  • /trunk/phase3/tests/phpunit/includes/PreferencesTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES-1.20
@@ -21,6 +21,7 @@
2222 contentSub, ... The same div often also contains the class mw-content-ltr/rtl.
2323 * (bug 27619) Remove preference option to display broken links as link?
2424 * (bug 34896) Update jQuery JSON plugin to v2.3 (2011-09-17)
 25+* (bug 34302) Add CSS classes to email fields in user preferences
2526
2627 === Bug fixes in 1.20 ===
2728 * (bug 30245) Use the correct way to construct a log page title.
Index: trunk/phase3/CREDITS
@@ -159,6 +159,7 @@
160160 * Nx.devnull
161161 * Nikola Kovacs
162162 * Nikolaos S. Karastathis
 163+* Nischay Nahata
163164 * Olaf Lenz
164165 * Olivier Finlay Beaton
165166 * Paul Copperman
Index: trunk/phase3/tests/phpunit/includes/PreferencesTest.php
@@ -31,9 +31,10 @@
3232 */
3333 function testEmailFieldsWhenUserHasNoEmail() {
3434 $prefs = $this->prefsFor( 'noemail' );
35 - $this->assertArrayNotHasKey( 'class',
 35+ $this->assertArrayHasKey( 'cssclass',
3636 $prefs['emailaddress']
3737 );
 38+ $this->assertEquals( 'mw-email-none', $prefs['emailaddress']['cssclass'] );
3839 }
3940 /**
4041 * Placeholder to verify bug 34302
@@ -41,9 +42,10 @@
4243 */
4344 function testEmailFieldsWhenUserEmailNotAuthenticated() {
4445 $prefs = $this->prefsFor( 'notauth' );
45 - $this->assertArrayNotHasKey( 'class',
 46+ $this->assertArrayHasKey( 'cssclass',
4647 $prefs['emailaddress']
4748 );
 49+ $this->assertEquals( 'mw-email-not-authenticated', $prefs['emailaddress']['cssclass'] );
4850 }
4951 /**
5052 * Placeholder to verify bug 34302
@@ -51,9 +53,10 @@
5254 */
5355 function testEmailFieldsWhenUserEmailIsAuthenticated() {
5456 $prefs = $this->prefsFor( 'auth' );
55 - $this->assertArrayNotHasKey( 'class',
 57+ $this->assertArrayHasKey( 'cssclass',
5658 $prefs['emailaddress']
5759 );
 60+ $this->assertEquals( 'mw-email-authenticated', $prefs['emailaddress']['cssclass'] );
5861 }
5962
6063
Index: trunk/phase3/includes/Preferences.php
@@ -354,16 +354,19 @@
355355 $emailAddress .= $emailAddress == '' ? $link : " ($link)";
356356 }
357357
 358+
358359 $defaultPreferences['emailaddress'] = array(
359360 'type' => 'info',
360361 'raw' => true,
361362 'default' => $emailAddress,
362363 'label-message' => 'youremail',
363364 'section' => 'personal/email',
 365+ # 'cssclass' chosen below
364366 );
365367
366368 $disableEmailPrefs = false;
367369
 370+ $emailauthenticationclass = 'mw-email-not-authenticated';
368371 if ( $wgEmailAuthentication ) {
369372 if ( $user->getEmail() ) {
370373 if ( $user->getEmailAuthenticationTimestamp() ) {
@@ -378,6 +381,7 @@
379382 $emailauthenticated = $context->msg( 'emailauthenticated',
380383 $time, $d, $t )->parse() . '<br />';
381384 $disableEmailPrefs = false;
 385+ $emailauthenticationclass = 'mw-email-authenticated';
382386 } else {
383387 $disableEmailPrefs = true;
384388 $emailauthenticated = $context->msg( 'emailnotauthenticated' )->parse() . '<br />' .
@@ -385,10 +389,12 @@
386390 SpecialPage::getTitleFor( 'Confirmemail' ),
387391 $context->msg( 'emailconfirmlink' )->escaped()
388392 ) . '<br />';
 393+ $emailauthenticationclass="mw-email-not-authenticated";
389394 }
390395 } else {
391396 $disableEmailPrefs = true;
392397 $emailauthenticated = $context->msg( 'noemailprefs' )->escaped();
 398+ $emailauthenticationclass = 'mw-email-none';
393399 }
394400
395401 $defaultPreferences['emailauthentication'] = array(
@@ -397,9 +403,11 @@
398404 'section' => 'personal/email',
399405 'label-message' => 'prefs-emailconfirm-label',
400406 'default' => $emailauthenticated,
 407+ # Apply the same CSS class used on the input to the message:
 408+ 'cssclass' => $emailauthenticationclass,
401409 );
402 -
403410 }
 411+ $defaultPreferences['emailaddress']['cssclass'] = $emailauthenticationclass;
404412
405413 if ( $wgEnableUserEmail && $user->isAllowed( 'sendemail' ) ) {
406414 $defaultPreferences['disablemail'] = array(
Index: trunk/phase3/resources/Resources.php
@@ -786,6 +786,7 @@
787787 ),
788788 'mediawiki.special.preferences' => array(
789789 'scripts' => 'resources/mediawiki.special/mediawiki.special.preferences.js',
 790+ 'styles' => 'resources/mediawiki.special/mediawiki.special.preferences.css',
790791 ),
791792 'mediawiki.special.recentchanges' => array(
792793 'scripts' => 'resources/mediawiki.special/mediawiki.special.recentchanges.js',
Index: trunk/phase3/resources/mediawiki.special/mediawiki.special.changeemail.css
@@ -5,6 +5,8 @@
66 border-bottom-right-radius: 0.8em;
77 border-top-right-radius: 0.8em;
88 }
 9+
 10+/** colors also used in mediawiki.special.preferences.css */
911 #mw-emailaddress-validity.valid {
1012 border: 1px solid #80FF80;
1113 background-color: #C0FFC0;
Index: trunk/phase3/resources/mediawiki.special/mediawiki.special.preferences.css
@@ -0,0 +1,11 @@
 2+/** Reuses colors from mediawiki.special.changeemail.css */
 3+.mw-email-not-authenticated .mw-input,
 4+.mw-email-none .mw-input{
 5+ border: 1px solid #FF8080;
 6+ background-color: #FFC0C0;
 7+ color: black;
 8+}
 9+/** Authenticated email field has its own class too. Unstyled by default */
 10+/*
 11+.mw-email-authenticated .mw-input { }
 12+*/
Property changes on: trunk/phase3/resources/mediawiki.special/mediawiki.special.preferences.css
___________________________________________________________________
Added: svn:eol-style
113 + native

Sign-offs

UserFlagDate
Krinkleinspected09:59, 7 March 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r113016place holder to test bug 34919 when it is fixedhashar11:48, 5 March 2012
r113017amend r113016 , that was for bug 34302hashar11:50, 5 March 2012

Comments

#Comment by Bawolff (talk | contribs)   01:45, 21 March 2012

I'm not a fan how this highlights your email red for not-authenticated, even if $wgEmailAuthentication is false.

Status & tagging log