diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:47:21 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 12:47:21 +0000 |
commit | 1ac4a2050c8076eb96e07e83721ebc9db864db94 (patch) | |
tree | da9b32212bf99154450a7668f61a75f65617a9fa /application/views/helpers/Tiles.php | |
parent | Initial commit. (diff) | |
download | icingaweb2-module-toplevelview-1ac4a2050c8076eb96e07e83721ebc9db864db94.tar.xz icingaweb2-module-toplevelview-1ac4a2050c8076eb96e07e83721ebc9db864db94.zip |
Adding upstream version 0.3.3.upstream/0.3.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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; + } +} |