r53423 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53422‎ | r53423 | r53424 >
Date:22:19, 17 July 2009
Author:simetrical
Status:ok
Tags:
Comment:
Allow non-integral days for watchlists and RC

Fixes bug 19296. This was a regression due to the preferences work.
Modified paths:
  • /trunk/phase3/includes/HTMLForm.php (modified) (history)
  • /trunk/phase3/includes/Preferences.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/HTMLForm.php
@@ -20,6 +20,7 @@
2121 'check' => 'HTMLCheckField',
2222 'toggle' => 'HTMLCheckField',
2323 'int' => 'HTMLIntField',
 24+ 'float' => 'HTMLFloatField',
2425 'info' => 'HTMLInfoField',
2526 'selectorother' => 'HTMLSelectOrOtherField',
2627 );
@@ -524,7 +525,7 @@
525526
526527 }
527528
528 -class HTMLIntField extends HTMLTextField {
 529+class HTMLFloatField extends HTMLTextField {
529530 function getSize() {
530531 return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 20;
531532 }
@@ -532,14 +533,16 @@
533534 function validate( $value, $alldata ) {
534535 $p = parent::validate( $value, $alldata );
535536
536 - if( $p !== true ) return $p;
 537+ if ( $p !== true ) return $p;
537538
538 - if ( intval( $value ) != $value ) {
539 - return wfMsgExt( 'htmlform-int-invalid', 'parse' );
 539+ if ( floatval( $value ) != $value ) {
 540+ return wfMsgExt( 'htmlform-float-invalid', 'parse' );
540541 }
541542
542543 $in_range = true;
543544
 545+ # The "int" part of these message names is rather confusing. They make
 546+ # equal sense for all numbers.
544547 if ( isset( $this->mParams['min'] ) ) {
545548 $min = $this->mParams['min'];
546549 if ( $min > $value )
@@ -556,6 +559,20 @@
557560 }
558561 }
559562
 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+
560577 class HTMLCheckField extends HTMLFormField {
561578 function getInputHTML( $value ) {
562579 if ( !empty( $this->mParams['invert'] ) )
Index: trunk/phase3/includes/Preferences.php
@@ -689,7 +689,7 @@
690690 ## RecentChanges #####################################
691691 $defaultPreferences['rcdays'] =
692692 array(
693 - 'type' => 'int',
 693+ 'type' => 'float',
694694 'label-message' => 'recentchangesdays',
695695 'section' => 'rc/display',
696696 'min' => 1,
@@ -747,7 +747,7 @@
748748 ## Watchlist #####################################
749749 $defaultPreferences['watchlistdays'] =
750750 array(
751 - 'type' => 'int',
 751+ 'type' => 'float',
752752 'min' => 0,
753753 'max' => 7,
754754 'section' => 'watchlist/display',
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -4112,6 +4112,7 @@
41134113 'htmlform-invalid-input' => 'There are problems with some of your input',
41144114 'htmlform-select-badoption' => 'The value you specified is not a valid option.',
41154115 'htmlform-int-invalid' => 'The value you specified is not an integer.',
 4116+'htmlform-float-invalid' => 'The value you specified is not a number.',
41164117 'htmlform-int-toolow' => 'The value you specified is below the minimum of $1',
41174118 'htmlform-int-toohigh' => 'The value you specified is above the maximum of $1',
41184119 'htmlform-submit' => 'Submit',

Follow-up revisions

RevisionCommit summaryAuthorDate
r53425Update messages.inc for r53423simetrical22:30, 17 July 2009

Status & tagging log