Allow non-integral days for watchlists and RC
authorAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 17 Jul 2009 22:19:02 +0000 (22:19 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 17 Jul 2009 22:19:02 +0000 (22:19 +0000)
Fixes bug 19296.  This was a regression due to the preferences work.

includes/HTMLForm.php
includes/Preferences.php
languages/messages/MessagesEn.php

index 9d3c38e..f634c5b 100644 (file)
@@ -20,6 +20,7 @@ class HTMLForm {
                'check' => 'HTMLCheckField',
                'toggle' => 'HTMLCheckField',
                'int' => 'HTMLIntField',
+               'float' => 'HTMLFloatField',
                'info' => 'HTMLInfoField',
                'selectorother' => 'HTMLSelectOrOtherField',
        );
@@ -524,7 +525,7 @@ class HTMLTextField extends HTMLFormField {
 
 }
 
-class HTMLIntField extends HTMLTextField {
+class HTMLFloatField extends HTMLTextField {
        function getSize() {
                return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 20;
        }
@@ -532,14 +533,16 @@ class HTMLIntField extends HTMLTextField {
        function validate( $value, $alldata ) {
                $p = parent::validate( $value, $alldata );
 
-               if( $p !== true ) return $p;
+               if ( $p !== true ) return $p;
 
-               if ( intval( $value ) != $value ) {
-                       return wfMsgExt( 'htmlform-int-invalid', 'parse' );
+               if ( floatval( $value ) != $value ) {
+                       return wfMsgExt( 'htmlform-float-invalid', 'parse' );
                }
 
                $in_range = true;
 
+               # The "int" part of these message names is rather confusing.  They make
+               # equal sense for all numbers.
                if ( isset( $this->mParams['min'] ) ) {
                        $min = $this->mParams['min'];
                        if ( $min > $value )
@@ -556,6 +559,20 @@ class HTMLIntField extends HTMLTextField {
        }
 }
 
+class HTMLIntField extends HTMLFloatField {
+       function validate( $value, $alldata ) {
+               $p = parent::validate( $value, $alldata );
+
+               if ( $p !== true ) return $p;
+
+               if ( intval( $value ) != $value ) {
+                       return wfMsgExt( 'htmlform-int-invalid', 'parse' );
+               }
+
+               return true;
+       }
+}
+
 class HTMLCheckField extends HTMLFormField {
        function getInputHTML( $value ) {
                if ( !empty( $this->mParams['invert'] ) )
index 279b1a8..7e068b0 100644 (file)
@@ -689,7 +689,7 @@ class Preferences {
                ## RecentChanges #####################################
                $defaultPreferences['rcdays'] =
                                array(
-                                       'type' => 'int',
+                                       'type' => 'float',
                                        'label-message' => 'recentchangesdays',
                                        'section' => 'rc/display',
                                        'min' => 1,
@@ -747,7 +747,7 @@ class Preferences {
                ## Watchlist #####################################
                $defaultPreferences['watchlistdays'] =
                                array(
-                                       'type' => 'int',
+                                       'type' => 'float',
                                        'min' => 0,
                                        'max' => 7,
                                        'section' => 'watchlist/display',
index 3519301..6e90772 100644 (file)
@@ -4112,6 +4112,7 @@ Enter the filename without the "{{ns:file}}:" prefix.',
 'htmlform-invalid-input'       => 'There are problems with some of your input',
 'htmlform-select-badoption'    => 'The value you specified is not a valid option.',
 'htmlform-int-invalid'         => 'The value you specified is not an integer.',
+'htmlform-float-invalid'       => 'The value you specified is not a number.',
 'htmlform-int-toolow'          => 'The value you specified is below the minimum of $1',
 'htmlform-int-toohigh'         => 'The value you specified is above the maximum of $1',
 'htmlform-submit'              => 'Submit',