From: Aryeh Gregor Date: Fri, 17 Jul 2009 22:19:02 +0000 (+0000) Subject: Allow non-integral days for watchlists and RC X-Git-Tag: 1.31.0-rc.0~40865 X-Git-Url: https://git.heureux-cyclage.org/?a=commitdiff_plain;h=5ed6a1ec3a40d8511d42c729a6c12dc6be4be8c6;p=lhc%2Fweb%2Fwiklou.git Allow non-integral days for watchlists and RC Fixes bug 19296. This was a regression due to the preferences work. --- diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php index 9d3c38e986..f634c5b9e4 100644 --- a/includes/HTMLForm.php +++ b/includes/HTMLForm.php @@ -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'] ) ) diff --git a/includes/Preferences.php b/includes/Preferences.php index 279b1a8f67..7e068b0851 100644 --- a/includes/Preferences.php +++ b/includes/Preferences.php @@ -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', diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 3519301375..6e907728bf 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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',