You are here

public function date_views_filter_handler::admin_summary in Date 7.3

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

Display the filter on the administrative summary.

Overrides date_views_filter_handler_simple::admin_summary

File

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

Class

date_views_filter_handler
A flexible, configurable date filter.

Code

public function admin_summary() {
  if (empty($this->options['date_fields'])) {
    return t('Missing date fields!');
  }
  $handler = $this->date_handler;
  $fields = date_views_fields($this->view->base_table);
  if (!empty($this->options['date_fields'])) {
    $output = array();
    foreach ($this->options['date_fields'] as $field) {
      if (array_key_exists($field, $fields['name'])) {
        $output[] = $fields['name'][$field]['label'];
      }
    }
  }
  $field = implode(' ' . $this->options['date_method'] . ' ', $output);
  $output = "{$field} " . check_plain($this->operator) . ' ';
  $parts = $handler
    ->date_parts();
  $widget_options = $this
    ->widget_options();

  // If the filter is exposed, display the granularity.
  if ($this->options['exposed']) {
    return t('(@field) <strong>Exposed</strong> @widget @format', array(
      '@field' => $field,
      '@format' => $parts[$handler->granularity],
      '@widget' => $widget_options[$this->options['form_type']],
    ));
  }

  // If not exposed, display the value.
  if (in_array($this->operator, $this
    ->operator_values(2))) {
    $min = check_plain(!empty($this->options['default_date']) ? $this->options['default_date'] : $this->options['value']['min']);
    $max = check_plain(!empty($this->options['default_to_date']) ? $this->options['default_to_date'] : $this->options['value']['max']);
    $output .= t('@min and @max', array(
      '@min' => $min,
      '@max' => $max,
    ));
  }
  else {
    $output .= check_plain(!empty($this->options['default_date']) ? $this->options['default_date'] : $this->options['value']['value']);
  }
  return $output;
}