diff options
Diffstat (limited to 'application/views/helpers/Tiles.php')
-rw-r--r-- | application/views/helpers/Tiles.php | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/application/views/helpers/Tiles.php b/application/views/helpers/Tiles.php new file mode 100644 index 0000000..dcefbfe --- /dev/null +++ b/application/views/helpers/Tiles.php @@ -0,0 +1,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; + } +} |