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

Last change on this file since 410 was 231, checked in by bastiaans, 18 years ago

*.php:

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