Index: trunk/extensions/Validator/includes/manipulations/ParamManipulationInteger.php |
— | — | @@ -0,0 +1,34 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Parameter manipulation converting the value to a integer. |
| 6 | + * |
| 7 | + * @since 0.4 |
| 8 | + * |
| 9 | + * @file ParamManipulationInteger.php |
| 10 | + * @ingroup Validator |
| 11 | + * @ingroup ParameterManipulations |
| 12 | + * |
| 13 | + * @author Jeroen De Dauw |
| 14 | + */ |
| 15 | +class ParamManipulationInteger extends ItemParameterManipulation { |
| 16 | + |
| 17 | + /** |
| 18 | + * Constructor. |
| 19 | + * |
| 20 | + * @since 0.4 |
| 21 | + */ |
| 22 | + public function __construct() { |
| 23 | + parent::__construct(); |
| 24 | + } |
| 25 | + |
| 26 | + /** |
| 27 | + * @see ItemParameterManipulation::doManipulation |
| 28 | + * |
| 29 | + * @since 0.4 |
| 30 | + */ |
| 31 | + public function doManipulation( &$value, array &$parameters ) { |
| 32 | + $value = (int)$value; |
| 33 | + } |
| 34 | + |
| 35 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/Validator/includes/manipulations/ParamManipulationInteger.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 36 | + native |
Index: trunk/extensions/Validator/includes/manipulations/ParamManipulationFloat.php |
— | — | @@ -0,0 +1,34 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Parameter manipulation converting the value to a float. |
| 6 | + * |
| 7 | + * @since 0.4 |
| 8 | + * |
| 9 | + * @file ParamManipulationFloat.php |
| 10 | + * @ingroup Validator |
| 11 | + * @ingroup ParameterManipulations |
| 12 | + * |
| 13 | + * @author Jeroen De Dauw |
| 14 | + */ |
| 15 | +class ParamManipulationFloat extends ItemParameterManipulation { |
| 16 | + |
| 17 | + /** |
| 18 | + * Constructor. |
| 19 | + * |
| 20 | + * @since 0.4 |
| 21 | + */ |
| 22 | + public function __construct() { |
| 23 | + parent::__construct(); |
| 24 | + } |
| 25 | + |
| 26 | + /** |
| 27 | + * @see ItemParameterManipulation::doManipulation |
| 28 | + * |
| 29 | + * @since 0.4 |
| 30 | + */ |
| 31 | + public function doManipulation( &$value, array &$parameters ) { |
| 32 | + $value = (float)$value; |
| 33 | + } |
| 34 | + |
| 35 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/Validator/includes/manipulations/ParamManipulationFloat.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 36 | + native |
Index: trunk/extensions/Validator/includes/Parameter.php |
— | — | @@ -618,23 +618,17 @@ |
619 | 619 | |
620 | 620 | switch( $this->type ) { |
621 | 621 | case self::TYPE_INTEGER: |
622 | | - //$manipulations[] = new (); |
| 622 | + $manipulations[] = new ParamManipulationInteger(); |
623 | 623 | break; |
624 | | - case self::TYPE_FLOAT: |
625 | | - //$manipulations[] = new (); |
| 624 | + case self::TYPE_FLOAT: case self::TYPE_NUMBER: |
| 625 | + $manipulations[] = new ParamManipulationFloat(); |
626 | 626 | break; |
627 | | - case self::TYPE_NUMBER: |
628 | | - //$manipulations[] = new (); |
629 | | - break; |
630 | 627 | case self::TYPE_BOOLEAN: |
631 | 628 | $manipulations[] = new ParamManipulationBoolean(); |
632 | 629 | break; |
633 | | - case self::TYPE_CHAR: |
634 | | - //$manipulations[] = new (); |
| 630 | + case self::TYPE_CHAR: case self::TYPE_STRING: default: |
| 631 | + // No extra manipulations for these types |
635 | 632 | break; |
636 | | - case self::TYPE_STRING: default: |
637 | | - // No extra criteria for strings. |
638 | | - break; |
639 | 633 | } |
640 | 634 | |
641 | 635 | return $manipulations; |
Index: trunk/extensions/Validator/includes/Validator.php |
— | — | @@ -11,9 +11,6 @@ |
12 | 12 | * @author Jeroen De Dauw |
13 | 13 | * |
14 | 14 | * TODO: break on fatal errors, such as missing required parameters that are dependencies |
15 | | - * TODO: correct invalid parameters in the main loop, as to have correct dependency handling |
16 | | - * TODO: settings of defaults should happen as a default behaviour that can be overiden by the output format, |
17 | | - * as it is not wished for all output formats in every case, and now a hacky approach is required there. |
18 | 15 | */ |
19 | 16 | class Validator { |
20 | 17 | |
Index: trunk/extensions/Validator/Validator.php |
— | — | @@ -82,6 +82,8 @@ |
83 | 83 | |
84 | 84 | $wgAutoloadClasses['ParamManipulationBoolean'] = $incDir . 'manipulations/ParamManipulationBoolean.php'; |
85 | 85 | $wgAutoloadClasses['ParamManipulationBoolstr'] = $incDir . 'manipulations/ParamManipulationBoolstr.php'; |
| 86 | +$wgAutoloadClasses['ParamManipulationFloat'] = $incDir . 'manipulations/ParamManipulationFloat.php'; |
| 87 | +$wgAutoloadClasses['ParamManipulationInteger'] = $incDir . 'manipulations/ParamManipulationInteger.php'; |
86 | 88 | |
87 | 89 | $wgAutoloadClasses['ValidatorListErrors'] = $incDir . 'parserHooks/Validator_ListErrors.php'; |
88 | 90 | unset( $incDir ); |