You are here

function workflow_views_handler_filter_sid::admin_summary in Workflow 7.2

Display the filter on the administrative summary.

Overrides views_handler_filter_in_operator::admin_summary

File

workflow_views/handlers/workflow_views_handler_filter_sid.inc, line 81
Provide views filter handler for workflow.module.

Class

workflow_views_handler_filter_sid
Filter by state.

Code

function admin_summary() {
  if ($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))) {

    // !!! here unlike views_handler_filter_in_operator class.
    $options_sids = array();
    foreach ($this->value_options as $key => $value) {
      if (is_array($value)) {
        foreach ($value as $k => $v) {
          $options_sids[$k] = $v;
        }
      }
      else {
        $options_sids[$key] = $value;
      }
    }

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

        // !!! Unlike views_handler_filter_in_operator class.
        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($options_sids[$value])) {

        // !!! Unlike views_handler_filter_in_operator class.
        $values = check_plain($options_sids[$value]);
      }
      else {
        $values = '';
      }
    }
    else {
      foreach ($this->value as $value) {
        if ($values !== '') {
          $values .= ', ';
        }
        if (drupal_strlen($values) > 8) {
          $values .= '...';
          break;
        }
        if (isset($options_sids[$value])) {

          // !!! Unlike views_handler_filter_in_operator class.
          $values .= check_plain($options_sids[$value]);
        }
      }
    }
  }
  return $operator . ($values !== '' ? ' ' . $values : '');
}