Index: trunk/extensions/Validator/Validator.class.php |
— | — | @@ -19,8 +19,6 @@ |
20 | 20 | * @ingroup Validator |
21 | 21 | * |
22 | 22 | * @author Jeroen De Dauw |
23 | | - * |
24 | | - * TODO: add native suport for default parameters as present in Maps 0.6. |
25 | 23 | */ |
26 | 24 | final class Validator { |
27 | 25 | |
— | — | @@ -55,6 +53,7 @@ |
56 | 54 | 'in_array' => array( 'ValidatorFunctions', 'in_array' ), |
57 | 55 | 'in_range' => array( 'ValidatorFunctions', 'in_range' ), |
58 | 56 | 'is_numeric' => 'is_numeric', |
| 57 | + 'is_float' => 'is_float', |
59 | 58 | 'is_integer' => array( 'ValidatorFunctions', 'is_integer' ), |
60 | 59 | 'not_empty' => array( 'ValidatorFunctions', 'not_empty' ), |
61 | 60 | 'has_length' => array( 'ValidatorFunctions', 'has_length' ), |
— | — | @@ -121,17 +120,21 @@ |
122 | 121 | */ |
123 | 122 | public function parseAndSetParams( array $rawParams, array $defaultParams = array() ) { |
124 | 123 | $parameters = array(); |
125 | | - |
| 124 | + //var_dump($rawParams); exit; |
126 | 125 | foreach( $rawParams as $arg ) { |
127 | | - $parts = explode( '=', $arg ); |
128 | | - if ( count( $parts ) == 1 ) { |
129 | | - if ( count( $defaultParams ) > 0 ) { |
130 | | - $defaultParam = array_shift( $defaultParams ); |
131 | | - $parameters[$defaultParam] = trim( $parts[0] ); |
132 | | - } |
| 126 | + if ( is_array( $arg ) ) { |
| 127 | + |
133 | 128 | } else { |
134 | | - $name = strtolower( trim( array_shift( $parts ) ) ); |
135 | | - $parameters[$name] = trim( implode( $parts ) ); |
| 129 | + $parts = explode( '=', $arg ); |
| 130 | + if ( count( $parts ) == 1 ) { |
| 131 | + if ( count( $defaultParams ) > 0 ) { |
| 132 | + $defaultParam = array_shift( $defaultParams ); |
| 133 | + $parameters[$defaultParam] = trim( $parts[0] ); |
| 134 | + } |
| 135 | + } else { |
| 136 | + $name = strtolower( trim( array_shift( $parts ) ) ); |
| 137 | + $parameters[$name] = trim( implode( $parts ) ); |
| 138 | + } |
136 | 139 | } |
137 | 140 | } |
138 | 141 | |
— | — | @@ -253,8 +256,7 @@ |
254 | 257 | $this->addTypeCriteria( $name, 'is_integer' ); |
255 | 258 | break; |
256 | 259 | case 'float': |
257 | | - // FIXME: only accept floats, not the weird crap is_numeric also accepts |
258 | | - $this->addTypeCriteria( $name, 'is_numeric' ); |
| 260 | + $this->addTypeCriteria( $name, 'is_float' ); |
259 | 261 | break; |
260 | 262 | case 'number': // Note: This accepts non-decimal notations! |
261 | 263 | $this->addTypeCriteria( $name, 'is_numeric' ); |
Index: trunk/extensions/Validator/Validator_Manager.php |
— | — | @@ -36,7 +36,7 @@ |
37 | 37 | * @param array $defaultParams |
38 | 38 | * @return array or false The valid parameters or false when the output should not be shown. |
39 | 39 | */ |
40 | | - public function manageMapparameters( array $rawParameters, array $parameterInfo, array $defaultParams = array() ) { |
| 40 | + public function manageParameters( array $rawParameters, array $parameterInfo, array $defaultParams = array() ) { |
41 | 41 | global $egValidatorErrorLevel; |
42 | 42 | |
43 | 43 | $validator = new Validator(); |