Index: trunk/extensions/Validator/includes/ValidationManager.php |
— | — | @@ -1,83 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * Class for parameter handling. |
6 | | - * |
7 | | - * @deprecated |
8 | | - * |
9 | | - * @file ValidationManager.php |
10 | | - * @ingroup Validator |
11 | | - * |
12 | | - * @author Jeroen De Dauw |
13 | | - * |
14 | | - * FIXME: missing required params should result in a no-go, no matter of the error level, as they can/are not defaulted. |
15 | | - * TODO: make a distinction between fatal errors and regular errors by using 2 seperate error levels. |
16 | | - */ |
17 | | -class ValidationManager { |
18 | | - |
19 | | - /** |
20 | | - * @var Validator |
21 | | - */ |
22 | | - protected $validator; |
23 | | - |
24 | | - /** |
25 | | - * Parses and validates the provided parameters, and corrects them depending on the error level. |
26 | | - * |
27 | | - * @param array $rawParameters The raw parameters, as provided by the user. |
28 | | - * @param array $parameterInfo Array containing the parameter definitions, which are needed for validation and defaulting. |
29 | | - * @param array $defaultParams |
30 | | - * |
31 | | - * @return array or false The valid parameters or false when the output should not be shown. |
32 | | - */ |
33 | | - public function manageParameters( array $rawParameters, array $parameterInfo, array $defaultParams = array() ) { |
34 | | - global $egValidatorErrorLevel; |
35 | | - |
36 | | - $this->validator = new Validator(); |
37 | | - |
38 | | - $this->validator->parseAndSetParams( $rawParameters, $parameterInfo, $defaultParams ); |
39 | | - $this->validator->validateAndFormatParameters(); |
40 | | - |
41 | | - if ( $this->validator->hasErrors() && $egValidatorErrorLevel < Validator_ERRORS_STRICT ) { |
42 | | - $this->validator->correctInvalidParams(); |
43 | | - } |
44 | | - |
45 | | - return !$this->validator->hasFatalError(); |
46 | | - } |
47 | | - |
48 | | - /** |
49 | | - * Validates the provided parameters, and corrects them depending on the error level. |
50 | | - * |
51 | | - * @since 3.x |
52 | | - * |
53 | | - * @param $parameters Array |
54 | | - * @param $parameterInfo Array |
55 | | - */ |
56 | | - public function manageParsedParameters( array $parameters, array $parameterInfo ) { |
57 | | - global $egValidatorErrorLevel; |
58 | | - |
59 | | - $this->validator = new Validator(); |
60 | | - |
61 | | - $this->validator->setParameters( $parameters, $parameterInfo ); |
62 | | - $this->validator->validateAndFormatParameters(); |
63 | | - |
64 | | - if ( $this->validator->hasErrors() && $egValidatorErrorLevel < Validator_ERRORS_STRICT ) { |
65 | | - $this->validator->correctInvalidParams(); |
66 | | - } |
67 | | - |
68 | | - return !$this->validator->hasFatalError(); |
69 | | - } |
70 | | - |
71 | | - /** |
72 | | - * Returns an array with the valid parameters. |
73 | | - * |
74 | | - * @since 3.x |
75 | | - * |
76 | | - * @param boolean $includeMetaData |
77 | | - * |
78 | | - * @return array |
79 | | - */ |
80 | | - public function getParameters( $includeMetaData = true ) { |
81 | | - return $this->validator->getValidParams( $includeMetaData ); |
82 | | - } |
83 | | - |
84 | | -} |
\ No newline at end of file |
Index: trunk/extensions/Validator/includes/ListParameter.php |
— | — | @@ -74,7 +74,9 @@ |
75 | 75 | $default = null, array $aliases = array(), array $criteria = array() ) { |
76 | 76 | $itemCriteria = array(); |
77 | 77 | $listCriteria = array(); |
78 | | - |
| 78 | + |
| 79 | + $this->cleanCriteria( $criteria ); |
| 80 | + |
79 | 81 | foreach ( $criteria as $criterion ) { |
80 | 82 | if ( $criterion->isForLists() ) { |
81 | 83 | $listCriteria[] = $criterion; |
— | — | @@ -83,13 +85,13 @@ |
84 | 86 | $itemCriteria[] = $criterion; |
85 | 87 | } |
86 | 88 | } |
| 89 | + |
| 90 | + $this->listCriteria = $listCriteria; |
87 | 91 | |
88 | 92 | parent::__construct( $name, $type, $default, $aliases, $itemCriteria ); |
89 | 93 | |
90 | 94 | $this->delimiter = $delimiter; |
91 | 95 | |
92 | | - $this->cleanCriteria( $listCriteria ); |
93 | | - $this->listCriteria = $listCriteria; |
94 | 96 | } |
95 | 97 | |
96 | 98 | /** |
— | — | @@ -113,7 +115,7 @@ |
114 | 116 | |
115 | 117 | if ( $this->lowerCaseValue ) { |
116 | 118 | foreach ( $this->value as &$item ) { |
117 | | - $item = strtolower( $this->value ); |
| 119 | + $item = strtolower( $item ); |
118 | 120 | } |
119 | 121 | } |
120 | 122 | } |
Index: trunk/extensions/Validator/includes/Parameter.php |
— | — | @@ -174,7 +174,7 @@ |
175 | 175 | */ |
176 | 176 | public static function newFromArray( $name, array $definition ) { |
177 | 177 | $isList = false; |
178 | | - $delimiter = false; |
| 178 | + $delimiter = ListParameter::DEFAULT_DELIMITER; |
179 | 179 | |
180 | 180 | if ( array_key_exists( 'type', $definition ) ) { |
181 | 181 | if ( is_array( $definition['type'] ) ) { |
Index: trunk/extensions/Validator/Validator.php |
— | — | @@ -63,7 +63,6 @@ |
64 | 64 | $wgAutoloadClasses['Validator'] = $incDir . 'Validator.php'; |
65 | 65 | $wgAutoloadClasses['TopologicalSort'] = $incDir . 'TopologicalSort.php'; |
66 | 66 | $wgAutoloadClasses['ValidationFormats'] = $incDir . 'ValidationFormats.php'; |
67 | | -$wgAutoloadClasses['ValidationManager'] = $incDir . 'ValidationManager.php'; // TODO: remove |
68 | 67 | $wgAutoloadClasses['ValidationError'] = $incDir . 'ValidationError.php'; |
69 | 68 | $wgAutoloadClasses['ValidationErrorHandler'] = $incDir . 'ValidationErrorHandler.php'; |
70 | 69 | |