public function SearchApiViewsHandlerFilterOptions::admin_summary in Search API 7
Provides a summary of this filter's value for the admin UI.
Overrides SearchApiViewsHandlerFilter::admin_summary
File
- contrib/
search_api_views/ includes/ handler_filter_options.inc, line 198 - Contains the SearchApiViewsHandlerFilterOptions class.
Class
- SearchApiViewsHandlerFilterOptions
- Views filter handler for fields with a limited set of possible values.
Code
public function admin_summary() {
if (!empty($this->options['exposed'])) {
return t('exposed');
}
if ($this->operator === 'empty') {
return t('is empty');
}
if ($this->operator === 'not empty') {
return t('is not empty');
}
if (!is_array($this->value)) {
return;
}
$operator_options = $this
->operator_options();
$operator = $operator_options[$this->operator];
$values = '';
// Remove every element which is not known.
$this
->get_value_options();
foreach ($this->value as $i => $value) {
if (!isset($this->value_options[$value])) {
unset($this->value[$i]);
}
}
// Choose different kind of ouput for 0, a single and multiple values.
if (count($this->value) == 0) {
return $this->operator != '<>' ? t('none') : t('any');
}
elseif (count($this->value) == 1) {
switch ($this->operator) {
case '=':
case 'all of':
$operator = '=';
break;
case '<>':
$operator = '<>';
break;
}
// If there is only a single value, use just the plain operator, = or <>.
$operator = check_plain($operator);
$values = check_plain($this->value_options[reset($this->value)]);
}
else {
foreach ($this->value as $value) {
if ($values !== '') {
$values .= ', ';
}
if (drupal_strlen($values) > 20) {
$values .= '…';
break;
}
$values .= check_plain($this->value_options[$value]);
}
}
return $operator . ($values !== '' ? ' ' . $values : '');
}