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