blob: dcefbfe779d2a09b628e8743e40c7a4df8bf7f45 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
<?php
/* Icinga Web 2 Top Level View | (c) 2017 Icinga Development Team | GPLv2+ */
use Icinga\Module\Toplevelview\Tree\TLVTreeNode;
class Zend_View_Helper_Tiles extends Zend_View_Helper_Abstract
{
/** @var \Icinga\Web\View */
public $view;
public function tiles(TLVTreeNode $node, $levels = 2, $classes = array())
{
$htm = '';
$title = $this->view->escape($node->getTitle());
$status = $node->getStatus();
if ($levels > 1) {
$statusClass = 'tlv-status-section';
} else {
$statusClass = 'tlv-status-tile';
}
$statusClasses = array($statusClass, $status->getOverall());
$htm .= sprintf(
'<div class="tlv-tile %s" title="%s" data-base-target="_next">' . "\n",
join(' ', $classes + $statusClasses),
$title
);
$badges = $this->view->badges($status);
$htm .= $this->view->qlink(
$title . $badges,
'toplevelview/show/tree',
array(
'name' => $node->getRoot()->getConfig()->getName(),
'id' => $node->getFullId()
),
array(
'class' => 'tlv-tile-title'
),
false
);
if ($levels > 1 && $node->hasChildren()) {
$htm .= '<div class="tlv-tiles">';
foreach ($node->getChildren() as $child) {
$htm .= $this->tiles($child, $levels - 1, $classes);
}
$htm .= '</div>';
}
$htm .= "</div>\n";
return $htm;
}
}
|