-
Notifications
You must be signed in to change notification settings - Fork 0
/
grid_tree.php
64 lines (51 loc) · 1.78 KB
/
grid_tree.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/* $Id: grid_tree.php 589 2005-10-10 07:42:26Z knobi1 $ */
$tpl = new TemplatePower( template("grid_tree.tpl") );
$tpl->prepare();
$tpl->assign("self", "$self");
# Not as complicated as before. No depth-first-search, and
# we only show our immediate children.
# Publish past grids in our stack.
$ancestors = $gridstack;
# Take ourself off the end of the stack.
array_pop($ancestors);
if (count($ancestors)) {
$tpl->newBlock("parentgrid");
$parentgridtable = "";
$parentgridstack = array();
foreach ($ancestors as $g) {
list($name, $link) = explode("@", $g);
$parentgridstack[] = $g;
$parentgridstack_url = rawurlencode(join(">", $parentgridstack));
$parentgridtable .= "<tr><td align=center class=grid>".
"<a href=\"$link?t=yes&gw=back&gs=$parentgridstack_url\">$name</a></td></tr>\n";
}
$tpl->assign("parents", $parentgridtable);
$tpl->gotoBlock("_ROOT");
}
$gridtable="";
# Publish our children.
if ($n = count($grid))
{
$tpl->assign("n", $n);
foreach ($grid as $source => $attrs)
{
if ($source == $self) continue;
if (isset($grid[$source]['GRID']) and $grid[$source]['GRID'])
{
# This child is a grid.
$url = $grid[$source]['AUTHORITY'] . "?t=yes&gw=fwd&gs=$gridstack_url";
$gridtable .= "<td class=grid><a href=\"$url\">$source</a></td>";
}
else
{
# A cluster.
$url = "./?c=". rawurlencode($source) ."&$get_metric_string";
$gridtable .= "<td><a href=\"$url\">$source</a></td>";
}
}
$gridtable .= "</tr></table>";
}
$tpl->assign("children", $gridtable);
$tpl->printToScreen();
?>