mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-21 21:04:25 +02:00
Introduce Icinga\Web\Widget\Tab::$label as alternative for $title
This commit is contained in:
parent
48286e0d59
commit
9fb3dcabea
@ -42,6 +42,8 @@ class Tab extends AbstractWidget
|
|||||||
*/
|
*/
|
||||||
private $title = '';
|
private $title = '';
|
||||||
|
|
||||||
|
private $label = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Url this tab points to
|
* The Url this tab points to
|
||||||
*
|
*
|
||||||
@ -116,6 +118,11 @@ class Tab extends AbstractWidget
|
|||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setLabel($label)
|
||||||
|
{
|
||||||
|
$this->label = $label;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param mixed $title
|
* @param mixed $title
|
||||||
*/
|
*/
|
||||||
@ -210,9 +217,22 @@ class Tab extends AbstractWidget
|
|||||||
if ($this->active) {
|
if ($this->active) {
|
||||||
$classes[] = 'active';
|
$classes[] = 'active';
|
||||||
}
|
}
|
||||||
$caption = $view->escape($this->title);
|
|
||||||
|
$caption = $view->escape($this->label);
|
||||||
$tagParams = $this->tagParams;
|
$tagParams = $this->tagParams;
|
||||||
|
|
||||||
|
if ($this->title) {
|
||||||
|
if ($tagParams !== null) {
|
||||||
|
$tagParams['title'] = $this->title;
|
||||||
|
$tagParams['aria-label'] = $this->title;
|
||||||
|
} else {
|
||||||
|
$tagParams = array(
|
||||||
|
'title' => $this->title,
|
||||||
|
'aria-label' => $this->title
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->icon !== null) {
|
if ($this->icon !== null) {
|
||||||
if (strpos($this->icon, '.') === false) {
|
if (strpos($this->icon, '.') === false) {
|
||||||
$caption = $view->icon($this->icon) . $caption;
|
$caption = $view->icon($this->icon) . $caption;
|
||||||
@ -220,13 +240,16 @@ class Tab extends AbstractWidget
|
|||||||
$caption = $view->img($this->icon, null, array('class' => 'icon')) . $caption;
|
$caption = $view->img($this->icon, null, array('class' => 'icon')) . $caption;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->url !== null) {
|
if ($this->url !== null) {
|
||||||
$this->url->overwriteParams($this->urlParams);
|
$this->url->overwriteParams($this->urlParams);
|
||||||
|
|
||||||
if ($tagParams !== null) {
|
if ($tagParams !== null) {
|
||||||
$params = $view->propertiesToString($tagParams);
|
$params = $view->propertiesToString($tagParams);
|
||||||
} else {
|
} else {
|
||||||
$params = '';
|
$params = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$tab = sprintf(
|
$tab = sprintf(
|
||||||
'<a href="%s"%s>%s</a>',
|
'<a href="%s"%s>%s</a>',
|
||||||
$this->url,
|
$this->url,
|
||||||
@ -236,6 +259,7 @@ class Tab extends AbstractWidget
|
|||||||
} else {
|
} else {
|
||||||
$tab = $caption;
|
$tab = $caption;
|
||||||
}
|
}
|
||||||
|
|
||||||
$class = empty($classes) ? '' : sprintf(' class="%s"', implode(' ', $classes));
|
$class = empty($classes) ? '' : sprintf(' class="%s"', implode(' ', $classes));
|
||||||
return '<li ' . $class . '>' . $tab . "</li>\n";
|
return '<li ' . $class . '>' . $tab . "</li>\n";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user