Index: trunk/extensions/Validator/includes/ItemParameterManipualtion.php |
— | — | @@ -1,64 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * Item parameter manipulation base class. This is for manipulations |
6 | | - * that apply to individial values, which can either be the whole value |
7 | | - * of a non-list parameter, or a single item of a list parameter. |
8 | | - * |
9 | | - * @since 0.4 |
10 | | - * |
11 | | - * @file ItemParameterManipulation.php |
12 | | - * @ingroup Validator |
13 | | - * @ingroup ParameterManipulations |
14 | | - * |
15 | | - * @author Jeroen De Dauw |
16 | | - */ |
17 | | -abstract class ItemParameterManipulation extends ParameterManipulation { |
18 | | - |
19 | | - /** |
20 | | - * Manipulate an actual value. |
21 | | - * |
22 | | - * @param string $value |
23 | | - * @param array $parameters |
24 | | - * |
25 | | - * @since 0.4 |
26 | | - * |
27 | | - * @return mixed |
28 | | - */ |
29 | | - protected abstract function doManipulation( &$value, array &$parameters ); |
30 | | - |
31 | | - /** |
32 | | - * Constructor. |
33 | | - * |
34 | | - * @since 0.4 |
35 | | - */ |
36 | | - public function __construct() { |
37 | | - parent::__construct(); |
38 | | - } |
39 | | - |
40 | | - /** |
41 | | - * @see ParameterManipulation::isForLists |
42 | | - */ |
43 | | - public function isForLists() { |
44 | | - return false; |
45 | | - } |
46 | | - /** |
47 | | - * Validate a parameter against the criterion. |
48 | | - * |
49 | | - * @param Parameter $parameter |
50 | | - * @param array $parameters |
51 | | - * |
52 | | - * @since 0.4 |
53 | | - */ |
54 | | - public abstract function manipulate( Parameter &$parameter, array &$parameters ) { |
55 | | - if ( is_array( $parameter->value ) ) { |
56 | | - foreach ( $parameter->value as &$item ) { |
57 | | - $this->doManipulation( $item, $parameters ); |
58 | | - } |
59 | | - } |
60 | | - else { |
61 | | - $this->doManipulation( $parameter->value, $parameters ); |
62 | | - } |
63 | | - } |
64 | | - |
65 | | -} |
\ No newline at end of file |
Index: trunk/extensions/Validator/includes/ValidationFormats.php |
— | — | @@ -1,123 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * Class holding variouse static methods for the appliance of output formats. |
6 | | - * |
7 | | - * @file ValidationFormats.php |
8 | | - * @ingroup Validator |
9 | | - * |
10 | | - * @author Jeroen De Dauw |
11 | | - */ |
12 | | -final class ValidationFormats { |
13 | | - |
14 | | - /** |
15 | | - * Ensures the value is an array. |
16 | | - * |
17 | | - * @param $value |
18 | | - * @param string name The name of the parameter. |
19 | | - * @param array $parameters Array containing data about the so far handled parameters. |
20 | | - */ |
21 | | - public static function format_array( &$value, $name, array $parameters ) { |
22 | | - if ( ! is_array( $value ) ) $value = array( $value ); |
23 | | - } |
24 | | - |
25 | | - /** |
26 | | - * Returns an array containing only the specified values. |
27 | | - * |
28 | | - * @param $value |
29 | | - * @param string name The name of the parameter. |
30 | | - * @param array $parameters Array containing data about the so far handled parameters. |
31 | | - */ |
32 | | - public static function format_filtered_array( &$value, $name, array $parameters ) { |
33 | | - // TODO: It's possible the way the allowed values are passed here is quite inneficient... |
34 | | - $params = func_get_args(); |
35 | | - array_shift( $params ); // Ommit the value |
36 | | - |
37 | | - self::format_array( $value, $name, $parameters ); |
38 | | - $filtered = array(); |
39 | | - foreach ( $value as $item ) if ( in_array( $item, $params ) ) $filtered[] = $item; |
40 | | - |
41 | | - return $filtered; |
42 | | - } |
43 | | - |
44 | | - /** |
45 | | - * Changes the value to list notation, by separating items with a delimiter, |
46 | | - * and/or adding wrappers before and after the items. Intended for lists, but |
47 | | - * will also work for single values. |
48 | | - * |
49 | | - * @param $value |
50 | | - * @param string name The name of the parameter. |
51 | | - * @param array $parameters Array containing data about the so far handled parameters. |
52 | | - * @param $delimiter |
53 | | - * @param $wrapper |
54 | | - */ |
55 | | - public static function format_list( &$value, $name, array $parameters, $delimiter = ',', $wrapper = '' ) { |
56 | | - self::format_array( $value, $name, $parameters ); |
57 | | - $value = $wrapper . implode( $wrapper . $delimiter . $wrapper, $value ) . $wrapper; |
58 | | - } |
59 | | - |
60 | | - /** |
61 | | - * Changes every value into a boolean. |
62 | | - * |
63 | | - * TODO: work with a list of true-values. |
64 | | - * |
65 | | - * @param $value |
66 | | - * @param string name The name of the parameter. |
67 | | - * @param array $parameters Array containing data about the so far handled parameters. |
68 | | - */ |
69 | | - public static function format_boolean( &$value, $name, array $parameters ) { |
70 | | - if ( is_array( $value ) ) { |
71 | | - $boolArray = array(); |
72 | | - foreach ( $value as $item ) $boolArray[] = in_array( $item, array( 'yes', 'on' ) ); |
73 | | - $value = $boolArray; |
74 | | - } |
75 | | - else { |
76 | | - $value = in_array( $value, array( 'yes', 'on' ) ); |
77 | | - } |
78 | | - } |
79 | | - |
80 | | - /** |
81 | | - * Changes every value into a boolean, represented by a 'false' or 'true' string. |
82 | | - * |
83 | | - * @param $value |
84 | | - * @param string name The name of the parameter. |
85 | | - * @param array $parameters Array containing data about the so far handled parameters. |
86 | | - */ |
87 | | - public static function format_boolean_string( &$value, $name, array $parameters ) { |
88 | | - self::format_boolean( $value, $name, $parameters ); |
89 | | - if ( is_array( $value ) ) { |
90 | | - $boolArray = array(); |
91 | | - foreach ( $value as $item ) $boolArray[] = $item ? 'true' : 'false'; |
92 | | - $value = $boolArray; |
93 | | - } |
94 | | - else { |
95 | | - $value = $value ? 'true' : 'false'; |
96 | | - } |
97 | | - } |
98 | | - |
99 | | - /** |
100 | | - * Changes lists into strings, by enumerating the items using $wgLang->listToText. |
101 | | - * |
102 | | - * @param $value |
103 | | - * @param string name The name of the parameter. |
104 | | - * @param array $parameters Array containing data about the so far handled parameters. |
105 | | - */ |
106 | | - public static function format_string( &$value, $name, array $parameters ) { |
107 | | - if ( is_array( $value ) ) { |
108 | | - global $wgLang; |
109 | | - $value = $wgLang->listToText( $value ); |
110 | | - } |
111 | | - } |
112 | | - |
113 | | - /** |
114 | | - * Removes duplicate items from lists. |
115 | | - * |
116 | | - * @param $value |
117 | | - * @param string name The name of the parameter. |
118 | | - * @param array $parameters Array containing data about the so far handled parameters. |
119 | | - */ |
120 | | - public static function format_unique_items( &$value, $name, array $parameters ) { |
121 | | - if ( is_array( $value ) ) $value = array_unique( $value ); |
122 | | - } |
123 | | - |
124 | | -} |
\ No newline at end of file |
Index: trunk/extensions/Validator/includes/manipulations/ParamManipualtionBoolean.php |
— | — | @@ -1,34 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * Parameter manipulation converting the value to a boolean. |
6 | | - * |
7 | | - * @since 0.4 |
8 | | - * |
9 | | - * @file ParamManipulationBoolean.php |
10 | | - * @ingroup Validator |
11 | | - * @ingroup ParameterManipulations |
12 | | - * |
13 | | - * @author Jeroen De Dauw |
14 | | - */ |
15 | | -class ParamManipulationBoolean 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 = in_array( $value, array( 'yes', 'on' ) ); |
33 | | - } |
34 | | - |
35 | | -} |
\ No newline at end of file |
Index: trunk/extensions/Validator/includes/manipulations/ParamManipulationBoolean.php |
— | — | @@ -0,0 +1,34 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Parameter manipulation converting the value to a boolean. |
| 6 | + * |
| 7 | + * @since 0.4 |
| 8 | + * |
| 9 | + * @file ParamManipulationBoolean.php |
| 10 | + * @ingroup Validator |
| 11 | + * @ingroup ParameterManipulations |
| 12 | + * |
| 13 | + * @author Jeroen De Dauw |
| 14 | + */ |
| 15 | +class ParamManipulationBoolean 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 = in_array( $value, array( 'yes', 'on' ) ); |
| 33 | + } |
| 34 | + |
| 35 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/Validator/includes/manipulations/ParamManipulationBoolean.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 36 | + native |
Index: trunk/extensions/Validator/includes/manipulations/ParamManipulationBoolstr.php |
— | — | @@ -0,0 +1,34 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Parameter manipulation converting the value to a boolean value as string. |
| 6 | + * |
| 7 | + * @since 0.4 |
| 8 | + * |
| 9 | + * @file ParamManipulationBoolstr.php |
| 10 | + * @ingroup Validator |
| 11 | + * @ingroup ParameterManipulations |
| 12 | + * |
| 13 | + * @author Jeroen De Dauw |
| 14 | + */ |
| 15 | +class ParamManipulationBoolstr 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 = $value ? 'true' : 'false'; |
| 33 | + } |
| 34 | + |
| 35 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/Validator/includes/manipulations/ParamManipulationBoolstr.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 36 | + native |
Index: trunk/extensions/Validator/includes/ParserHook.php |
— | — | @@ -161,8 +161,6 @@ |
162 | 162 | $output = 'Demo: fatal error'; |
163 | 163 | } |
164 | 164 | else { |
165 | | - $this->validator->formatParameters(); |
166 | | - |
167 | 165 | $output = $this->render( $this->validator->getParameterValues() ); |
168 | 166 | } |
169 | 167 | |
Index: trunk/extensions/Validator/includes/ItemParameterManipulation.php |
— | — | @@ -0,0 +1,64 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * Item parameter manipulation base class. This is for manipulations |
| 6 | + * that apply to individial values, which can either be the whole value |
| 7 | + * of a non-list parameter, or a single item of a list parameter. |
| 8 | + * |
| 9 | + * @since 0.4 |
| 10 | + * |
| 11 | + * @file ItemParameterManipulation.php |
| 12 | + * @ingroup Validator |
| 13 | + * @ingroup ParameterManipulations |
| 14 | + * |
| 15 | + * @author Jeroen De Dauw |
| 16 | + */ |
| 17 | +abstract class ItemParameterManipulation extends ParameterManipulation { |
| 18 | + |
| 19 | + /** |
| 20 | + * Manipulate an actual value. |
| 21 | + * |
| 22 | + * @param string $value |
| 23 | + * @param array $parameters |
| 24 | + * |
| 25 | + * @since 0.4 |
| 26 | + * |
| 27 | + * @return mixed |
| 28 | + */ |
| 29 | + protected abstract function doManipulation( &$value, array &$parameters ); |
| 30 | + |
| 31 | + /** |
| 32 | + * Constructor. |
| 33 | + * |
| 34 | + * @since 0.4 |
| 35 | + */ |
| 36 | + public function __construct() { |
| 37 | + parent::__construct(); |
| 38 | + } |
| 39 | + |
| 40 | + /** |
| 41 | + * @see ParameterManipulation::isForLists |
| 42 | + */ |
| 43 | + public function isForLists() { |
| 44 | + return false; |
| 45 | + } |
| 46 | + /** |
| 47 | + * Validate a parameter against the criterion. |
| 48 | + * |
| 49 | + * @param Parameter $parameter |
| 50 | + * @param array $parameters |
| 51 | + * |
| 52 | + * @since 0.4 |
| 53 | + */ |
| 54 | + public function manipulate( Parameter &$parameter, array &$parameters ) { |
| 55 | + if ( is_array( $parameter->value ) ) { |
| 56 | + foreach ( $parameter->value as &$item ) { |
| 57 | + $this->doManipulation( $item, $parameters ); |
| 58 | + } |
| 59 | + } |
| 60 | + else { |
| 61 | + $this->doManipulation( $parameter->value, $parameters ); |
| 62 | + } |
| 63 | + } |
| 64 | + |
| 65 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/Validator/includes/ItemParameterManipulation.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 66 | + native |
Index: trunk/extensions/Validator/includes/Parameter.php |
— | — | @@ -67,15 +67,6 @@ |
68 | 68 | public $default; |
69 | 69 | |
70 | 70 | /** |
71 | | - * List of formatting functions to shape the final form of the parameter value. |
72 | | - * |
73 | | - * @since 0.4 |
74 | | - * |
75 | | - * @var array |
76 | | - */ |
77 | | - public $outputTypes = array(); |
78 | | - |
79 | | - /** |
80 | 71 | * The main name of the parameter. |
81 | 72 | * |
82 | 73 | * @since 0.4 |
— | — | @@ -109,9 +100,18 @@ |
110 | 101 | * |
111 | 102 | * @var array of ParameterCriterion |
112 | 103 | */ |
113 | | - protected $criteria; |
| 104 | + protected $criteria = array(); |
114 | 105 | |
115 | 106 | /** |
| 107 | + * List of manipulations the parameter value needs to undergo. |
| 108 | + * |
| 109 | + * @since 0.4 |
| 110 | + * |
| 111 | + * @var array of ParameterManipulation |
| 112 | + */ |
| 113 | + protected $manipulations = array(); |
| 114 | + |
| 115 | + /** |
116 | 116 | * The original parameter name as provided by the user. This can be the |
117 | 117 | * main name or an alias. |
118 | 118 | * |
— | — | @@ -297,10 +297,32 @@ |
298 | 298 | } |
299 | 299 | |
300 | 300 | /** |
| 301 | + * Adds one or more ParameterCriterion. |
301 | 302 | * |
| 303 | + * @since 0.4 |
302 | 304 | * |
| 305 | + * @param mixed $criteria ParameterCriterion or array of ParameterCriterion |
| 306 | + */ |
| 307 | + public function addCriteria( $criteria ) { |
| 308 | + $this->criteria = array_merge( $this->criteria, (array)$criteria ); |
| 309 | + } |
| 310 | + |
| 311 | + /** |
| 312 | + * Adds one or more ParameterManipulation. |
| 313 | + * |
303 | 314 | * @since 0.4 |
304 | 315 | * |
| 316 | + * @param mixed $criteria ParameterManipulation or array of ParameterManipulation |
| 317 | + */ |
| 318 | + public function addManipulations( $manipulations ) { |
| 319 | + $this->manipulations = array_merge( $this->manipulations, (array)$manipulations ); |
| 320 | + } |
| 321 | + |
| 322 | + /** |
| 323 | + * |
| 324 | + * |
| 325 | + * @since 0.4 |
| 326 | + * |
305 | 327 | * @param string $paramName |
306 | 328 | * @param string $paramValue |
307 | 329 | * |
— | — | @@ -367,6 +389,19 @@ |
368 | 390 | } |
369 | 391 | |
370 | 392 | /** |
| 393 | + * Applies the parameter manipulations. |
| 394 | + * |
| 395 | + * @since 0.4 |
| 396 | + * |
| 397 | + * @param array $parameters |
| 398 | + */ |
| 399 | + public function format( array &$parameters ) { |
| 400 | + foreach ( $this->getManipulations() as $manipulation ) { |
| 401 | + $manipulation->manipulate( $this, $parameters ); |
| 402 | + } |
| 403 | + } |
| 404 | + |
| 405 | + /** |
371 | 406 | * Validates the parameter value. |
372 | 407 | * |
373 | 408 | * @since 0.4 |
— | — | @@ -526,6 +561,17 @@ |
527 | 562 | } |
528 | 563 | |
529 | 564 | /** |
| 565 | + * Returns the parameter manipulations. |
| 566 | + * |
| 567 | + * @since 0.4 |
| 568 | + * |
| 569 | + * @return array of ParameterManipulation |
| 570 | + */ |
| 571 | + public function getManipulations() { |
| 572 | + return array_merge( $this->getManipulationsForType(), $this->manipulations ); |
| 573 | + } |
| 574 | + |
| 575 | + /** |
530 | 576 | * Gets the criteria for the type of the parameter. |
531 | 577 | * |
532 | 578 | * @since 0.4 |
— | — | @@ -535,8 +581,6 @@ |
536 | 582 | protected function getCriteriaForType() { |
537 | 583 | $criteria = array(); |
538 | 584 | |
539 | | - // TODO: also have similar auto-adding of manipulations |
540 | | - |
541 | 585 | switch( $this->type ) { |
542 | 586 | case self::TYPE_INTEGER: |
543 | 587 | $criteria[] = new CriterionIsInteger(); |
— | — | @@ -544,7 +588,7 @@ |
545 | 589 | case self::TYPE_FLOAT: |
546 | 590 | $criteria[] = new CriterionIsFloat(); |
547 | 591 | break; |
548 | | - case self::TYPE_FLOAT: // Note: This accepts non-decimal notations! |
| 592 | + case self::TYPE_NUMBER: // Note: This accepts non-decimal notations! |
549 | 593 | $criteria[] = new CriterionIsNumeric(); |
550 | 594 | break; |
551 | 595 | case self::TYPE_BOOLEAN: |
— | — | @@ -563,6 +607,40 @@ |
564 | 608 | } |
565 | 609 | |
566 | 610 | /** |
| 611 | + * Gets the manipulation for the type of the parameter. |
| 612 | + * |
| 613 | + * @since 0.4 |
| 614 | + * |
| 615 | + * @return array |
| 616 | + */ |
| 617 | + protected function getManipulationsForType() { |
| 618 | + $manipulations = array(); |
| 619 | + |
| 620 | + switch( $this->type ) { |
| 621 | + case self::TYPE_INTEGER: |
| 622 | + //$manipulations[] = new (); |
| 623 | + break; |
| 624 | + case self::TYPE_FLOAT: |
| 625 | + //$manipulations[] = new (); |
| 626 | + break; |
| 627 | + case self::TYPE_NUMBER: |
| 628 | + //$manipulations[] = new (); |
| 629 | + break; |
| 630 | + case self::TYPE_BOOLEAN: |
| 631 | + $manipulations[] = new ParamManipulationBoolean(); |
| 632 | + break; |
| 633 | + case self::TYPE_CHAR: |
| 634 | + //$manipulations[] = new (); |
| 635 | + break; |
| 636 | + case self::TYPE_STRING: default: |
| 637 | + // No extra criteria for strings. |
| 638 | + break; |
| 639 | + } |
| 640 | + |
| 641 | + return $manipulations; |
| 642 | + } |
| 643 | + |
| 644 | + /** |
567 | 645 | * Returns the criteria that apply to the list as a whole. |
568 | 646 | * |
569 | 647 | * @since 0.4 |
Index: trunk/extensions/Validator/includes/Validator.php |
— | — | @@ -16,21 +16,6 @@ |
17 | 17 | * as it is not wished for all output formats in every case, and now a hacky approach is required there. |
18 | 18 | */ |
19 | 19 | class Validator { |
20 | | - |
21 | | - /** |
22 | | - * @deprecated TODO: remove |
23 | | - * |
24 | | - * @var array Holder for the formatting functions. |
25 | | - */ |
26 | | - protected static $mOutputFormats = array( |
27 | | - 'array' => array( 'ValidationFormats', 'format_array' ), |
28 | | - 'list' => array( 'ValidationFormats', 'format_list' ), |
29 | | - 'boolean' => array( 'ValidationFormats', 'format_boolean' ), |
30 | | - 'boolstr' => array( 'ValidationFormats', 'format_boolean_string' ), |
31 | | - 'string' => array( 'ValidationFormats', 'format_string' ), |
32 | | - 'unique_items' => array( 'ValidationFormats', 'format_unique_items' ), |
33 | | - 'filtered_array' => array( 'ValidationFormats', 'format_filtered_array' ), |
34 | | - ); |
35 | 20 | |
36 | 21 | /** |
37 | 22 | * Array containing the parameters. |
— | — | @@ -71,20 +56,6 @@ |
72 | 57 | } |
73 | 58 | |
74 | 59 | /** |
75 | | - * @deprecated TODO: remove |
76 | | - * |
77 | | - * Adds a new output format and the formatting function that should validate values of this type. |
78 | | - * You can use this function to override existing criteria type handlers. |
79 | | - * |
80 | | - * @param string $formatName The name of the format. |
81 | | - * @param array $functionName The functions location. If it's a global function, only the name, |
82 | | - * if it's in a class, first the class name, then the method name. |
83 | | - */ |
84 | | - public static function addOutputFormat( $formatName, array $functionName ) { |
85 | | - self::$mOutputFormats[strtolower( $formatName )] = $functionName; |
86 | | - } |
87 | | - |
88 | | - /** |
89 | 60 | * Determines the names and values of all parameters. Also takes care of default parameters. |
90 | 61 | * After that the resulting parameter list is passed to Validator::setParameters |
91 | 62 | * |
— | — | @@ -145,6 +116,7 @@ |
146 | 117 | $defaultParams = $newDefaults; |
147 | 118 | } |
148 | 119 | } |
| 120 | + |
149 | 121 | $nr++; |
150 | 122 | } |
151 | 123 | |
— | — | @@ -272,7 +244,7 @@ |
273 | 245 | } |
274 | 246 | |
275 | 247 | /** |
276 | | - * Validates all the parameters (but aborts when a fatal error occurs). |
| 248 | + * Validates and formats all the parameters (but aborts when a fatal error occurs). |
277 | 249 | * |
278 | 250 | * @since 0.4 |
279 | 251 | */ |
— | — | @@ -289,37 +261,19 @@ |
290 | 262 | foreach ( $orderedParameters as $paramName ) { |
291 | 263 | $parameter = $this->parameters[$paramName]; |
292 | 264 | |
293 | | - if ( !$parameter->validate() ) { |
| 265 | + $validationSucceeded = $parameter->validate(); |
| 266 | + |
| 267 | + if ( !$validationSucceeded ) { |
294 | 268 | foreach ( $parameter->getErrors() as $error ) { |
295 | 269 | $this->registerError( $error ); |
296 | 270 | } |
297 | 271 | } |
| 272 | + |
| 273 | + $parameter->format( $this->parameters ); |
298 | 274 | } |
299 | 275 | } |
300 | 276 | |
301 | 277 | /** |
302 | | - * Applies the output formats to all parameters. |
303 | | - * |
304 | | - * @param string $name |
305 | | - */ |
306 | | - public function formatParameters() { |
307 | | - foreach ( $this->parameters as $parameter ) { |
308 | | - foreach ( $parameter->outputTypes as $outputType ) { |
309 | | - $outputType[0] = strtolower( $outputType[0] ); |
310 | | - if ( array_key_exists( $outputType[0], self::$mOutputFormats ) ) { |
311 | | - $parameters = array( &$parameter->value, $parameter->getName(), $this->parameters ); |
312 | | - $name = array_shift( $outputType ); |
313 | | - $parameters = array_merge( $parameters, $outputType ); |
314 | | - call_user_func_array( self::$mOutputFormats[$name], $parameters ); |
315 | | - } |
316 | | - else { |
317 | | - throw new Exception( 'There is no formatting function for output format ' . $outputType[0] ); |
318 | | - } |
319 | | - } |
320 | | - } |
321 | | - } |
322 | | - |
323 | | - /** |
324 | 278 | * Returns the parameters. |
325 | 279 | * |
326 | 280 | * @since 0.4 |
Index: trunk/extensions/Validator/Validator.php |
— | — | @@ -65,7 +65,6 @@ |
66 | 66 | $wgAutoloadClasses['ParserHook'] = $incDir . 'ParserHook.php'; |
67 | 67 | $wgAutoloadClasses['Validator'] = $incDir . 'Validator.php'; |
68 | 68 | $wgAutoloadClasses['TopologicalSort'] = $incDir . 'TopologicalSort.php'; |
69 | | -$wgAutoloadClasses['ValidationFormats'] = $incDir . 'ValidationFormats.php'; // TODO: remove |
70 | 69 | $wgAutoloadClasses['ValidationError'] = $incDir . 'ValidationError.php'; |
71 | 70 | $wgAutoloadClasses['ValidationErrorHandler'] = $incDir . 'ValidationErrorHandler.php'; |
72 | 71 | |
— | — | @@ -81,6 +80,9 @@ |
82 | 81 | $wgAutoloadClasses['CriterionTrue'] = $incDir . 'criteria/CriterionTrue.php'; |
83 | 82 | $wgAutoloadClasses['CriterionUniqueItems'] = $incDir . 'criteria/CriterionUniqueItems.php'; |
84 | 83 | |
| 84 | +$wgAutoloadClasses['ParamManipulationBoolean'] = $incDir . 'manipulations/ParamManipulationBoolean.php'; |
| 85 | +$wgAutoloadClasses['ParamManipulationBoolstr'] = $incDir . 'manipulations/ParamManipulationBoolstr.php'; |
| 86 | + |
85 | 87 | $wgAutoloadClasses['ValidatorListErrors'] = $incDir . 'parserHooks/Validator_ListErrors.php'; |
86 | 88 | unset( $incDir ); |
87 | 89 | |