You are here

function _date_field_settings in Date 5.2

Same name and namespace in other branches
  1. 5 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/date.module

File

date/date_admin.inc, line 215
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('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',
        'repeat_collapsed',
      );
      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':
      require_once './' . drupal_get_path('module', 'date') . '/date_views.inc';
      return _date_views_arguments($field);
    case 'filters':
      require_once './' . drupal_get_path('module', 'date') . '/date_views.inc';
      return date_views_filters($field);
      break;
    case 'tables':
      require_once './' . drupal_get_path('module', 'date') . '/date_views.inc';
      return date_views_field_tables($field);
      break;
  }
}