-
Notifications
You must be signed in to change notification settings - Fork 170
/
grid_tree.php
61 lines (49 loc) · 1.72 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
<?php
$tpl = new Dwoo_Template_File( template("grid_tree.tpl") );
$data = new Dwoo_Data();
$data->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)) {
$data->assign("parentgrid", 1);
$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";
}
$data->assign("parents", $parentgridtable);
}
$gridtable="";
# Publish our children.
if ($n = count($grid))
{
$data->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>";
}
$data->assign("children", $gridtable);
$dwoo->output($tpl, $data);
?>