Use ->parse() for messages on Special:ResetTokens
[lhc/web/wiklou.git] / includes / Preferences.php
index 709f15c..84a3b7e 100644 (file)
@@ -188,7 +188,8 @@ class Preferences {
                global $wgAuth, $wgContLang, $wgParser, $wgCookieExpiration, $wgLanguageCode,
                        $wgDisableTitleConversion, $wgDisableLangConversion, $wgMaxSigChars,
                        $wgEnableEmail, $wgEmailConfirmToEdit, $wgEnableUserEmail, $wgEmailAuthentication,
-                       $wgEnotifWatchlist, $wgEnotifUserTalk, $wgEnotifRevealEditorAddress;
+                       $wgEnotifWatchlist, $wgEnotifUserTalk, $wgEnotifRevealEditorAddress,
+                       $wgSecureLogin;
 
                // retrieving user name for GENDER and misc.
                $userName = $user->getName();
@@ -280,18 +281,6 @@ class Preferences {
                        'help-message' => 'prefs-help-realname',
                );
 
-               $defaultPreferences['gender'] = array(
-                       'type' => 'select',
-                       'section' => 'personal/info',
-                       'options' => array(
-                               $context->msg( 'gender-male' )->text() => 'male',
-                               $context->msg( 'gender-female' )->text() => 'female',
-                               $context->msg( 'gender-unknown' )->text() => 'unknown',
-                       ),
-                       'label-message' => 'yourgender',
-                       'help-message' => 'prefs-help-gender',
-               );
-
                if ( $canEditPrivateInfo && $wgAuth->allowPasswordChange() ) {
                        $link = Linker::link( SpecialPage::getTitleFor( 'ChangePassword' ),
                                $context->msg( 'prefs-resetpass' )->escaped(), array(),
@@ -313,6 +302,14 @@ class Preferences {
                                'section' => 'personal/info',
                        );
                }
+               // Only show preferhttps if secure login is turned on
+               if ( $wgSecureLogin && wfCanIPUseHTTPS( $context->getRequest()->getIP() ) ) {
+                       $defaultPreferences['prefershttps'] = array(
+                               'type' => 'toggle',
+                               'label-message' => 'tog-prefershttps',
+                               'section' => 'personal/info'
+                       );
+               }
 
                // Language
                $languages = Language::fetchLanguageNames( null, 'mw' );
@@ -333,37 +330,58 @@ class Preferences {
                        'label-message' => 'yourlanguage',
                );
 
+               $defaultPreferences['gender'] = array(
+                       'type' => 'radio',
+                       'section' => 'personal/i18n',
+                       'options' => array(
+                               $context->msg( 'gender-male' )->text() => 'male',
+                               $context->msg( 'gender-female' )->text() => 'female',
+                               $context->msg( 'gender-unknown' )->text() => 'unknown',
+                       ),
+                       'label-message' => 'yourgender',
+                       'help-message' => 'prefs-help-gender',
+               );
+
                // see if there are multiple language variants to choose from
                if ( !$wgDisableLangConversion ) {
-                       $variants = $wgContLang->getVariants();
+                       foreach ( LanguageConverter::$languagesWithVariants as $langCode ) {
+                               if ( $langCode == $wgContLang->getCode() ) {
+                                       $variants = $wgContLang->getVariants();
 
-                       if ( count( $variants ) > 1 ) {
-                               $variantArray = array();
-                               foreach ( $variants as $v ) {
-                                       $v = str_replace( '_', '-', strtolower( $v ) );
-                                       $variantArray[$v] = $wgContLang->getVariantname( $v, false );
-                               }
+                                       if ( count( $variants ) <= 1 ) {
+                                               continue;
+                                       }
 
-                               $options = array();
-                               foreach ( $variantArray as $code => $name ) {
-                                       $display = wfBCP47( $code ) . ' - ' . $name;
-                                       $options[$display] = $code;
-                               }
+                                       $variantArray = array();
+                                       foreach ( $variants as $v ) {
+                                               $v = str_replace( '_', '-', strtolower( $v ) );
+                                               $variantArray[$v] = $lang->getVariantname( $v, false );
+                                       }
 
-                               $defaultPreferences['variant'] = array(
-                                       'label-message' => 'yourvariant',
-                                       'type' => 'select',
-                                       'options' => $options,
-                                       'section' => 'personal/i18n',
-                                       'help-message' => 'prefs-help-variant',
-                               );
+                                       $options = array();
+                                       foreach ( $variantArray as $code => $name ) {
+                                               $display = wfBCP47( $code ) . ' - ' . $name;
+                                               $options[$display] = $code;
+                                       }
 
-                               if ( !$wgDisableTitleConversion ) {
-                                       $defaultPreferences['noconvertlink'] =
-                                               array(
-                                               'type' => 'toggle',
+                                       $defaultPreferences['variant'] = array(
+                                               'label-message' => 'yourvariant',
+                                               'type' => 'select',
+                                               'options' => $options,
                                                'section' => 'personal/i18n',
-                                               'label-message' => 'tog-noconvertlink',
+                                               'help-message' => 'prefs-help-variant',
+                                       );
+
+                                       if ( !$wgDisableTitleConversion ) {
+                                               $defaultPreferences['noconvertlink'] = array(
+                                                       'type' => 'toggle',
+                                                       'section' => 'personal/i18n',
+                                                       'label-message' => 'tog-noconvertlink',
+                                               );
+                                       }
+                               } else {
+                                       $defaultPreferences["variant-$langCode"] = array(
+                                               'type' => 'api',
                                        );
                                }
                        }
@@ -969,6 +987,8 @@ class Preferences {
 
                foreach ( $watchTypes as $action => $pref ) {
                        if ( $user->isAllowed( $action ) ) {
+                               // Give grep a chance to find the usages:
+                               // tog-watchdefault, tog-watchmoves, tog-watchdeletion, tog-watchcreations
                                $defaultPreferences[$pref] = array(
                                        'type' => 'toggle',
                                        'section' => 'watchlist/advancedwatchlist',