You are here

function date_views_filter_handler::extra_options_form in Date 7

Same name and namespace in other branches
  1. 8 date_views/includes/date_views_filter_handler.inc \date_views_filter_handler::extra_options_form()
  2. 7.3 date_views/includes/date_views_filter_handler.inc \date_views_filter_handler::extra_options_form()
  3. 7.2 date_views/includes/date_views_filter_handler.inc \date_views_filter_handler::extra_options_form()

Provide a form for setting options.

Overrides views_handler::extra_options_form

File

date_views/includes/date_views_filter_handler.inc, line 104
A flexible, configurable date filter.

Class

date_views_filter_handler
This filter allows you to select a granularity of date parts to filter on, such as year, month, day, etc.

Code

function extra_options_form(&$form, &$form_state) {
  parent::extra_options_form($form, $form_state);
  $form['form_type'] = array(
    '#type' => 'radios',
    '#title' => t('Date form type'),
    '#default_value' => $this->options['form_type'],
    '#options' => $this
      ->widget_options(),
    '#description' => t('Choose the form element to use for date selection.'),
  );
  $form['granularity'] = $this->date_handler
    ->granularity_form($this->options['granularity']);
  $form['granularity']['#description'] = '<p>' . t("Select a granularity for the date filter. For instance, selecting 'day' will create a filter where users can select the year, month, and day.") . '</p>';
  $form['year_range'] = array(
    '#title' => t('Date year range'),
    '#type' => 'textfield',
    '#default_value' => $this->options['year_range'],
    '#description' => t("Set the allowable minimum and maximum year range for this argument, either a -X:+X offset from the current year, like '-3:+3' or an absolute minimum and maximum year, like '2005:2010' . When the argument is set to a date outside the range, the page will be returned as 'Page not found (404)' ."),
  );
  $fields = date_views_fields($this->view->base_table);
  $options = array();
  foreach ($fields['name'] as $name => $field) {
    $options[$name] = $field['label'];
  }

  // If this filter was added as a CCK field filter and no other date field
  // has been chosen, update the default with the right date.
  if (empty($this->options['date_fields']) && $this->field != 'date_filter') {
    $this->options['date_fields'] = array(
      $this->table . '.' . $this->field,
    );
  }
  $form['date_fields'] = array(
    '#title' => t('Date field(s)'),
    '#type' => 'checkboxes',
    '#options' => $options,
    '#default_value' => $this->options['date_fields'],
    '#multiple' => FALSE,
    '#description' => t('Select date field(s) to filter with this argument.'),
    '#required' => TRUE,
  );
  $form['date_method'] = array(
    '#title' => t('Method'),
    '#type' => 'radios',
    '#options' => array(
      'OR' => t('OR'),
      'AND' => t('AND'),
    ),
    '#default_value' => $this->options['date_method'],
    '#description' => t('Method of handling multiple date fields in the same query. Return items that have any matching date field (date = field_1 OR field_2), or only those with matches in all selected date fields (date = field_1 AND field_2).'),
  );
}