You are here

function date_api_argument_handler::options_form in Date 6

Same name and namespace in other branches
  1. 6.2 includes/date_api_argument_handler.inc \date_api_argument_handler::options_form()

Add a form element to select date_fields for this argument.

File

./date_api.views.inc, line 141
Defines date-related Views data and plugins:

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' => t('Week'),
  );
  $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.'),
  );
  $fields = date_api_fields();
  $options = array();
  foreach ($fields['name'] as $name => $field) {
    $options[$name] = $field['label'];
  }
  $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.'),
  );
  $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).'),
  );
}