public function locale() { return $this->format(SLocale::translate('FORMAT_DATETIME')); }
function error_message_for($objectName, $object, $options = array()) { $errors = $object->errors; if (!empty($errors)) { $headerTag = 'h2'; if (isset($options['header_tag'])) { $headerTag = $options['header_tag']; unset($options['header_tag']); } if (!isset($options['id'])) { $options['id'] = 'form-errors'; } if (!isset($options['class'])) { $options['class'] = 'form-errors'; } $list = ''; foreach ($errors as $field => $error) { $list .= '<li>' . link_to_function($error, "Field.focus('{$objectName}_{$field}')") . '</li>'; } return content_tag('div', content_tag($headerTag, SLocale::translate('ERR_VALID_FORM')) . "<ul>{$list}</ul>", $options); } }
private static function addError($record, $attr, $message, $var = null) { $message = SLocale::translate($message); $humanReadableAttr = SLocale::translate($attr); if ($humanReadableAttr == $attr) { $humanReadableAttr = str_replace('_', ' ', $attr); } $message = ucfirst(sprintf($message, $humanReadableAttr, $var)); if (!isset($record->errors[$attr])) { $record->errors[$attr] = $message; } }
function __($key) { return SLocale::translate($key); }