r75463 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75462‎ | r75463 | r75464 >
Date:19:46, 26 October 2010
Author:jeroendedauw
Status:deferred (Comments)
Tags:
Comment:
Fixed issue with empty lists
Modified paths:
  • /trunk/extensions/Validator/Validator.i18n.php (modified) (history)
  • /trunk/extensions/Validator/includes/ItemParameterCriterion.php (modified) (history)
  • /trunk/extensions/Validator/includes/ListParameter.php (modified) (history)
  • /trunk/extensions/Validator/includes/criteria/CriterionInArray.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Validator/includes/ListParameter.php
@@ -111,13 +111,19 @@
112112 * @since 0.4
113113 */
114114 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+ }
122128 }
123129
124130 /**
Index: trunk/extensions/Validator/includes/criteria/CriterionInArray.php
@@ -96,7 +96,7 @@
9797 if ( $originalCount > 15 ) {
9898 $allowedValues = array_slice( $this->allowedValues, 0, 13 );
9999 $omitCount = $originalCount - count( $allowedValues );
100 -
 100+
101101 return wfMsgExt(
102102 'validator-error-accepts-only-omitted',
103103 'parsemag',
@@ -130,13 +130,13 @@
131131 if ( $originalCount > 15 ) {
132132 $allowedValues = array_slice( $this->allowedValues, 0, 13 );
133133 $omitCount = $originalCount - count( $allowedValues );
134 -
 134+
135135 return wfMsgExt(
136136 'validator-list-error-accepts-only-omitted',
137137 'parsemag',
138138 $parameter->getOriginalName(),
139 - $parameter->getValue(),
140139 $wgLang->listToText( $allowedValues ),
 140+ count( $allowedValues ),
141141 $wgLang->formatNum( $omitCount )
142142 );
143143 }
Index: trunk/extensions/Validator/includes/ItemParameterCriterion.php
@@ -77,6 +77,7 @@
7878 }
7979
8080 if ( $result->hasInvalidItems() ) {
 81+ var_dump($parameter);exit;
8182 $allInvalid = count( $result->getInvalidItems() ) == count( $parameter->getValue() );
8283
8384 // If the parameter is required and all items are invalid, it's fatal.
@@ -159,6 +160,7 @@
160161 */
161162 protected function getPartialListErrorMessage( Parameter $parameter, array $invalidItems, $allInvalid ) {
162163 global $wgLang;
 164+
163165 return $this->getFullListErrorMessage( $parameter ) .
164166 wfMsgExt(
165167 'validator-error-omitted',
Index: trunk/extensions/Validator/Validator.i18n.php
@@ -60,16 +60,12 @@
6161 'validator_list_error_invalid_range' => 'All values of parameter $1 must be between $2 and $3.',
6262 'validator-list-error-invalid-regex' => 'All values of parameter $1 must match this regular expression: $2.',
6363 '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}}).',
6866
6967 // 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}}).',
7470
7571 'validator_list_omitted' => 'The {{PLURAL:$2|value|values}} $1 {{PLURAL:$2|has|have}} been omitted.',
7672 );

Follow-up revisions

RevisionCommit summaryAuthorDate
r75465Partly revert of r75463: please keep the linebreaks in i18n files. They are n...raymond19:57, 26 October 2010
r75475Follow up to r75463, forgotten debug linejeroendedauw21:44, 26 October 2010

Comments

#Comment by Jeroen De Dauw (talk | contribs)   19:56, 26 October 2010

Also fixed an i18n issue where I got confused about parameter order and removed newlines from messages that are meant to be shown on a single line.

Status & tagging log