GetFieldOptions($field_name); if ( isset($format) ) $options['format'] = $format; $tc_value = $this->TypeCast($value,$options); if( ($tc_value === false) || ($tc_value != $value) ) return $value; // for leaving badly formatted date on the form if (isset($options['format'])) return sprintf($options['format'], $tc_value); return $tc_value; } //function Parse($value, $options, &$errors) function Parse($value, $field_name, &$object) { if ($value == '') return NULL; $options = $object->GetFieldOptions($field_name); $tc_value = $this->TypeCast($value,$options); if($tc_value === false) return $value; // for leaving badly formatted date on the form if( isset($options['type']) ) { if( preg_match('#double|float|real|numeric#', $options['type']) ) $tc_value = str_replace(',', '.', $tc_value); } if( isset($options['regexp']) ) { if( !preg_match($options['regexp'], $value) ) { $object->FieldErrors[$field_name]['pseudo'] = 'invalid_format'; } } return $tc_value; } function HumanFormat($format) { return $format; } /** * The method is supposed to alter config options or cofigure object in some way based on its usage of formatters * The methods is called for every field with formatter defined when configuring item. * Could be used for adding additional VirtualFields to an object required by some special Formatter * * @param string $field_name * @param array $field_options * @param kDBBase $object */ function PrepareOptions($field_name, &$field_options, &$object) { } /** * Used for split fields like timestamp -> date, time * Called from DBItem to update sub fields values after loading item * * @param unknown_type $field * @param unknown_type $value * @param unknown_type $options * @param unknown_type $object */ function UpdateSubFields($field, $value, &$options, &$object) { } /** * Used for split fields like timestamp -> date, time * Called from DBItem Validate (before validation) to get back master field value from its sub_fields * * @param unknown_type $field * @param unknown_type $value * @param unknown_type $options * @param unknown_type $object */ function UpdateMasterFields($field, $value, &$options, &$object) { } /* function GetErrorMsg($pseudo_error, $options) { if ( isset($options['error_msgs'][$pseudo_error]) ) { return $options['error_msgs'][$pseudo_error]; } else { return $this->ErrorMsgs[$pseudo_error]; } }*/ function GetSample($field, &$options, &$object) { } }