function BindStatus($path, $textDomain = '', $htmlEscape = null) { $this->path = $path; $this->htmlEscape = is_html_escape($htmlEscape) === true; $this->textDomain = $textDomain; // determine name of the object and property $beanName = null; $dotPos = strpos($path, NESTED_PATH_SEPARATOR); if ($dotPos === FALSE) { // property not set, only the object itself $beanName = $path; $this->expression = null; } else { $beanName = substr($path, 0, $dotPos); $this->expression = substr($path, $dotPos + 1); } $this->bindingResult =& RequestUtils::getBindingResult($beanName); if ($this->bindingResult != null) { // Usual case: A BindingResult is available as request attribute. // Can determine error codes and messages for the given expression. // Can use a custom PropertyEditor, as registered by a form controller. if ($this->expression != null) { if ("*" == $this->expression) { $this->objectErrors =& $this->bindingResult->getAllErrors(); } else { if (str_ends_with($this->expression, "*")) { $this->objectErrors = $this->bindingResult->getFieldErrors($this->expression); } else { $this->objectErrors = $this->bindingResult->getFieldErrors($this->expression); $this->value = $this->bindingResult->getFieldValue($this->expression); $this->valueType = $this->bindingResult->getFieldType($this->expression); $this->editor =& $this->bindingResult->getCustomEditor($this->expression); } } } else { $this->objectErrors =& $this->bindingResult->getGlobalErrors(); } $this->_initErrorCodes(); } else { // No BindingResult available as request attribute: // Probably forwarded directly to a form view. // Let's do the best we can: extract a plain target if appropriate. $target =& RequestUtils::getModelObject($beanName); if ($target == null) { show_error('BindStatus', "Neither BindingResult nor plain target object for bean name '" . $beanName . "' available as request attribute"); } if ($this->expression != null && $this->expression != "*" && !str_ends_with($this->expression, "*")) { $bw =& new BeanWrapper($target); $this->valueType =& $bw->getPropertyType($this->expression); $this->value =& $bw->getPropertyValue($this->expression); } $this->errorCodes = array(); $this->errorMessages = array(); } if ($htmlEscape && is_string($this->value)) { $this->value = specialchars($this->value); } }
function _renderMessage($message, $arguments, $textDomain, $htmlEscape = null) { if ($arguments != null && is_array($arguments) && !empty($arguments)) { $message = __($message, $textDomain); $sprintargs = array_merge(array($message), $arguments); $result = call_user_func_array('sprintf', $sprintargs); if (is_html_escape($htmlEscape) === true) { $result = specialchars($result); } return $result; } else { $result = __($message, $textDomain); if (is_html_escape($htmlEscape) === true) { $result = specialchars($result); } return $result; } }
function _get_display_string($value, &$propertyEditor) { if (is_string($value) || $propertyEditor == null) { if (is_object($value) && is_null($propertyEditor)) { show_error('Bind', 'Cannot get display string for object of type: ' . get_class($value)); } return is_html_escape(null) ? specialchars($value) : $value; } $originalValue = $propertyEditor->getValue(); // var_dump($value); // var_dump($propertyEditor); $propertyEditor->setValue($value); $result = $propertyEditor->getAsText(); if (!is_null($result)) { $result = is_html_escape(null) ? specialchars($result) : $result; } else { $result = ''; } $propertyEditor->setValue($originalValue); return $result; }