diff --git a/library/Icinga/Web/Widget/FilterEditor.php b/library/Icinga/Web/Widget/FilterEditor.php index bc82f8939..7f86a9db2 100644 --- a/library/Icinga/Web/Widget/FilterEditor.php +++ b/library/Icinga/Web/Widget/FilterEditor.php @@ -284,8 +284,38 @@ class FilterEditor extends AbstractWidget } } + public function renderSearch() + { + $html = '
'; + + if ($this->filter->isEmpty()) { + $title = t('Filter this list'); + } else { + $title = t('Modify this filter'); + if (! $this->filter->isEmpty()) { + $title .= ': ' . $this->filter; + } + } + return $html + . '' + . '' + . ''; + } + public function render() { + if (! $this->url()->getParam('modifyFilter')) { + return $this->renderSearch() . $this->shorten($this->filter, 50); + } + return '

' . t('Modify this filter') . '

' @@ -298,6 +328,14 @@ class FilterEditor extends AbstractWidget . ''; } + protected function shorten($string, $length) + { + if (strlen($string) > $length) { + return substr($string, 0, $length) . '...'; + } + return $string; + } + public function __toString() { try {