From 2e1cc8ed35c503fc069e9b9f5d1220a32666aa46 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Sun, 16 Nov 2014 14:41:22 +0100 Subject: [PATCH] Widget\Tabs: use icon font --- library/Icinga/Web/Widget/Tab.php | 18 ++++++++++++------ .../Widget/Tabextension/DashboardAction.php | 2 +- .../Web/Widget/Tabextension/OutputFormat.php | 4 ++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/library/Icinga/Web/Widget/Tab.php b/library/Icinga/Web/Widget/Tab.php index bf7ea9bcc..b8050f4a5 100644 --- a/library/Icinga/Web/Widget/Tab.php +++ b/library/Icinga/Web/Widget/Tab.php @@ -85,7 +85,7 @@ class Tab extends AbstractWidget */ public function setIcon($icon) { - if (is_string($icon)) { + if (is_string($icon) && strpos($icon, '.') !== false) { $icon = Url::fromPath($icon); } $this->icon = $icon; @@ -202,24 +202,30 @@ class Tab extends AbstractWidget $classes[] = 'active'; } $caption = $view->escape($this->title); + $tagParams = $this->tagParams; if ($this->icon !== null) { if (strpos($this->icon, '.') === false) { - $classes[] = 'icon-' . $this->icon; + if (array_key_exists('class', $tagParams)) { + $tagParams['class'] .= ' icon-' . $this->icon; + } else { + $tagParams['class'] = 'icon-' . $this->icon; + } } else { $caption = $view->img($this->icon, array('class' => 'icon')) . $caption; } } if ($this->url !== null) { $this->url->overwriteParams($this->urlParams); - $tagParams = ''; - if ($this->tagParams !== null) { - $tagParams = $view->propertiesToString($this->tagParams); + if ($tagParams !== null) { + $params = $view->propertiesToString($tagParams); + } else { + $params = ''; } $tab = sprintf( '%s', $this->url, - $tagParams, + $params, $caption ); } else { diff --git a/library/Icinga/Web/Widget/Tabextension/DashboardAction.php b/library/Icinga/Web/Widget/Tabextension/DashboardAction.php index 241b83556..a8cce1cc0 100644 --- a/library/Icinga/Web/Widget/Tabextension/DashboardAction.php +++ b/library/Icinga/Web/Widget/Tabextension/DashboardAction.php @@ -24,7 +24,7 @@ class DashboardAction implements Tabextension $tabs->addAsDropdown( 'dashboard', array( - 'icon' => 'img/icons/dashboard.png', + 'icon' => 'dashboard', 'title' => 'Add To Dashboard', 'url' => Url::fromPath('dashboard/addurl'), 'urlParams' => array( diff --git a/library/Icinga/Web/Widget/Tabextension/OutputFormat.php b/library/Icinga/Web/Widget/Tabextension/OutputFormat.php index 46c55fad2..b5426ea47 100644 --- a/library/Icinga/Web/Widget/Tabextension/OutputFormat.php +++ b/library/Icinga/Web/Widget/Tabextension/OutputFormat.php @@ -40,13 +40,13 @@ class OutputFormat implements Tabextension self::TYPE_PDF => array( 'name' => 'pdf', 'title' => 'PDF', - 'icon' => 'img/icons/pdf.png', + 'icon' => 'file-pdf', 'urlParams' => array('format' => 'pdf'), ), self::TYPE_CSV => array( 'name' => 'csv', 'title' => 'CSV', - 'icon' => 'img/icons/csv.png', + 'icon' => 'file-excel', 'urlParams' => array('format' => 'csv') ), self::TYPE_JSON => array(