You are here

function date_api_argument_handler::options_form in Date 6.2

Same name and namespace in other branches
  1. 6 date_api.views.inc \date_api_argument_handler::options_form()

Add a form element to select date_fields for this argument.

File

includes/date_api_argument_handler.inc, line 80
Views argument handler.

Class

date_api_argument_handler
Date API argument handler.

Code

function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);
  $options = $this->date_handler
    ->date_parts();
  unset($options['second'], $options['minute']);
  $options += array(
    'week' => date_t('Week', 'datetime'),
  );
  $form['granularity'] = array(
    '#title' => t('Granularity'),
    '#type' => 'radios',
    '#options' => $options,
    '#default_value' => $this->options['granularity'],
    '#multiple' => TRUE,
    '#description' => t("Select the type of date value to be used in defaults, summaries, and navigation. For example, a granularity of 'month' will set the default date to the current month, summarize by month in summary views, and link to the next and previous month when using date navigation."),
  );
  $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_api_fields($this->definition['base']);
  $options = array();
  foreach ($fields['name'] as $name => $field) {
    $options[$name] = $field['label'];
  }

  // If this argument was added as a CCK field argument and no other date field
  // has been chosen, update the default with the right date.
  if (empty($this->options['date_fields']) && $this->field != 'date_argument') {
    $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' => TRUE,
    '#description' => t("Select one or more date fields to filter with this argument. Do not select both the 'From date' and 'To date' for CCK date fields, only one of them is needed."),
  );
  $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).'),
  );
}