You are here

function _date_field_settings in Date 5

Same name and namespace in other branches
  1. 5.2 date/date_admin.inc \_date_field_settings()
  2. 6.2 date/date_admin.inc \_date_field_settings()
  3. 6 date/date_admin.inc \_date_field_settings()

Implementation of hook_field_settings().

1 call to _date_field_settings()
date_field_settings in ./date.module

File

./date_admin.inc, line 160

Code

function _date_field_settings($op, $field) {
  switch ($op) {
    case 'form':
      return date_field_settings_form($field);
    case 'validate':
      date_set_site_timezone($field['field_timezone']);
      if (!in_array('Y', $field['granularity'])) {
        form_set_error('granularity', t('Input granularity must include a year.'));
      }
      if ($field['tz_handling'] != 'none' && !in_array('H', 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',
        'field_timezone',
        'timezone_db',
        'tz_handling',
        'todate',
      );
      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 'arguments':
      include_once './' . drupal_get_path('module', 'date') . '/date_views.inc';
      return _date_views_arguments($field);
    case 'filters':
      return date_views_filters($field);
      break;
  }
}