You are here

function tzfield_field_settings in Time Zone Field 6

Implementation of hook_field_settings().

File

./tzfield.module, line 76
Defines a field type for storing timezones.

Code

function tzfield_field_settings($op, $field) {
  switch ($op) {
    case 'form':
      $form = array();
      $form['exclude'] = array(
        '#type' => 'select',
        '#multiple' => TRUE,
        '#required' => FALSE,
        '#title' => t('Timezones to be excluded from the option list'),
        '#default_value' => is_array($field['exclude']) ? $field['exclude'] : tzfield_excluded_timezones(),
        '#options' => array(
          '' => '<' . t('none') . '>',
        ) + tzfield_identifiers_list(),
        '#description' => t('Note, many <a href="http://en.wikipedia.org/wiki/List_of_zoneinfo_timezones">timezones</a> exist in PHP only for backward compatibility reasons.'),
      );
      return $form;
    case 'save':
      return array(
        'exclude',
      );
    case 'database columns':
      $columns = array(
        'timezone' => array(
          'type' => 'varchar',
          'length' => 32,
          'not null' => FALSE,
          'sortable' => TRUE,
        ),
      );
      return $columns;
    case 'filters':
      $allowed_values = content_allowed_values($field);
      if (count($allowed_values)) {
        return array(
          'default' => array(
            'list' => $allowed_values,
            'list-type' => 'list',
            'operator' => 'views_handler_operator_or',
            'value-type' => 'array',
          ),
        );
      }
      else {
        return array(
          'like' => array(
            'operator' => 'views_handler_operator_like',
            'handler' => 'views_handler_filter_like',
          ),
        );
      }
  }
}