diff --git a/application/views/scripts/hosttemplates/tree.phtml b/application/views/scripts/hosttemplates/tree.phtml
new file mode 100644
index 00000000..a97bba7a
--- /dev/null
+++ b/application/views/scripts/hosttemplates/tree.phtml
@@ -0,0 +1,65 @@
+children);
+ if ($level === 0) {
+ $class = 'root';
+ } else {
+ $class = 'host';
+ }
+
+ if ($hasChildren) {
+ $collapsed = '';
+ } else {
+ $collapsed = ' class="collapsed"';
+ }
+
+ $html = '
';
+ if ($hasChildren) {
+ ksort($tree->children);
+ $html .= ' ';
+ }
+
+ if ($level === 0) {
+ $html .= '' . $self->escape($tree->name) . '';
+ } else {
+ $html .= $self->qlink(
+ $tree->name,
+ 'director/host',
+ array('name' => $tree->name),
+ array('class' => $class)
+ );
+ }
+
+ if ($hasChildren) {
+ $html .= '';
+ foreach ($tree->children as $child) {
+ $html .= dumpTree($child, $self, $level + 1);
+ }
+ $html .= '
';
+ }
+ $html .= "\n";
+ return $html;
+}
+
+?>
+
+= $this->tabs ?>
+
= $this->translate('Host template tree') ?>
+
+
+
+
+
+= dumpTree(
+ (object) array(
+ 'name' => 'Templates',
+ 'children' => $this->tree
+ ),
+ $this
+) ?>
+
+
diff --git a/library/Director/Web/Controller/ObjectsController.php b/library/Director/Web/Controller/ObjectsController.php
index f78f1ccc..ec74945e 100644
--- a/library/Director/Web/Controller/ObjectsController.php
+++ b/library/Director/Web/Controller/ObjectsController.php
@@ -16,14 +16,12 @@ abstract class ObjectsController extends ActionController
public function init()
{
+ $tabs = $this->getTabs();
$type = $this->getType();
- $ltype = strtolower($type);
-
- $object = $this->dummyObject();
if (in_array(ucfirst($type), $this->globalTypes)) {
+ $ltype = strtolower($type);
- $tabs = $this->getTabs();
foreach ($this->globalTypes as $tabType) {
$ltabType = strtolower($tabType);
$tabs->add($ltabType, array(
@@ -60,6 +58,11 @@ abstract class ObjectsController extends ActionController
}
}
+
+ $tabs->add('tree', array(
+ 'url' => sprintf('director/%stemplates/tree', $type),
+ 'label' => $this->translate('Tree'),
+ ));
}
public function indexAction()
@@ -103,6 +106,12 @@ abstract class ObjectsController extends ActionController
$this->render('objects/table', null, true);
}
+ public function treeAction()
+ {
+ $this->getTabs()->activate('tree');
+ $this->view->tree = $this->db()->fetchTemplateTree(strtolower($this->getType()));
+ }
+
protected function dummyObject()
{
if ($this->dummy === null) {