Followup r78924: keep track of exception/warning comments separately, to prevent...
[lhc/web/wiklou.git] / includes / Preferences.php
index 01a7041..0916040 100644 (file)
@@ -29,6 +29,11 @@ class Preferences {
        static $defaultPreferences = null;
        static $saveFilters = array(
                        'timecorrection' => array( 'Preferences', 'filterTimezoneInput' ),
+                       'cols' => array( 'Preferences', 'filterIntval' ),
+                       'rows' => array( 'Preferences', 'filterIntval' ),
+                       'rclimit' => array( 'Preferences', 'filterIntval' ),
+                       'wllimit' => array( 'Preferences', 'filterIntval' ),
+                       'searchlimit' => array( 'Preferences', 'filterIntval' ),
        );
 
        static function getPreferences( $user ) {
@@ -62,7 +67,7 @@ class Preferences {
                ## Prod in defaults from the user
                foreach ( $defaultPreferences as $name => &$info ) {
                        $prefFromUser = self::getOptionFromUser( $name, $info, $user );
-                       $field = HTMLForm::loadInputFromParameters( $info ); // For validation
+                       $field = HTMLForm::loadInputFromParameters( $name, $info ); // For validation
                        $defaultOptions = User::getDefaultOptions();
                        $globalDefault = isset( $defaultOptions[$name] )
                                ? $defaultOptions[$name]
@@ -98,7 +103,7 @@ class Preferences {
                        $prefix = isset( $info['prefix'] ) ? $info['prefix'] : $name;
                        $val = array();
 
-                       foreach ( $options as $label => $value ) {
+                       foreach ( $options as $value ) {
                                if ( $user->getOption( "$prefix$value" ) ) {
                                        $val[] = $value;
                                }
@@ -228,10 +233,10 @@ class Preferences {
                }
 
                // Language
-               global $wgContLanguageCode;
+               global $wgLanguageCode;
                $languages = Language::getLanguageNames( false );
-               if ( !array_key_exists( $wgContLanguageCode, $languages ) ) {
-                       $languages[$wgContLanguageCode] = $wgContLanguageCode;
+               if ( !array_key_exists( $wgLanguageCode, $languages ) ) {
+                       $languages[$wgLanguageCode] = $wgLanguageCode;
                }
                ksort( $languages );
 
@@ -529,7 +534,7 @@ class Preferences {
                $nowlocal = Xml::element( 'span', array( 'id' => 'wpLocalTime' ),
                        $wgLang->time( $now = wfTimestampNow(), true ) );
                $nowserver = $wgLang->time( $now, false ) .
-                       Xml::hidden( 'wpServerTime', substr( $now, 8, 2 ) * 60 + substr( $now, 10, 2 ) );
+                       Html::hidden( 'wpServerTime', substr( $now, 8, 2 ) * 60 + substr( $now, 10, 2 ) );
 
                $defaultPreferences['nowserver'] = array(
                        'type' => 'info',
@@ -705,6 +710,11 @@ class Preferences {
                        'section' => 'editing/advancedediting',
                        'label-message' => 'tog-showtoolbar',
                );
+               $defaultPreferences['minordefault'] = array(
+                       'type' => 'toggle',
+                       'section' => 'editing/advancedediting',
+                       'label-message' => 'tog-minordefault',
+               );
 
                if ( $wgUseExternalEditor ) {
                        $defaultPreferences['externaleditor'] = array(
@@ -1100,14 +1110,15 @@ class Preferences {
        }
 
        static function validateSignature( $signature, $alldata ) {
-               global $wgMaxSigChars, $wgLang;
+               global $wgParser, $wgMaxSigChars, $wgLang;
                if ( mb_strlen( $signature ) > $wgMaxSigChars ) {
                        return Xml::element( 'span', array( 'class' => 'error' ),
                                wfMsgExt( 'badsiglength', 'parsemag',
                                        $wgLang->formatNum( $wgMaxSigChars )
                                )
                        );
-               } elseif ( !empty( $alldata['fancysig'] ) &&
+               } elseif ( isset( $alldata['fancysig'] ) &&
+                               $alldata['fancysig'] &&
                                false === $wgParser->validateSig( $signature ) ) {
                        return Xml::element( 'span', array( 'class' => 'error' ), wfMsg( 'badsig' ) );
                } else {
@@ -1117,7 +1128,7 @@ class Preferences {
 
        static function cleanSignature( $signature, $alldata ) {
                global $wgParser;
-               if ( $alldata['fancysig'] ) {
+               if ( isset( $alldata['fancysig'] ) && $alldata['fancysig'] ) {
                        $signature = $wgParser->cleanSig( $signature );
                } else {
                        // When no fancy sig used, make sure ~{3,5} get removed.
@@ -1208,6 +1219,10 @@ class Preferences {
                }
                return $opt;
        }
+       
+       static function filterIntval( $value, $alldata ){
+               return intval( $value );
+       }
 
        static function filterTimezoneInput( $tz, $alldata ) {
                $data = explode( '|', $tz, 3 );
@@ -1217,7 +1232,6 @@ class Preferences {
                                return $tz;
                        default:
                                $data = explode( ':', $tz, 2 );
-                               $minDiff = 0;
                                if ( count( $data ) == 2 ) {
                                        $data[0] = intval( $data[0] );
                                        $data[1] = intval( $data[1] );
@@ -1267,8 +1281,8 @@ class Preferences {
                                        # Mail a temporary password to the dirty address.
                                        # User can come back through the confirmation URL to re-enable email.
                                        $result = $wgUser->sendConfirmationMail( $oldaddr != '' );
-                                       if ( WikiError::isError( $result ) ) {
-                                               return wfMsg( 'mailerror', htmlspecialchars( $result->getMessage() ) );
+                                       if ( !$result->isGood() ) {
+                                               return htmlspecialchars( $result->getWikiText( 'mailerror' ) );
                                        } elseif ( $entryPoint == 'ui' ) {
                                                $result = 'eauth';
                                        }
@@ -1323,7 +1337,7 @@ class Preferences {
                        $wgOut->redirect( $url );
                }
 
-               return true;
+               return Status::newGood();
        }
 
        public static function loadOldSearchNs( $user ) {