You are here

function menu_references_filter_handler::admin_summary in Menu Reference 7

Display the filter on the administrative summary.

Overrides views_handler_filter_in_operator::admin_summary

File

views/handlers/menu_references_filter_handler.inc, line 176
Views filter handler

Class

menu_references_filter_handler
@file Views filter handler

Code

function admin_summary() {
  if (method_exists($this, 'is_a_group') && $this
    ->is_a_group()) {
    return t('grouped');
  }
  if (!empty($this->options['exposed'])) {
    return t('exposed');
  }
  $info = $this
    ->operators();
  $this
    ->get_value_options();
  if (!is_array($this->value)) {
    return;
  }
  $operator = check_plain($info[$this->operator]['short']);
  $values = '';
  if (in_array($this->operator, $this
    ->operator_values(1))) {
    $flat_options = form_options_flatten($this->value_options, TRUE);

    // Remove every element which is not known.
    foreach ($this->value as $value) {
      if (!isset($flat_options[$value])) {
        unset($this->value[$value]);
      }
    }

    // Choose different kind of ouput for 0, a single and multiple values.
    if (count($this->value) == 0) {
      $values = t('Unknown');
    }
    elseif (count($this->value) == 1) {

      // If any, use the 'single' short name of the operator instead.
      if (isset($info[$this->operator]['short_single'])) {
        $operator = check_plain($info[$this->operator]['short_single']);
      }
      $keys = $this->value;
      $value = array_shift($keys);
      if (isset($flat_options[$value])) {
        $values = check_plain($value);
      }
      else {
        $values = '';
      }
    }
    else {
      foreach ($this->value as $value) {
        if ($values !== '') {
          $values .= ', ';
        }
        if (drupal_strlen($values) > 8) {
          $values .= '...';
          break;
        }
        if (isset($flat_options[$value])) {
          $values .= check_plain($value);
        }
      }
    }
  }
  return $operator . ($values !== '' ? ' ' . $values : '');
}