mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
helpers/icon: support webfont shortcuts
* set icon class instead of icon image if no such is given * fix TODO: merge parameter classes refs #6936
This commit is contained in:
parent
86a9c7f8c6
commit
1aa8858dca
@ -51,19 +51,32 @@ $this->addHelperFunction('img', function ($url, array $properties = array()) use
|
||||
});
|
||||
|
||||
$this->addHelperFunction('icon', function ($img, $title = null, array $properties = array()) use ($view) {
|
||||
// TODO: join with classes passed in $properties?
|
||||
$attributes = array(
|
||||
'class' => 'icon',
|
||||
);
|
||||
$isClass = strpos($img, '.') === false;
|
||||
$class = null;
|
||||
|
||||
if ($isClass) {
|
||||
$class = 'icon-' . $img;
|
||||
} else {
|
||||
$class = 'icon';
|
||||
}
|
||||
if ($title !== null) {
|
||||
$attributes['alt'] = $title;
|
||||
$attributes['title'] = $title;
|
||||
$properties['alt'] = $title;
|
||||
$properties['title'] = $title;
|
||||
}
|
||||
|
||||
return $view->img(
|
||||
'img/icons/' . $img,
|
||||
array_merge($attributes, $properties)
|
||||
);
|
||||
if ($class !== null) {
|
||||
if (isset($props['class'])) {
|
||||
$properties['class'] .= ' ' . $class;
|
||||
} else {
|
||||
$properties['class'] = $class;
|
||||
}
|
||||
}
|
||||
if ($isClass) {
|
||||
return sprintf('<i %s ></i>', $view->propertiesToString($properties));
|
||||
|
||||
} else {
|
||||
return $view->img('img/icons/' . $img, $properties);
|
||||
}
|
||||
});
|
||||
|
||||
$this->addHelperFunction('propertiesToString', function ($properties) use ($view) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user