function _date_field_settings in Date 6
Same name and namespace in other branches
- 5.2 date/date_admin.inc \_date_field_settings()
- 5 date_admin.inc \_date_field_settings()
- 6.2 date/date_admin.inc \_date_field_settings()
Implementation of hook_field_settings().
1 call to _date_field_settings()
- date_field_settings in date/
date.module
File
- date/
date_admin.inc, line 227 - Date administration code. Moved to separate file since there is a lot of code here that is not needed often.
Code
function _date_field_settings($op, $field) {
switch ($op) {
case 'form':
return date_field_settings_form($field);
case 'validate':
if (!in_array('year', $field['granularity'])) {
form_set_error('granularity', t('Input granularity must include a year.'));
}
if ($field['tz_handling'] != 'none' && !in_array('hour', array_filter($field['granularity']))) {
form_set_error('tz_handling', t('Dates without hours granularity must not use any timezone handling.'));
}
break;
case 'save':
$options = array(
'granularity',
'timezone_db',
'tz_handling',
'todate',
'repeat',
);
for ($i = 0; $i <= 3; $i++) {
switch ($i) {
case 1:
$name = 'long';
break;
case 2:
$name = 'medium';
break;
case 3:
$name = 'short';
break;
default:
$name = 'default';
}
$append = $i > 0 ? '_' . $name : '';
$options[] = 'output_format_date' . $append;
$options[] = 'output_format_custom' . $append;
}
return $options;
case 'database columns':
return date_columns($field);
case 'views data':
$data = content_views_field_views_data($field);
$db_info = content_database_info($field);
$table_alias = content_views_tablename($field);
// Unset the filter and argument handlers, dates can use the generic
// date argument and filter handlers created by the Date API.
unset($data[$table_alias][$field['field_name'] . '_value']['argument']);
unset($data[$table_alias][$field['field_name'] . '_value']['filter']);
// Add in another set of fields for the To date.
if ($field['todate']) {
$data[$table_alias][$field['field_name'] . '_value2'] = $data[$table_alias][$field['field_name'] . '_value'];
$data[$table_alias][$field['field_name'] . '_value']['title'] = t('!label (!field value)', array(
'!label' => t($field['widget']['label']),
'!field' => t($field['field_name']),
));
$data[$table_alias][$field['field_name'] . '_value2']['title'] = t('!label (!field value2)', array(
'!label' => t($field['widget']['label']),
'!field' => t($field['field_name']),
));
}
return $data;
}
}