Index: branches/5.2.x/core/kernel/utility/validator.php
===================================================================
diff -u -N -r15522 -r16080
--- branches/5.2.x/core/kernel/utility/validator.php (.../validator.php) (revision 15522)
+++ branches/5.2.x/core/kernel/utility/validator.php (.../validator.php) (revision 16080)
@@ -1,6 +1,6 @@
SetError($field, 'bad_type', null, Array ($params['type']));
+ $this->SetError($field, 'bad_type', null, array('type' => $params['type']));
return false;
}
@@ -256,7 +256,10 @@
if ( !isset($min_val) ) $min_val = '-∞';
if ( !isset($max_val) ) $max_val = '∞';
- $this->SetError($field, 'value_out_of_range', null, Array ($min_val, $max_val));
+ $this->SetError($field, 'value_out_of_range', null, array(
+ 'min_value' => $min_val,
+ 'max_value' => $max_val
+ ));
return false;
}
@@ -271,7 +274,11 @@
}
if ( !$res ) {
- $error_params = Array ((int)getArrayValue($params, 'min_len'), (int)getArrayValue($params, 'max_len'), mb_strlen($val));
+ $error_params = array(
+ 'min_length' => (int)getArrayValue($params, 'min_len'),
+ 'max_length' => (int)getArrayValue($params, 'max_len'),
+ 'value' => mb_strlen($val)
+ );
$this->SetError($field, 'length_out_of_range', null, $error_params);
return false;
@@ -425,9 +432,23 @@
$msg = $this->Application->ReplaceLanguageTags($msg, $force_escape);
if ( isset($this->FieldErrors[$field]['params']) ) {
- return vsprintf($msg, $this->FieldErrors[$field]['params']);
+ $params = $this->FieldErrors[$field]['params'];
}
+ else {
+ $params = array();
+ }
+ $field_phrase = $this->Application->isAdmin ? 'la_fld_' . $field : 'lu_fld_' . $field;
+ $params['field'] = $this->Application->Phrase($field_phrase);
+
+ foreach ( $params as $param_name => $param_value ) {
+ $msg = str_replace('{' . $param_name . '}', $param_value, $msg, $replacement_count);
+ }
+
+ if ( strpos($msg, '%s') !== false ) {
+ trigger_error('Unexpected "%s" in field "' . $field . '" validation error message (pseudo: "' . $error_pseudo . '") in "' . $this->dataSource->Prefix . '" unit', E_USER_WARNING);
+ }
+
return $msg;
}
@@ -501,4 +522,4 @@
{
$this->FieldErrors = Array();
}
-}
\ No newline at end of file
+}