Skip to content

Commit

Permalink
navigation/dashboard.phtml: Use ipl-web's Icon for fa- icons (#5278)
Browse files Browse the repository at this point in the history
resolves #5277
  • Loading branch information
nilmerg authored Nov 4, 2024
2 parents 41a2aed + e34c174 commit e12574f
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 1 deletion.
3 changes: 2 additions & 1 deletion application/views/scripts/navigation/dashboard.phtml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use ipl\Stdlib\Str;
use ipl\Web\Widget\Icon;

?>
Expand All @@ -11,7 +12,7 @@ use ipl\Web\Widget\Icon;
<a class="dashboard-link" href="<?= $this->url($item->getUrl(), $item->getUrlParameters()) ?>"<?= $this->propertiesToString($item->getAttributes()) ?>>
<div class="link-icon">
<?php
if (substr($item->getUrl()->getPath(), 0, 9) === 'icingadb/') {
if (Str::startsWith($item->getIcon(), 'fa-') || substr($item->getUrl()->getPath(), 0, 9) === 'icingadb/') {
echo new Icon($item->getIcon() ?: 'share', [ 'aria-hidden' => 1]);
} else {
echo $this->icon($item->getIcon() ?: 'forward', null, array('aria-hidden' => true));
Expand Down
148 changes: 148 additions & 0 deletions library/Icinga/Web/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,154 @@ class View extends Zend_View_Abstract
*/
const CHARSET = 'UTF-8';

/**
* Legacy icons provided by our old fontello font
*
* @var array<string, bool>
*/
private const LEGACY_ICONS = [
//<editor-fold desc="Icon names">
'dashboard' => true,
'user' => true,
'users' => true,
'ok' => true,
'cancel' => true,
'plus' => true,
'minus' => true,
'folder-empty' => true,
'download' => true,
'upload' => true,
'git' => true,
'cubes' => true,
'database' => true,
'gauge' => true,
'sitemap' => true,
'sort-name-up' => true,
'sort-name-down' => true,
'megaphone' => true,
'bug' => true,
'tasks' => true,
'filter' => true,
'off' => true,
'book' => true,
'paste' => true,
'scissors' => true,
'globe' => true,
'cloud' => true,
'flash' => true,
'barchart' => true,
'down-dir' => true,
'up-dir' => true,
'left-dir' => true,
'right-dir' => true,
'down-open' => true,
'right-open' => true,
'up-open' => true,
'left-open' => true,
'up-big' => true,
'right-big' => true,
'left-big' => true,
'down-big' => true,
'resize-full-alt' => true,
'resize-full' => true,
'resize-small' => true,
'move' => true,
'resize-horizontal' => true,
'resize-vertical' => true,
'zoom-in' => true,
'block' => true,
'zoom-out' => true,
'lightbulb' => true,
'clock' => true,
'volume-up' => true,
'volume-down' => true,
'volume-off' => true,
'mute' => true,
'mic' => true,
'endtime' => true,
'starttime' => true,
'calendar-empty' => true,
'calendar' => true,
'wrench' => true,
'sliders' => true,
'services' => true,
'service' => true,
'phone' => true,
'file-pdf' => true,
'file-word' => true,
'file-excel' => true,
'doc-text' => true,
'trash' => true,
'comment-empty' => true,
'comment' => true,
'chat' => true,
'chat-empty' => true,
'bell' => true,
'bell-alt' => true,
'attention-alt' => true,
'print' => true,
'edit' => true,
'forward' => true,
'reply' => true,
'reply-all' => true,
'eye' => true,
'tag' => true,
'tags' => true,
'lock-open-alt' => true,
'lock-open' => true,
'lock' => true,
'home' => true,
'info' => true,
'help' => true,
'search' => true,
'flapping' => true,
'rewind' => true,
'chart-line' => true,
'bell-off' => true,
'bell-off-empty' => true,
'plug' => true,
'eye-off' => true,
'arrows-cw' => true,
'cw' => true,
'host' => true,
'thumbs-up' => true,
'thumbs-down' => true,
'spinner' => true,
'attach' => true,
'keyboard' => true,
'menu' => true,
'wifi' => true,
'moon' => true,
'chart-pie' => true,
'chart-area' => true,
'chart-bar' => true,
'beaker' => true,
'magic' => true,
'spin6' => true,
'down-small' => true,
'left-small' => true,
'right-small' => true,
'up-small' => true,
'pin' => true,
'angle-double-left' => true,
'angle-double-right' => true,
'circle' => true,
'info-circled' => true,
'twitter' => true,
'facebook-squared' => true,
'gplus-squared' => true,
'attention-circled' => true,
'check' => true,
'reschedule' => true,
'warning-empty' => true,
'th-list' => true,
'th-thumb-empty' => true,
'github-circled' => true,
'history' => true,
'binoculars' => true
//</editor-fold>
];

/**
* Registered helper functions
*/
Expand Down
7 changes: 7 additions & 0 deletions library/Icinga/Web/View/helpers/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use Icinga\Web\Url;
use Icinga\Exception\ProgrammingError;
use ipl\Web\Widget\Icon;

$view = $this;

Expand Down Expand Up @@ -108,6 +109,12 @@ function ($title, $url, $params = null, $properties = null, $escape = true) use
$properties['aria-hidden'] = 'true';
}

if (! isset($view::LEGACY_ICONS[$img]) || substr($img, 0, 3) === 'fa-') {
// This may not be reached, as some legacy icons have equal names as fontawesome ones.
// Though, this is a legacy helper, so in that case one gets legacy icons...
return new Icon($img, $properties);
}

if (isset($properties['class'])) {
$properties['class'] .= ' icon-' . $img;
} else {
Expand Down

0 comments on commit e12574f

Please sign in to comment.