Index: trunk/extensions/Validator/includes/ListParameter.php |
— | — | @@ -111,13 +111,19 @@ |
112 | 112 | * @since 0.4 |
113 | 113 | */ |
114 | 114 | protected function cleanValue() { |
115 | | - $this->value = explode( $this->delimiter, $this->originalValue ); |
116 | | - |
117 | | - if ( $this->trimValue ) { |
118 | | - foreach ( $this->value as &$item ) { |
119 | | - $item = trim( $item ); |
120 | | - } |
121 | | - } |
| 115 | + if ( $this->originalValue == '' ) { |
| 116 | + // If no value is provided, there are no items, and not a single empty item. |
| 117 | + $this->value = array(); |
| 118 | + } |
| 119 | + else { |
| 120 | + $this->value = explode( $this->delimiter, $this->originalValue ); |
| 121 | + |
| 122 | + if ( $this->trimValue ) { |
| 123 | + foreach ( $this->value as &$item ) { |
| 124 | + $item = trim( $item ); |
| 125 | + } |
| 126 | + } |
| 127 | + } |
122 | 128 | } |
123 | 129 | |
124 | 130 | /** |
Index: trunk/extensions/Validator/includes/criteria/CriterionInArray.php |
— | — | @@ -96,7 +96,7 @@ |
97 | 97 | if ( $originalCount > 15 ) { |
98 | 98 | $allowedValues = array_slice( $this->allowedValues, 0, 13 ); |
99 | 99 | $omitCount = $originalCount - count( $allowedValues ); |
100 | | - |
| 100 | + |
101 | 101 | return wfMsgExt( |
102 | 102 | 'validator-error-accepts-only-omitted', |
103 | 103 | 'parsemag', |
— | — | @@ -130,13 +130,13 @@ |
131 | 131 | if ( $originalCount > 15 ) { |
132 | 132 | $allowedValues = array_slice( $this->allowedValues, 0, 13 ); |
133 | 133 | $omitCount = $originalCount - count( $allowedValues ); |
134 | | - |
| 134 | + |
135 | 135 | return wfMsgExt( |
136 | 136 | 'validator-list-error-accepts-only-omitted', |
137 | 137 | 'parsemag', |
138 | 138 | $parameter->getOriginalName(), |
139 | | - $parameter->getValue(), |
140 | 139 | $wgLang->listToText( $allowedValues ), |
| 140 | + count( $allowedValues ), |
141 | 141 | $wgLang->formatNum( $omitCount ) |
142 | 142 | ); |
143 | 143 | } |
Index: trunk/extensions/Validator/includes/ItemParameterCriterion.php |
— | — | @@ -77,6 +77,7 @@ |
78 | 78 | } |
79 | 79 | |
80 | 80 | if ( $result->hasInvalidItems() ) { |
| 81 | + var_dump($parameter);exit; |
81 | 82 | $allInvalid = count( $result->getInvalidItems() ) == count( $parameter->getValue() ); |
82 | 83 | |
83 | 84 | // If the parameter is required and all items are invalid, it's fatal. |
— | — | @@ -159,6 +160,7 @@ |
160 | 161 | */ |
161 | 162 | protected function getPartialListErrorMessage( Parameter $parameter, array $invalidItems, $allInvalid ) { |
162 | 163 | global $wgLang; |
| 164 | + |
163 | 165 | return $this->getFullListErrorMessage( $parameter ) . |
164 | 166 | wfMsgExt( |
165 | 167 | 'validator-error-omitted', |
Index: trunk/extensions/Validator/Validator.i18n.php |
— | — | @@ -60,16 +60,12 @@ |
61 | 61 | 'validator_list_error_invalid_range' => 'All values of parameter $1 must be between $2 and $3.', |
62 | 62 | 'validator-list-error-invalid-regex' => 'All values of parameter $1 must match this regular expression: $2.', |
63 | 63 | 'validator_list_error_invalid_argument' => 'One or more values for parameter $1 are invalid.', |
64 | | - 'validator-list-error-accepts-only' => 'One or more values for parameter $1 are invalid. |
65 | | -It only accepts {{PLURAL:$3|this value|these values}}: $2.', |
66 | | - 'validator-list-error-accepts-only-omitted' => 'One or more values for parameter $1 are invalid. |
67 | | -It only accepts {{PLURAL:$3|this value|these values}}: $2 (and $4 omitted {{PLURAL:$4|value|values}}).', |
| 64 | + 'validator-list-error-accepts-only' => 'One or more values for parameter $1 are invalid. It only accepts {{PLURAL:$3|this value|these values}}: $2.', |
| 65 | + 'validator-list-error-accepts-only-omitted' => 'One or more values for parameter $1 are invalid. It only accepts {{PLURAL:$3|this value|these values}}: $2 (and $4 omitted {{PLURAL:$4|value|values}}).', |
68 | 66 | |
69 | 67 | // Criteria errors for single values & lists |
70 | | - 'validator_error_accepts_only' => 'The value "$4" is not valid for parameter $1. |
71 | | -It only accepts {{PLURAL:$3|this value|these values}}: $2.', |
72 | | - 'validator-error-accepts-only-omitted' => 'The value "$2" is not valid for parameter $1. |
73 | | -It only accepts {{PLURAL:$5|this value|these values}}: $3 (and $4 omitted {{PLURAL:$4|value|values}}).', |
| 68 | + 'validator_error_accepts_only' => 'The value "$4" is not valid for parameter $1. It only accepts {{PLURAL:$3|this value|these values}}: $2.', |
| 69 | + 'validator-error-accepts-only-omitted' => 'The value "$2" is not valid for parameter $1. It only accepts {{PLURAL:$5|this value|these values}}: $3 (and $4 omitted {{PLURAL:$4|value|values}}).', |
74 | 70 | |
75 | 71 | 'validator_list_omitted' => 'The {{PLURAL:$2|value|values}} $1 {{PLURAL:$2|has|have}} been omitted.', |
76 | 72 | ); |