1 date_views_argument_handler_simple.inc date_views_argument_handler_simple::options_form(&$form, &$form_state)

Add a form element to select date_fields for this argument.

Overrides views_handler_argument::options_form

File

core/modules/date/views/date_views_argument_handler_simple.inc, line 147
Date API views argument handler.

Class

date_views_argument_handler_simple

Code

function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);

  // Add an option to control the format of the summary.
  $options = array(
    '' => t('Default format'),
    'custom' => t('Custom format'),
  );
  $example_month = date_format_date(date_example_date(), 'custom', $this->date_handler->views_formats('month', 'display'));
  $example_day = date_format_date(date_example_date(), 'custom', $this->date_handler->views_formats('day', 'display'));

  $form['title_format'] = array(
    '#type' => 'select',
    '#title' => t('Date format options'),
    '#default_value' => $this->options['title_format'],
    '#options' => $options,
    '#description' => t('The date format used in titles and summary links for this argument. The default format is based on the granularity of the filter, i.e. month: @example_month, day: @example_day.', array('@example_month' => $example_month, '@example_day' => $example_day)),
    '#attributes' => array('class' => array('dependent-options')),
    '#states' => array(
      'visible' => array(
        ':input[name="options[default_action]"]' => array(
          'value' => 'summary',
        ),
      ),
    ),
  );

  $form['title_format_custom'] = array(
    '#type' => 'textfield',
    '#title' => t('Custom summary date format'),
    '#default_value' => $this->options['title_format_custom'],
    '#description' => t("A custom format for the title and summary date format. Define a php date format string like 'm-d-Y H:i' (see <a href=\"@link\">http://php.net/date</a> for more details).", array('@link' => 'http://php.net/date')),
    '#attributes' => array('class' => array('dependent-options')),
    '#states' => array(
      'visible' => array(
        ':input[name="options[title_format]"]' => array(
          'value' => 'custom',
        ),
      ),
    ),
  );

  // Get default granularity options
  $options = $this->date_handler->date_parts();
  // Add the 'week' option.
  $options += array(
    'week' => t('Week', array(), array(
      'context' => 'datetime',
    )),
  );

  $form['granularity'] = array(
    '#title' => t('Granularity'),
    '#type' => 'radios',
    '#options' => $options,
    '#default_value' => $this->options['granularity'],
    '#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['granularity_reset'] = array(
    '#title' => t('Use granularity from argument value'),
    '#type' => 'checkbox',
    '#default_value' => $this->options['granularity_reset'],
    '#description' => t("If the granularity of argument value is different from selected, use it from argument value."),
  );

  $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)' ."),
  );

  $form['use_fromto'] = array(
    '#type' => 'radios',
    '#title' => t('Dates to compare'),
    '#default_value' => $this->options['use_fromto'],
    '#options' => array('' => t('Start/End date range'), 'no' => t('Only this field')),
    '#description' => t("If selected the view will check if any value starting with the 'Start' date and ending with the 'End' date matches the view criteria. Otherwise the view will be limited to the specifically selected fields. Comparing to the whole Start/End range is the recommended setting when using this filter in a Calendar. When using the Start/End option, it is not necessary to add both the Start and End fields to the filter, either one will do."),
  );

  $access = TRUE;
  if (!empty($this->definition['field_name'])) {
    $field = field_info_field($this->definition['field_name']);
    $access = $field['cardinality'] != 1;
  }
  $form['add_delta'] = array(
    '#type' => 'radios',
    '#title' => t('Add multiple value identifier'),
    '#default_value' => $this->options['add_delta'],
    '#options' => array('' => t('No'), 'yes' => t('Yes')),
    '#description' => t('Add an identifier to the view to show which multiple value date fields meet the filter criteria. Note: This option may introduce duplicate values into the view. Required when using multiple value fields in a Calendar or any time you want the node view of multiple value dates to display only the values that match the view filters.'),
    // Only let mere mortals tweak this setting for multi-value fields.
    '#access' => $access,
  );
}