icingaweb2-module-director/application/views/scripts/objects/tree.phtml

71 lines
1.5 KiB
PHTML

<?php
use Icinga\Web\Url;
function dumpTree($tree, $self, $level = 0)
{
$hasChildren = ! empty($tree->children);
if ($level === 0) {
$class = 'root';
} else {
//$class = 'host';
$class = $self->objectTypeName;
}
if ($hasChildren) {
$collapsed = '';
} else {
$collapsed = ' class="collapsed"';
}
$html = '<li' . $collapsed . '>';
if ($hasChildren) {
ksort($tree->children);
$html .= '<span class="handle"> </span>';
}
if ($level === 0) {
$html .= '<a name="Templates" class="root">' . $self->escape($tree->name) . '</a>';
} else {
$html .= $self->qlink(
$tree->name,
'director/' . $self->objectTypeName,
array('name' => $tree->name),
array('class' => $class)
)/* . $self->qlink(
'=>',
'director/' . $self->objectTypeName . '/childlist',
array('name' => $tree->name)
)*/;
}
if ($hasChildren) {
$html .= '<ul>';
foreach ($tree->children as $child) {
$html .= dumpTree($child, $self, $level + 1);
}
$html .= '</ul>';
}
$html .= "</li>\n";
return $html;
}
?>
<div class="controls">
<?= $this->tabs ?>
<h1><?= $this->translate('Template tree') ?></h1>
</div>
<div class="content">
<ul class="tree" data-base-target="_next">
<?= dumpTree(
(object) array(
'name' => 'Templates',
'children' => $this->tree
),
$this
) ?>
</ul>
</div>