diff --git a/library/Icinga/Web/Widget/FilterEditor.php b/library/Icinga/Web/Widget/FilterEditor.php index 84e21c3d4..bd4c7986e 100644 --- a/library/Icinga/Web/Widget/FilterEditor.php +++ b/library/Icinga/Web/Widget/FilterEditor.php @@ -48,31 +48,22 @@ class FilterEditor extends AbstractWidget } else { $attributes = $view->propertiesToString($attributes); } - $html = '' . "\n"; + + asort($list); foreach ($list as $k => $v) { $active = ''; if ($k === $selected) { $active = ' selected="selected"'; - $beenActive = true; } - $v = str_replace('_', ' ', ucfirst($v)); $html .= sprintf( - '', + ' ' . "\n", $view->escape($k), $active, $view->escape($v) ); } - if (! $beenActive && $selected) { - $html .= sprintf( - '', - $view->escape($selected), - $view->escape(str_replace('_', ' ', ucfirst(ltrim($selected, '_')))) - ); - } - $html .= ''; + $html .= '' . "\n\n"; return $html; } @@ -145,7 +136,7 @@ class FilterEditor extends AbstractWidget . ''; } } else { - $html .= $op . ''; + $html .= $op . "\n"; } return $html; } @@ -205,6 +196,19 @@ class FilterEditor extends AbstractWidget protected function selectColumn($filter) { $name = 'column_' . $filter->getId(); + $cols = $this->arrayForSelect($this->query->getColumns()); + $active = $filter->getColumn(); + $seen = false; + foreach ($cols as $k => & $v) { + $v = str_replace('_', ' ', ucfirst($v)); + if ($k === $active) { + $seen = true; + } + } + + if (!$seen) { + $cols[$active] = str_replace('_', ' ', ucfirst(ltrim($active, '_'))); + } if ($this->query === null) { return sprintf( @@ -215,8 +219,8 @@ class FilterEditor extends AbstractWidget } else { return $this->select( $name, - $this->arrayForSelect($this->query->getColumns()), - $filter->getColumn() + $cols, + $active ); } }