histogram: Make histograms crash less
[ninja.git] / application / views / template_menu.php
blobe7c8d494e7102ceb86df19f72e749f395869f511
1 <?php
3 /*
4 The API for adding a menu item is this:
6 array(4) {
7 ["About"]=> <-- category
8 array(3) {
9 ["The Ninja project"]=> <-- label
10 array(3) {
11 [0]=>
12 string(64) "http://www.op5.org/community/plugin-inventory/op5-projects/ninja" <-- absolute or relative url
13 [1]=>
14 string(5) "ninja" <--- "id", or "geomap.png" (ninja/app..), or array('synergy', 'synergy.png') (ninja/modules/..)
15 [2]=>
16 int(3) <---- 0 indicates internal link, /monitor/index.php will be prepended;
17 <---- 1 indicates same host, https://monitor-server will be prepended
18 <---- 2 indicates same host, but only if site_domain is /monitor/, licensed version
19 <---- 3 indicates same host, but only if site_domain is not /monitor/, community version
22 $in_menu = false;
26 <div class="main-menu">
28 <div class="logo">
29 <div class="logo-image"></div>
30 </div>
32 <?php
34 if (isset($links)) {
36 $uri = str_replace($_SERVER['QUERY_STRING'], '', $_SERVER['REQUEST_URI']);
37 $uri = str_replace('?', '', $uri);
38 $uri = preg_replace('~/+~', '/', $uri);
40 echo "<ul>";
42 foreach ($links as $section => $entry) {
43 $normalized_section_name = str_replace(' ','-',strtolower($section));
46 <li class="supermenu-button" id="<?php echo $normalized_section_name; ?>-button">
47 <span class="icon-32 x32-<?php echo $normalized_section_name; ?>"></span>
48 <?php
50 $linkstring = '';
51 if (strtolower($section) == 'about') {
52 $linkstring .= '<li class="meta">'.Kohana::config('config.product_name') . ": " . config::get_version_info().'</li>';
53 $linkstring .= '<li class="meta">'._('Page loaded').': '.date(nagstat::date_format()).'</li>';
54 } elseif (empty($entry)) {
55 continue;
58 $i = 0;
60 $in_menu = false;
62 if($entry) {
63 foreach ($entry as $name => $data) {
65 /* Never have a capital o in op5 */
66 $formatted_name = preg_replace('/op5/i', 'op5', ucwords($name));
68 if( is_array($data[1]) ) {
69 $icon_image = $data[1][1];
70 $module_name = $data[1][0];
71 $id = $normalized_section_name."-".$data[1][0];
72 } else {
73 $icon_image = $data[1];
74 $module_name = false;
75 $id = $normalized_section_name."-".$data[1];
77 if ($data[2] == 0) {
79 // Do not add white-space, line-feeds or carriage returns in here, it will screw up JavaScript .children's and .nextSibling's
81 $siteuri = url::site($data[0], null);
82 $siteuri = preg_replace('~/+~', '/', $siteuri);
84 if (strpos($siteuri, '?')) {
85 $siteuri = substr($siteuri, 0, strpos($siteuri, '?'));
88 $linkstring .= "<li class='nav-seg'><a href='".rtrim(url::base(true), "/").$data[0]."' id='$id' class='ninja_menu_links'>";
89 if (strpos($icon_image, '.') !== false)
90 $linkstring .= "<span class='icon-menu' style='background-image: url(".ninja::add_path('icons/menu/'.$icon_image, $module_name).")'></span>";
91 else
92 $linkstring .= "<span class='icon-menu menu-".$icon_image."'></span>";
93 $linkstring .= "<span class='nav-seg-span'>".$formatted_name."</span></a></li>";
96 $i++;
98 } elseif($data[2] == 1) {
99 $linkstring .= "<li class='nav-seg'><a href='".$data[0]."' id='$id' class='ninja_menu_links'>";
100 if (strpos($icon_image, '.') !== false)
101 $linkstring .= "<img src='".ninja::add_path('icons/menu/'.$icon_image, $module_name)."' />";
102 else
103 $linkstring .= "<span class='icon-menu menu-".$icon_image."'></span>";
104 $linkstring .= "<span class='nav-seg-span'>".$formatted_name."</span></a></li>";
105 } // common external links
106 elseif(($data[2] == 2 && Kohana::config('config.site_domain') == '/monitor/') ||
107 ($data[2] == 3 && Kohana::config('config.site_domain') != '/monitor/')) {
109 $linkstring .= "<li class='nav-seg'><a href='".$data[0]."' id='$id' target='_blank' class='ninja_menu_links'>";
110 if (strpos($icon_image, '.') !== false)
111 $linkstring .= "<img src='".ninja::add_path('icons/menu/'.$icon_image, $module_name)."' />";
112 else
113 $linkstring .= "<span class='icon-menu menu-".$icon_image."'></span>";
114 $linkstring .= "<span class='nav-seg-span'>".$formatted_name."</span></a></li>";
122 if ($in_menu == true) {
123 echo "<ul id='$normalized_section_name-menu' class='current-sup-menu' style='display: block'>";
124 } else {
125 echo "<ul id='$normalized_section_name-menu'>";
128 echo $linkstring;
130 echo "</ul></li>";
134 echo "</ul>";
140 </div>