Index: branches/5.2.x/core/kernel/utility/formatters/ccdate_formatter.php =================================================================== diff -u -N -r14244 -r14628 --- branches/5.2.x/core/kernel/utility/formatters/ccdate_formatter.php (.../ccdate_formatter.php) (revision 14244) +++ branches/5.2.x/core/kernel/utility/formatters/ccdate_formatter.php (.../ccdate_formatter.php) (revision 14628) @@ -1,6 +1,6 @@ setVirtualFields($add_fields); } - function UpdateSubFields($field, $value, &$options, &$object) + /** + * Used for split fields like timestamp -> date, time + * Called from DBItem to update sub fields values after loading item + * + * @param string $field + * @param string $value + * @param Array $options + * @param kDBItem $object + * @return void + * @access public + */ + public function UpdateSubFields($field, $value, &$options, &$object) { - if(!$value) return false; + if ( !$value ) { + return ; + } + $date = explode('/', $value); - $object->SetDBField( $options['month_field'], $date[0] ); - $object->SetDBField( $options['year_field'], $date[1] ); + $object->SetDBField($options['month_field'], $date[0]); + $object->SetDBField($options['year_field'], $date[1]); } /** * Will work in future if we could attach 2 formatters to one field * - * @param string $value + * @param mixed $value * @param string $field_name * @param kDBItem $object - * @return string + * @return mixed + * @access public */ - function Parse($value, $field_name, &$object) + public function Parse($value, $field_name, &$object) { -// if ( is_null($value) ) return ''; - $options = $object->GetFieldOptions($field_name); $month = $object->GetDirtyField($options['month_field']); $year = $object->GetDirtyField($options['year_field']); - if( !(int)$month && !(int)$year ) return NULL; + if ( !(int)$month && !(int)$year ) { + return NULL; + } + $is_valid = ($month >= 1 && $month <= 12) && ($year >= 0 && $year <= 99); - if (!$is_valid) { + if ( !$is_valid ) { $object->SetError($field_name, 'bad_type'); } - return $month.'/'.$year; + + return $month . '/' . $year; } } \ No newline at end of file