Don't shown red box around unconfirmed email address in preferences if authentication...
[lhc/web/wiklou.git] / includes / Preferences.php
index 8edf60a..972e2c6 100644 (file)
@@ -310,23 +310,23 @@ class Preferences {
                        'label-message' => 'yourlanguage',
                );
 
-               /* see if there are multiple language variants to choose from*/
-               $variantArray = array();
+               // see if there are multiple language variants to choose from
                if ( !$wgDisableLangConversion ) {
                        $variants = $wgContLang->getVariants();
 
-                       foreach ( $variants as $v ) {
-                               $v = str_replace( '_', '-', strtolower( $v ) );
-                               $variantArray[$v] = $wgContLang->getVariantname( $v, false );
-                       }
+                       if ( count( $variants ) > 1 ) {
+                               $variantArray = array();
+                               foreach ( $variants as $v ) {
+                                       $v = str_replace( '_', '-', strtolower( $v ) );
+                                       $variantArray[$v] = $wgContLang->getVariantname( $v, false );
+                               }
 
-                       $options = array();
-                       foreach ( $variantArray as $code => $name ) {
-                               $display = wfBCP47( $code ) . ' - ' . $name;
-                               $options[$display] = $code;
-                       }
+                               $options = array();
+                               foreach ( $variantArray as $code => $name ) {
+                                       $display = wfBCP47( $code ) . ' - ' . $name;
+                                       $options[$display] = $code;
+                               }
 
-                       if ( count( $variantArray ) > 1 ) {
                                $defaultPreferences['variant'] = array(
                                        'label-message' => 'yourvariant',
                                        'type' => 'select',
@@ -334,16 +334,16 @@ class Preferences {
                                        'section' => 'personal/i18n',
                                        'help-message' => 'prefs-help-variant',
                                );
-                       }
-               }
 
-               if ( count( $variantArray ) > 1 && !$wgDisableLangConversion && !$wgDisableTitleConversion ) {
-                       $defaultPreferences['noconvertlink'] =
-                               array(
-                               'type' => 'toggle',
-                               'section' => 'personal/i18n',
-                               'label-message' => 'tog-noconvertlink',
-                       );
+                               if ( !$wgDisableTitleConversion ) {
+                                       $defaultPreferences['noconvertlink'] =
+                                               array(
+                                               'type' => 'toggle',
+                                               'section' => 'personal/i18n',
+                                               'label-message' => 'tog-noconvertlink',
+                                       );
+                               }
+                       }
                }
 
                // show a preview of the old signature first
@@ -378,7 +378,7 @@ class Preferences {
                                        ? 'prefs-help-email-required'
                                        : 'prefs-help-email';
 
-                       if( $wgEnableUserEmail ) {
+                       if ( $wgEnableUserEmail ) {
                                // additional messages when users can send email to each other
                                $helpMessages[] = 'prefs-help-email-others';
                        }
@@ -409,8 +409,8 @@ class Preferences {
 
                        $disableEmailPrefs = false;
 
-                       $emailauthenticationclass = 'mw-email-not-authenticated';
                        if ( $wgEmailAuthentication ) {
+                               $emailauthenticationclass = 'mw-email-not-authenticated';
                                if ( $user->getEmail() ) {
                                        if ( $user->getEmailAuthenticationTimestamp() ) {
                                                // date and time are separate parameters to facilitate localisation.
@@ -432,7 +432,7 @@ class Preferences {
                                                                SpecialPage::getTitleFor( 'Confirmemail' ),
                                                                $context->msg( 'emailconfirmlink' )->escaped()
                                                        ) . '<br />';
-                                               $emailauthenticationclass="mw-email-not-authenticated";
+                                               $emailauthenticationclass = "mw-email-not-authenticated";
                                        }
                                } else {
                                        $disableEmailPrefs = true;
@@ -449,8 +449,8 @@ class Preferences {
                                        # Apply the same CSS class used on the input to the message:
                                        'cssclass' => $emailauthenticationclass,
                                );
+                               $defaultPreferences['emailaddress']['cssclass'] = $emailauthenticationclass;
                        }
-                       $defaultPreferences['emailaddress']['cssclass'] = $emailauthenticationclass;
 
                        if ( $wgEnableUserEmail && $user->isAllowed( 'sendemail' ) ) {
                                $defaultPreferences['disablemail'] = array(
@@ -674,7 +674,7 @@ class Preferences {
                        'section' => 'rendering/advancedrendering',
                        'options' => $stubThresholdOptions,
                        'size' => 20,
-                       'label' => $context->msg( 'stub-threshold' )->text(), // Raw HTML message. Yay?
+                       'label-raw' => $context->msg( 'stub-threshold' )->text(), // Raw HTML message. Yay?
                );
 
                if ( $wgAllowUserCssPrefs ) {
@@ -721,7 +721,7 @@ class Preferences {
         * @param $defaultPreferences Array
         */
        static function editingPreferences( $user, IContextSource $context, &$defaultPreferences ) {
-               global $wgUseExternalEditor, $wgAllowUserCssPrefs;
+               global $wgAllowUserCssPrefs;
 
                ## Editing #####################################
                $defaultPreferences['cols'] = array(
@@ -794,19 +794,6 @@ class Preferences {
                        );
                }
 
-               if ( $wgUseExternalEditor ) {
-                       $defaultPreferences['externaleditor'] = array(
-                               'type' => 'toggle',
-                               'section' => 'editing/advancedediting',
-                               'label-message' => 'tog-externaleditor',
-                       );
-                       $defaultPreferences['externaldiff'] = array(
-                               'type' => 'toggle',
-                               'section' => 'editing/advancedediting',
-                               'label-message' => 'tog-externaldiff',
-                       );
-               }
-
                $defaultPreferences['forceeditsummary'] = array(
                        'type' => 'toggle',
                        'section' => 'editing/advancedediting',
@@ -818,6 +805,13 @@ class Preferences {
                        'section' => 'editing/advancedediting',
                        'label-message' => 'tog-uselivepreview',
                );
+
+               $defaultPreferences['useeditwarning'] = array(
+                       'type' => 'toggle',
+                       'section' => 'editing/advancedediting',
+                       'label-message' => 'tog-useeditwarning',
+               );
+
        }
 
        /**
@@ -1018,8 +1012,9 @@ class Preferences {
                $nsOptions = $wgContLang->getFormattedNamespaces();
                $nsOptions[0] = $context->msg( 'blanknamespace' )->text();
                foreach ( $nsOptions as $ns => $name ) {
-                       if ( $ns < 0 )
+                       if ( $ns < 0 ) {
                                unset( $nsOptions[$ns] );
+                       }
                }
 
                $defaultPreferences['searchnamespaces'] = array(
@@ -1098,7 +1093,7 @@ class Preferences {
                        }
 
                        # Create preview link
-                       $mplink = htmlspecialchars( $mptitle->getLocalURL( "useskin=$skinkey" ) );
+                       $mplink = htmlspecialchars( $mptitle->getLocalURL( array( 'useskin' => $skinkey ) ) );
                        $linkTools[] = "<a target='_blank' href=\"$mplink\">$previewtext</a>";
 
                        # Create links to user CSS/JS pages
@@ -1266,6 +1261,7 @@ class Preferences {
        }
 
        /**
+        * @param $context IContextSource
         * @return array
         */
        static function getTimezoneOptions( IContextSource $context ) {
@@ -1356,7 +1352,9 @@ class Preferences {
                                        $data[0] = intval( $data[0] );
                                        $data[1] = intval( $data[1] );
                                        $minDiff = abs( $data[0] ) * 60 + $data[1];
-                                       if ( $data[0] < 0 ) $minDiff = - $minDiff;
+                                       if ( $data[0] < 0 ) {
+                                               $minDiff = - $minDiff;
+                                       }
                                } else {
                                        $minDiff = intval( $data[0] ) * 60;
                                }
@@ -1370,6 +1368,8 @@ class Preferences {
        }
 
        /**
+        * Handle the form submission if everything validated properly
+        *
         * @param $formData
         * @param $form PreferencesForm
         * @param $entryPoint string
@@ -1409,7 +1409,7 @@ class Preferences {
                # via $wgHiddenPrefs, we don't want to destroy that setting in case the preference
                # is subsequently re-enabled
                # TODO: maintenance script to actually delete these
-               foreach( $wgHiddenPrefs as $pref ) {
+               foreach ( $wgHiddenPrefs as $pref ) {
                        # If the user has not set a non-default value here, the default will be returned
                        # and subsequently discarded
                        $formData[$pref] = $user->getOption( $pref, null, true );