Changeset View
Standalone View
core/kernel/utility/validator.php
Context not available. | |||||
} | } | ||||
if ( !$res ) { | if ( !$res ) { | ||||
$this->SetError($field, 'bad_type', null, Array ($params['type'])); | $this->SetError($field, 'bad_type', null, array('type' => $params['type'])); | ||||
alex: The array declaration isn't fixed to match coding standard. | |||||
return false; | return false; | ||||
} | } | ||||
Context not available. | |||||
if ( !isset($min_val) ) $min_val = '-∞'; | if ( !isset($min_val) ) $min_val = '-∞'; | ||||
if ( !isset($max_val) ) $max_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 | |||||
Not Done ReplyThe parameter name should be max_value to be consistent with other parameter names. alex: The parameter name should be `max_value` to be consistent with other parameter names. | |||||
)); | |||||
return false; | return false; | ||||
} | } | ||||
Context not available. | |||||
} | } | ||||
if ( !$res ) { | 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); | $this->SetError($field, 'length_out_of_range', null, $error_params); | ||||
return false; | return false; | ||||
Context not available. | |||||
$msg = $this->Application->ReplaceLanguageTags($msg, $force_escape); | $msg = $this->Application->ReplaceLanguageTags($msg, $force_escape); | ||||
if ( isset($this->FieldErrors[$field]['params']) ) { | if ( isset($this->FieldErrors[$field]['params']) ) { | ||||
return vsprintf($msg, $this->FieldErrors[$field]['params']); | $params = $this->FieldErrors[$field]['params']; | ||||
} | |||||
else { | |||||
$params = array(); | |||||
} | |||||
$field_options = $this->dataSource->GetFieldOptions($field); | |||||
Not Done ReplyWe need to allow changing this via unit config as well. Here is what needs to be done: $field_options = $this->dataSource->GetFieldOptions($field); if ( $this->Application->isAdmin ) { $field_phrase = !empty($field_options['admin_label']) ? $field_options['admin_label'] : 'la_fld_' . $field; } else { $field_phrase = !empty($field_options['front_label']) ? $field_options['front_label'] : 'lu_fld_' . $field; } Theoretically this would allow to override corresponding phrase in unit config. alex: We need to allow changing this via unit config as well. Here is what needs to be done:
```… | |||||
Not Done ReplyThere is dedicated $this->Application->Phrase method that should be used to translate a phrase. alex: There is dedicated `$this->Application->Phrase` method that should be used to translate a… | |||||
if ( $this->Application->isAdmin ) { | |||||
$field_phrase = !empty($field_options['admin_label']) ? $field_options['admin_label'] : 'la_fld_' . $field; | |||||
} | |||||
Not Done ReplyRename to $replacement_count to add more clarity. alex: Rename to `$replacement_count` to add more clarity. | |||||
else { | |||||
$field_phrase = !empty($field_options['front_label']) ? $field_options['front_label'] : 'lu_fld_' . $field; | |||||
} | |||||
$params['field'] = $this->Application->Phrase($field_phrase); | |||||
Not Done ReplyNow, when we are not calling vsprintf at the end the parameter unsetting code isn't needed anymore. Same goes for replacement count tracking code. alex: Now, when we are not calling `vsprintf` at the end the parameter unsetting code isn't needed… | |||||
foreach ( $params as $param_name => $param_value ) { | |||||
$msg = str_replace('{' . $param_name . '}', $param_value, $msg, $replacement_count); | |||||
Not Done ReplySince introduced {field} parameter isn't currently used anywhere we put vsprintf function call into situation where we always have 1 more parameter given, then %s in the actual error message. Please verify that this doesn't cause vsprintf to return empty string or trigger a warning. If it does, then we should just remove $msg and don't use vsprintf. alex: Since introduced `{field}` parameter isn't currently used anywhere we put `vsprintf` function… | |||||
} | |||||
if ( strpos($msg, '%s') !== false ) { | |||||
trigger_error('Unexpected "%s" in field "<b>' . $field . '</b>" validation error message (pseudo: "<b>' . $error_pseudo . '</b>") in "<b>' . $this->dataSource->Prefix . '</b>" unit', E_USER_WARNING); | |||||
} | } | ||||
return $msg; | return $msg; | ||||
Context not available. | |||||
{ | { | ||||
$this->FieldErrors = Array(); | $this->FieldErrors = Array(); | ||||
} | } | ||||
} | } | ||||
No newline at end of file | |||||
Context not available. |
The array declaration isn't fixed to match coding standard.