source: trunk/web/addons/job_monarch/header.php @ 225

Last change on this file since 225 was 225, checked in by bastiaans, 16 years ago

ALL:

  • added GPL
File size: 5.0 KB
Line 
1<?php
2/*
3 *
4 * This file is part of Jobmonarch
5 *
6 * Copyright (C) 2006  Ramon Bastiaans
7 *
8 * Jobmonarch is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * Jobmonarch is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 *
22 */
23
24# Check if this context is private.
25include_once "$GANGLIA_PATH/auth.php";
26checkcontrol();
27checkprivate();
28
29if ( $context == "control" && $controlroom < 0 )
30      $header = "header-nobanner";
31else
32      $header = "header";
33
34$tpl = new TemplatePower( "templates/header.tpl" );
35$tpl->prepare();
36
37# Maintain our path through the grid tree.
38$me = $self . "@" . $grid[$self][AUTHORITY];
39if ($initgrid)
40   {
41      $gridstack = array();
42      $gridstack[] = $me;
43   }
44else if ($gridwalk=="fwd")
45   {
46      # push our info on gridstack, format is "name@url>name2@url".
47      if (end($gridstack) != $me)
48         {
49            $gridstack[] = $me;
50         }
51   }
52else if ($gridwalk=="back")
53   {
54      # pop a single grid off stack.
55      if (end($gridstack) != $me)
56         {
57            array_pop($gridstack);
58         }
59   }
60$gridstack_str = join(">", $gridstack);
61$gridstack_url = rawurlencode($gridstack_str);
62
63if ($initgrid or $gridwalk)
64   {
65      # Use cookie so we dont have to pass gridstack around within this site.
66      # Cookie values are automatically urlencoded. Expires in a day.
67      setcookie("gs", $gridstack_str, time() + 86400);
68   }
69
70# Invariant: back pointer is second-to-last element of gridstack. Grid stack never
71# has duplicate entries.
72list($parentgrid, $parentlink) = explode("@", $gridstack[count($gridstack)-2]);
73
74# Setup a redirect to a remote server if you choose a grid from pulldown menu. Tell
75# destination server that we're walking foward in the grid tree.
76if (strstr($clustername, "http://"))
77   {
78      $tpl->assign("refresh", "0");
79      $tpl->assign("redirect", ";URL=$clustername?gw=fwd&gs=$gridstack_url");
80      echo "<h2>Redirecting, please wait...</h2>";
81      $tpl->printToScreen();
82      exit;
83   }
84$tpl->assign("refresh", $default_refresh);
85
86$tpl->assign( "date", date("r"));
87$tpl->assign( "page_title", $title );
88
89# The page to go to when "Get Fresh Data" is pressed.
90if (isset($page))
91      $tpl->assign("page",$page);
92else
93      $tpl->assign("page","./");
94
95# Templated Logo image
96$tpl->assign("images","./templates/$template_name/images");
97
98#
99# Used when making graphs via graph.php. Included in most URLs
100#
101$sort_url=rawurlencode($sort);
102$get_metric_string = "m=$metric&r=$range&s=$sort_url&hc=$hostcols";
103if ($jobrange and $jobstart)
104        $get_metric_string .= "&jr=$jobrange&js=$jobstart";
105
106# Set the Alternate view link.
107$cluster_url=rawurlencode($clustername);
108$node_url=rawurlencode($hostname);
109
110# Make some information available to templates.
111$tpl->assign("cluster_url", $cluster_url);
112
113# Build the node_menu
114$node_menu = "";
115
116if ($parentgrid)
117   {
118      $node_menu .= "<B><A HREF=\"$parentlink?gw=back&gs=$gridstack_url\">".
119         "$parentgrid $meta_designator</A></B> ";
120      $node_menu .= "<B>&gt;</B>\n";
121   }
122
123# Show grid.
124$mygrid =  ($self == "unspecified") ? "" : $self;
125$node_menu .= "<B><A HREF=\"./?$get_metric_string\">$mygrid $meta_designator</A> ";
126$node_menu .= "<B>&gt;</B>\n";
127
128if ($physical)
129   $node_menu .= hiddenvar("p", $physical);
130
131if ( $clustername )
132   {
133      $url = rawurlencode($clustername);
134      $node_menu .= "<B><A HREF=\"./?c=$url&$get_metric_string\">$clustername</A></B> ";
135      //$node_menu .= "<B>&gt;</B>\n";
136      $node_menu .= hiddenvar("c", $clustername);
137   }
138else
139   {
140      # No cluster has been specified, so drop in a list
141      $node_menu .= "<SELECT NAME=\"c\" OnChange=\"ganglia_form.submit();\">\n";
142      $node_menu .= "<OPTION VALUE=\"\">--Choose a Source\n";
143      ksort($grid);
144      foreach( $grid as $k => $v )
145         {
146            if ($k==$self) continue;
147            if ($v[GRID])
148               {
149                  $url = $v[AUTHORITY];
150                  $node_menu .="<OPTION VALUE=\"$url\">$k $meta_designator\n";
151               }
152            else
153               {
154                  $url = rawurlencode($k);
155                  $node_menu .="<OPTION VALUE=\"$url\">$k\n";
156               }
157         }
158      $node_menu .= "</SELECT>\n";
159   }
160
161$tpl->assign("node_menu", $node_menu);
162
163# Make sure that no data is cached..
164header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    # Date in the past
165header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); # always modified
166header ("Cache-Control: no-cache, must-revalidate");  # HTTP/1.1
167header ("Pragma: no-cache");                          # HTTP/1.0
168
169$tpl->printToScreen();
170
171
172
173?>
Note: See TracBrowser for help on using the repository browser.