Index: trunk/phase3/includes/HTMLForm.php |
— | — | @@ -20,6 +20,7 @@ |
21 | 21 | 'check' => 'HTMLCheckField', |
22 | 22 | 'toggle' => 'HTMLCheckField', |
23 | 23 | 'int' => 'HTMLIntField', |
| 24 | + 'float' => 'HTMLFloatField', |
24 | 25 | 'info' => 'HTMLInfoField', |
25 | 26 | 'selectorother' => 'HTMLSelectOrOtherField', |
26 | 27 | ); |
— | — | @@ -524,7 +525,7 @@ |
525 | 526 | |
526 | 527 | } |
527 | 528 | |
528 | | -class HTMLIntField extends HTMLTextField { |
| 529 | +class HTMLFloatField extends HTMLTextField { |
529 | 530 | function getSize() { |
530 | 531 | return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 20; |
531 | 532 | } |
— | — | @@ -532,14 +533,16 @@ |
533 | 534 | function validate( $value, $alldata ) { |
534 | 535 | $p = parent::validate( $value, $alldata ); |
535 | 536 | |
536 | | - if( $p !== true ) return $p; |
| 537 | + if ( $p !== true ) return $p; |
537 | 538 | |
538 | | - if ( intval( $value ) != $value ) { |
539 | | - return wfMsgExt( 'htmlform-int-invalid', 'parse' ); |
| 539 | + if ( floatval( $value ) != $value ) { |
| 540 | + return wfMsgExt( 'htmlform-float-invalid', 'parse' ); |
540 | 541 | } |
541 | 542 | |
542 | 543 | $in_range = true; |
543 | 544 | |
| 545 | + # The "int" part of these message names is rather confusing. They make |
| 546 | + # equal sense for all numbers. |
544 | 547 | if ( isset( $this->mParams['min'] ) ) { |
545 | 548 | $min = $this->mParams['min']; |
546 | 549 | if ( $min > $value ) |
— | — | @@ -556,6 +559,20 @@ |
557 | 560 | } |
558 | 561 | } |
559 | 562 | |
| 563 | +class HTMLIntField extends HTMLFloatField { |
| 564 | + function validate( $value, $alldata ) { |
| 565 | + $p = parent::validate( $value, $alldata ); |
| 566 | + |
| 567 | + if ( $p !== true ) return $p; |
| 568 | + |
| 569 | + if ( intval( $value ) != $value ) { |
| 570 | + return wfMsgExt( 'htmlform-int-invalid', 'parse' ); |
| 571 | + } |
| 572 | + |
| 573 | + return true; |
| 574 | + } |
| 575 | +} |
| 576 | + |
560 | 577 | class HTMLCheckField extends HTMLFormField { |
561 | 578 | function getInputHTML( $value ) { |
562 | 579 | if ( !empty( $this->mParams['invert'] ) ) |
Index: trunk/phase3/includes/Preferences.php |
— | — | @@ -689,7 +689,7 @@ |
690 | 690 | ## RecentChanges ##################################### |
691 | 691 | $defaultPreferences['rcdays'] = |
692 | 692 | array( |
693 | | - 'type' => 'int', |
| 693 | + 'type' => 'float', |
694 | 694 | 'label-message' => 'recentchangesdays', |
695 | 695 | 'section' => 'rc/display', |
696 | 696 | 'min' => 1, |
— | — | @@ -747,7 +747,7 @@ |
748 | 748 | ## Watchlist ##################################### |
749 | 749 | $defaultPreferences['watchlistdays'] = |
750 | 750 | array( |
751 | | - 'type' => 'int', |
| 751 | + 'type' => 'float', |
752 | 752 | 'min' => 0, |
753 | 753 | 'max' => 7, |
754 | 754 | 'section' => 'watchlist/display', |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -4112,6 +4112,7 @@ |
4113 | 4113 | 'htmlform-invalid-input' => 'There are problems with some of your input', |
4114 | 4114 | 'htmlform-select-badoption' => 'The value you specified is not a valid option.', |
4115 | 4115 | 'htmlform-int-invalid' => 'The value you specified is not an integer.', |
| 4116 | +'htmlform-float-invalid' => 'The value you specified is not a number.', |
4116 | 4117 | 'htmlform-int-toolow' => 'The value you specified is below the minimum of $1', |
4117 | 4118 | 'htmlform-int-toohigh' => 'The value you specified is above the maximum of $1', |
4118 | 4119 | 'htmlform-submit' => 'Submit', |