'check' => 'HTMLCheckField',
'toggle' => 'HTMLCheckField',
'int' => 'HTMLIntField',
+ 'float' => 'HTMLFloatField',
'info' => 'HTMLInfoField',
'selectorother' => 'HTMLSelectOrOtherField',
);
}
-class HTMLIntField extends HTMLTextField {
+class HTMLFloatField extends HTMLTextField {
function getSize() {
return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 20;
}
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 )
}
}
+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'] ) )
## RecentChanges #####################################
$defaultPreferences['rcdays'] =
array(
- 'type' => 'int',
+ 'type' => 'float',
'label-message' => 'recentchangesdays',
'section' => 'rc/display',
'min' => 1,
## Watchlist #####################################
$defaultPreferences['watchlistdays'] =
array(
- 'type' => 'int',
+ 'type' => 'float',
'min' => 0,
'max' => 7,
'section' => 'watchlist/display',
'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',