foreach ($lat as $lo => $lon) { $num_up = count($lon["up_hosts"]); $num_down = count($lon["down_hosts"]); $total_hosts = $num_up + $num_down; $tooltip = "{$total_hosts} Hosts"; $location_name = ""; if ($num_down > 0) { $location_name = $lon['down_hosts'][0]['location'] === '' ? OBS_VAR_UNSET : $lon['down_hosts'][0]['location']; $location_url = generate_location_url($lon['down_hosts'][0]['location']); $tooltip .= "\\n\\nDown hosts:"; foreach ($lon["down_hosts"] as $down_host) { $tooltip .= "\\n" . escape_html($down_host['hostname']); } } elseif ($num_up > 0) { $location_name = $lon['up_hosts'][0]['location'] === '' ? OBS_VAR_UNSET : $lon['up_hosts'][0]['location']; $location_url = generate_location_url($lon['up_hosts'][0]['location']); } // Google Map JS not allowed chars: ', \ $location_name = strtr(escape_html($location_name), "'\\", "`/"); echo "[{$la}, {$lo}, {$num_up}, {$num_down}, \"{$tooltip}\", '{$location_name}', '{$location_url}'],\n "; } } ?> ]); return data; } function initialize() { var data = getMapData(); var markers = [];
function print_device_header($device, $args = array()) { global $config; if (!is_array($device)) { print_error("Invalid device passed to print_device_header()!"); } if ($device['status'] == '0') { $class = "div-alert"; } else { $class = "div-normal"; } if ($device['ignore'] == '1') { $class = "div-ignore-alert"; if ($device['status'] == '1') { $class = "div-ignore"; } } if ($device['disabled'] == '1') { $class = "div-disabled"; } $type = strtolower($device['os']); echo '<div class="box box-solid"><table class=" table table-hover table-condensed ' . $args['class'] . '" style="margin-bottom: 10px; min-height: 70px; border-radius: 2px;">'; echo ' <tr class="' . $device['html_row_class'] . ' vertical-align"> <td class="state-marker"></td> <td style="width: 70px; text-align: center;">' . get_device_icon($device) . '</td> <td><span style="font-size: 20px;">' . generate_device_link($device) . '</span> <br /><a href="' . generate_location_url($device['location']) . '">' . escape_html($device['location']) . '</a></td> '; if (device_permitted($device) && !$args['no_graphs']) { echo '<td>'; // Only show graphs for device_permitted(), don't show device graphs to users who can only see a single entity. if (isset($config['os'][$device['os']]['graphs'])) { $graphs = $config['os'][$device['os']]['graphs']; } else { if (isset($device['os_group']) && isset($config['os'][$device['os_group']]['graphs'])) { $graphs = $config['os'][$device['os_group']]['graphs']; } else { $graphs = $config['os']['default']['graphs']; } } $graph_array = array(); $graph_array['height'] = "100"; $graph_array['width'] = "310"; $graph_array['to'] = $config['time']['now']; $graph_array['device'] = $device['device_id']; $graph_array['type'] = "device_bits"; $graph_array['from'] = $config['time']['day']; $graph_array['legend'] = "no"; $graph_array['height'] = "45"; $graph_array['width'] = "150"; $graph_array['style'] = array('width: 150px !important'); // Fix for FF issue on HiDPI screen $graph_array['bg'] = "FFFFFF00"; // Preprocess device graphs array foreach ($device['graphs'] as $graph) { $graphs_enabled[] = $graph['graph']; } foreach ($graphs as $entry) { if ($entry && in_array(str_replace('device_', '', $entry), $graphs_enabled) !== FALSE) { $graph_array['type'] = $entry; preg_match('/^(?P<type>[a-z0-9A-Z-]+)_(?P<subtype>[a-z0-9A-Z-_]+)/', $entry, $graphtype); if (isset($graphtype['type']) && isset($graphtype['subtype'])) { $type = $graphtype['type']; $subtype = $graphtype['subtype']; $text = $config['graph_types'][$type][$subtype]['descr']; } else { $text = nicecase($subtype); // Fallback to the type itself as a string, should not happen! } echo '<div class="pull-right" style="padding: 2px; margin: 0;">'; //echo generate_graph_tag($graph_array); echo generate_graph_popup($graph_array); echo '<div style="padding: 0px; font-weight: bold; font-size: 7pt; text-align: center;">' . $text . '</div>'; echo '</div>'; } } echo ' </td>'; } // Only show graphs for device_permitted() echo ' </tr> </table> </div>'; }
function show_map($config) { ?> <div class="row" style="margin-bottom: 10px;"> <div class="col-md-12"> <style type="text/css"> #chart_div label { width: auto; display:inline; } #chart_div img { max-width: none; } </style> <!-- <div id="reset" style="width: 100%; text-align: right;"><input type="button" onclick="resetMap();" value="重置地图" /></div> --> <div id="chart_div" style="height: <?php echo $config['frontpage']['map']['height']; ?> px;"></div> <?php if ($config['frontpage']['map']['api'] != 'google-mc') { ?> <script type='text/javascript' src='//www.google.com/jsapi'></script> <script type='text/javascript'> google.load('visualization', '1.1', {'packages': ['geochart']}); google.setOnLoadCallback(drawRegionsMap); function drawRegionsMap() { var data = new google.visualization.DataTable(); data.addColumn('number', '纬度'); data.addColumn('number', '经度'); data.addColumn('string', '位置'); data.addColumn('number', '状态'); data.addColumn('number', '设备'); data.addColumn({type: 'string', role: 'tooltip'}); data.addColumn('string', 'url'); data.addRows([ <?php $locations_up = array(); $locations_down = array(); foreach (get_locations() as $location) { $location_name = $location == '' ? '[[UNKNOWN]]' : strtr(htmlspecialchars($location), "'", "`"); $location_url = generate_location_url($location); $devices_down = array(); $devices_up = array(); $count = $GLOBALS['cache']['device_locations'][$location]; $down = 0; foreach ($GLOBALS['cache']['devices']['id'] as $device) { if ($device['location'] == $location) { if ($device['status'] == "0" && $device['ignore'] == "0") { $down++; $devices_down[] = $device['hostname']; $lat = $device['location_lat']; $lon = $device['location_lon']; } else { if ($device['status'] == "1") { $devices_up[] = $device['hostname']; $lat = $device['location_lat']; $lon = $device['location_lon']; } } } } $count = $count < 100 ? $count : 100; if ($down > 0) { $locations_down[] = "[{$lat}, {$lon}, '{$location_name}', {$down}, " . $count * $down . ", '" . count($devices_up) . " 设备启用, " . count($devices_down) . " 设备关闭: (" . implode(", ", $devices_down) . ")', '{$location_url}']"; } else { if ($count) { $locations_up[] = "[" . $lat . ", " . $lon . ", '" . $location_name . "', 0, " . $count . ", '" . count($devices_up) . " Devices UP: (" . implode(", ", $devices_up) . ")', '{$location_url}']"; } } } echo implode(",\n ", array_merge($locations_up, $locations_down)); ?> ]); var options = { region: '<?php echo $config['frontpage']['map']['region']; ?> ', resolution: '<?php echo $config['frontpage']['map']['resolution']; ?> ', displayMode: 'markers', keepAspectRatio: 0, //width: 1240, //height: 480, is3D: true, legend: 'none', enableRegionInteractivity: true, <?php if ($config['frontpage']['map']['realworld']) { echo "\t\t datalessRegionColor: '#93CA76',"; } else { echo "\t\t datalessRegionColor: '#d5d5d5',"; } if ($config['frontpage']['map']['realworld']) { echo "\t\t backgroundColor: {fill: '#000000'},"; } ?> backgroundColor: {fill: 'transparent'}, magnifyingGlass: {enable: true, zoomFactor: 5}, colorAxis: {values: [0, 1, 2, 3], colors: ['darkgreen', 'orange', 'orangered', 'red']}, markerOpacity: 0.75, sizeAxis: {minValue: 1, maxValue: 10, minSize: 10, maxSize: 40} }; var view = new google.visualization.DataView(data); // exclude last url column in the GeoChart view.setColumns([0, 1, 2, 3, 4, 5]); var chart = new google.visualization.GeoChart(document.getElementById('chart_div')); google.visualization.events.addListener(chart, 'ready', onReady); function onReady() { google.visualization.events.addListener(chart, 'select', gotoLocation); } function gotoLocation() { var selection = chart.getSelection(); var item = selection[0]; var url = data.getValue(item.row, 6); window.location = url; } chart.draw(view, options); }; </script> <?php } else { // begin google-mc $where = ' WHERE 1 '; $where .= generate_query_permitted(array('device'), array('ignored' => TRUE)); //Detect map center if (!is_numeric($config['frontpage']['map']['center']['lat']) || !is_numeric($config['frontpage']['map']['center']['lng'])) { $map_center = dbFetchRow('SELECT MAX(`location_lon`) AS `lng_max`, MIN(`location_lon`) AS `lng_min`, MAX(`location_lat`) AS `lat_max`, MIN(`location_lat`) AS `lat_min` FROM `devices` ' . $where); $map_center['lat'] = ($map_center['lat_max'] + $map_center['lat_min']) / 2; $map_center['lng'] = ($map_center['lng_max'] + $map_center['lng_min']) / 2; $config['frontpage']['map']['center']['lat'] = $map_center['lat']; $config['frontpage']['map']['center']['lng'] = $map_center['lng']; //Also auto-zoom if (!is_numeric($config['frontpage']['map']['zoom'])) { $map_center['lat_size'] = abs($map_center['lat_max'] - $map_center['lat_min']); $map_center['lng_size'] = abs($map_center['lng_max'] - $map_center['lng_min']); $l_max = max($map_center['lng_size'], $map_center['lat_size'] * 2); // This is the magic array (2: min zoom, 10: max zoom). foreach (array(1 => 10, 2 => 9, 4 => 8, 6 => 7, 15 => 5, 45 => 4, 90 => 3, 360 => 2) as $g => $z) { if ($l_max <= $g) { $config['frontpage']['map']['zoom'] = $z; break; } } } /// r($map_center); } else { if (!is_numeric($config['frontpage']['map']['zoom'])) { $config['frontpage']['map']['zoom'] = 4; } } ?> <script type='text/javascript' src='//www.google.com/jsapi'></script> <script type="text/javascript" src="js/google/markerclusterer.js"></script> <script src="//maps.google.com/maps/api/js?sensor=false"></script> <?php if ($config['frontpage']['map']['clouds']) { ?> <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=weather"></script><?php } ?> <script type="text/javascript"> google.load('visualization', '1.1', {'packages': ['geochart']}); function getMapData() { var data = new google.visualization.DataTable(); data.addColumn('number', '纬度'); data.addColumn('number', '经度'); data.addColumn('number', '正常数量'); data.addColumn('number', '停止数量'); data.addColumn({type: 'string', role: 'tooltip'}); data.addColumn('string', '位置'); data.addColumn('string', 'url'); data.addRows([ <?php $locations = array(); foreach ($GLOBALS['cache']['devices']['id'] as $device) { if ($device["status"] == "0" && $device["ignore"] == "0" && $device["disabled"] == "0") { $locations[$device['location_lat']][$device['location_lon']]["down_hosts"][] = $device; } elseif ($device["status"] == "1") { $locations[$device['location_lat']][$device['location_lon']]["up_hosts"][] = $device; } } foreach ($locations as $la => $lat) { foreach ($lat as $lo => $lon) { $num_up = count($lon["up_hosts"]); $num_down = count($lon["down_hosts"]); $total_hosts = $num_up + $num_down; $tooltip = "{$total_hosts} Hosts"; $location_name = ""; if ($num_down > 0) { $location_name = $lon['down_hosts'][0]['location'] == '' ? '[[UNKNOWN]]' : strtr(htmlspecialchars($lon['down_hosts'][0]['location']), "'", "`"); $location_url = generate_location_url($lon['down_hosts'][0]['location']); $tooltip .= "\\n\\nDown hosts:"; foreach ($lon["down_hosts"] as $down_host) { $tooltip .= "\\n" . $down_host['hostname']; } } elseif ($num_up > 0) { $location_name = $lon['up_hosts'][0]['location'] == '' ? '[[UNKNOWN]]' : strtr(htmlspecialchars($lon['up_hosts'][0]['location']), "'", "`"); $location_url = generate_location_url($lon['up_hosts'][0]['location']); } echo "[{$la}, {$lo}, {$num_up}, {$num_down}, \"{$tooltip}\", '{$location_name}', '{$location_url}'],\n "; } } ?> ]); return data; } function initialize() { var data = getMapData(); var markers = []; var base_link = '<?php echo generate_url(array("page" => "devices")); ?> '; for (var i = 0; i < data.getNumberOfRows(); i++) { var latLng = new google.maps.LatLng(data.getValue(i, 0), data.getValue(i, 1)); icon_ = '//maps.gstatic.com/mapfiles/ridefinder-images/mm_20_green.png'; var num_up = data.getValue(i, 2); var num_down = data.getValue(i, 3); var location = data.getValue(i, 5); var ratio_up = num_up / (num_up + num_down); if (ratio_up < 0.9999) { icon_ = '//maps.gstatic.com/mapfiles/ridefinder-images/mm_20_red.png'; } var marker = new google.maps.Marker({ position: latLng, icon: icon_, title: data.getValue(i, 4), location: location, num_up: num_up, num_down: num_down, url: data.getValue(i, 6) }); // marker.num_up = num_up; // marker.num_down = num_down; markers.push(marker); google.maps.event.addDomListener(marker, 'click', function() { window.location.href = this.url; }); } var styles = []; for (var i = 0; i < 4; i++) { image_path = "/images/mapclusterer/"; image_ext = ".png"; styles.push({ url: image_path + i + image_ext, height: 52, width: 53 }); } var mcOptions = {gridSize: 30, maxZoom: 15, zoomOnClick: false, styles: styles }; var markerClusterer = new MarkerClusterer(map, markers, mcOptions); var iconCalculator = function(markers, numStyles) { var total_up = 0; var total_down = 0; for (var i = 0; i < markers.length; i++) { total_up += markers[i].num_up; total_down += markers[i].num_down; } var ratio_up = total_up / (total_up + total_down); //The map clusterer really does seem to use index-1... index_ = 1; if (ratio_up < 0.9999) { index_ = 4; // Could be 2, and then more code to use all 4 images } return { text: (total_up + total_down), index: index_ }; } markerClusterer.setCalculator(iconCalculator); } var center_ = new google.maps.LatLng(<?php echo $config['frontpage']['map']['center']['lat']; ?> , <?php echo $config['frontpage']['map']['center']['lng']; ?> ); var map = new google.maps.Map(document.getElementById('chart_div'), { zoom: <?php echo $config['frontpage']['map']['zoom']; ?> , center: center_, mapTypeId: google.maps.MapTypeId.ROADMAP }); <?php if ($config['frontpage']['map']['clouds']) { ?> var cloudLayer = new google.maps.weather.CloudLayer(); cloudLayer.setMap(map); <?php } ?> function resetMap() { map.setZoom(4); map.panTo(center_); } google.maps.event.addListener(map, 'click', function(event) { map.setZoom(map.getZoom() + <?php echo $config['frontpage']['map']['zooms_per_click']; ?> ); map.panTo(event.latLng); }); google.maps.event.addDomListener(window, 'load', initialize); </script> <?php } // End google-mc ?> </div> </div> <?php }
function print_device_header($device) { global $config; if (!is_array($device)) { print_error("Invalid device passed to print_device_header!"); } if ($device['status'] == '0') { $class = "div-alert"; } else { $class = "div-normal"; } if ($device['ignore'] == '1') { $class = "div-ignore-alert"; if ($device['status'] == '1') { $class = "div-ignore"; } } if ($device['disabled'] == '1') { $class = "div-disabled"; } $type = strtolower($device['os']); echo '<table class="table table-hover table-striped table-bordered table-condensed table-rounded" style="vertical-align: middle; margin-bottom: 10px;">'; echo ' <tr class="' . $device['html_row_class'] . '" style="vertical-align: middle;"> <td style="width: 1px; background-color: ' . $device['html_tab_colour'] . '; margin: 0px; padding: 0px; min-width: 10px; max-width: 10px;"></td> <td style="width: 70px; text-align: center; vertical-align: middle;">' . getImage($device) . '</td> <td style="vertical-align: middle;"><span style="font-size: 20px;">' . generate_device_link($device) . '</span> <br /><a href="' . generate_location_url($device['location']) . '">' . htmlspecialchars($device['location']) . '</a></td> <td>'; if (isset($config['os'][$device['os']]['over'])) { $graphs = $config['os'][$device['os']]['over']; } elseif (isset($device['os_group']) && isset($config['os'][$device['os_group']]['over'])) { $graphs = $config['os'][$device['os_group']]['over']; } else { $graphs = $config['os']['default']['over']; } $graph_array = array(); $graph_array['height'] = "100"; $graph_array['width'] = "310"; $graph_array['to'] = $config['time']['now']; $graph_array['device'] = $device['device_id']; $graph_array['type'] = "device_bits"; $graph_array['from'] = $config['time']['day']; $graph_array['legend'] = "no"; $graph_array['popup_title'] = $descr; $graph_array['height'] = "45"; $graph_array['width'] = "150"; $graph_array['bg'] = "FFFFFF00"; foreach ($graphs as $entry) { if ($entry['graph']) { $graph_array['type'] = $entry['graph']; echo '<div class="pull-right" style="padding: 2px; margin: 0;">'; print_graph_popup($graph_array); echo "<div style='padding: 0px; font-weight: bold; font-size: 7pt; text-align: center;'>" . $entry['text'] . "</div>"; echo "</div>"; } } echo ' </td> </tr> </table>'; }
function print_device_header($device) { global $config; if (!is_array($device)) { print_error("无效的设备通过对_header()!"); } if ($device['status'] == '0') { $class = "div-alert"; } else { $class = "div-normal"; } if ($device['ignore'] == '1') { $class = "div-ignore-alert"; if ($device['status'] == '1') { $class = "div-ignore"; } } if ($device['disabled'] == '1') { $class = "div-disabled"; } $type = strtolower($device['os']); echo '<table class="table table-hover table-striped table-bordered table-condensed table-rounded" style="vertical-align: middle; margin-bottom: 10px;">'; echo ' <tr class="' . $device['html_row_class'] . '" style="vertical-align: middle;"> <td class="state-marker"></td> <td style="width: 70px; text-align: center; vertical-align: middle;">' . get_device_icon($device) . '</td> <td style="vertical-align: middle;"><span style="font-size: 20px;">' . generate_device_link($device) . '</span> <br /><a href="' . generate_location_url($device['location']) . '">' . escape_html($device['location']) . '</a></td> <td>'; if (isset($config['os'][$device['os']]['over'])) { $graphs = $config['os'][$device['os']]['over']; } else { if (isset($device['os_group']) && isset($config['os'][$device['os_group']]['over'])) { $graphs = $config['os'][$device['os_group']]['over']; } else { $graphs = $config['os']['default']['over']; } } $graph_array = array(); $graph_array['height'] = "100"; $graph_array['width'] = "310"; $graph_array['to'] = $config['time']['now']; $graph_array['device'] = $device['device_id']; $graph_array['type'] = "device_bits"; $graph_array['from'] = $config['time']['day']; $graph_array['legend'] = "no"; $graph_array['popup_title'] = $descr; $graph_array['height'] = "45"; $graph_array['width'] = "150"; $graph_array['bg'] = "FFFFFF00"; // Preprocess device graphs array foreach ($device['graphs'] as $graph) { $graphs_enabled[] = $graph['graph']; } foreach ($graphs as $entry) { if ($entry['graph'] && in_array(str_replace('device_', '', $entry['graph']), $graphs_enabled) !== FALSE) { $graph_array['type'] = $entry['graph']; if (isset($entry['text'])) { // Text is provided in the array, this overrides the default $text = $entry['text']; } else { // No text provided for the minigraph, fetch from array preg_match('/^(?P<type>[a-z0-9A-Z-]+)_(?P<subtype>[a-z0-9A-Z-_]+)/', $entry['graph'], $graphtype); if (isset($graphtype['type']) && isset($graphtype['subtype'])) { $type = $graphtype['type']; $subtype = $graphtype['subtype']; $text = $config['graph_types'][$type][$subtype]['descr']; } else { $text = nicecase($subtype); // Fallback to the type itself as a string, should not happen! } } echo '<div class="pull-right" style="padding: 2px; margin: 0;">'; print_graph_popup($graph_array); echo "<div style='padding: 0px; font-weight: bold; font-size: 7pt; text-align: center;'>{$text}</div>"; echo "</div>"; } } echo ' </td> </tr> </table>'; }
function drawRegionsMap() { var data = new google.visualization.DataTable(); data.addColumn('number', 'Latitude'); data.addColumn('number', 'Longitude'); data.addColumn('string', 'Location'); data.addColumn('number', 'Status'); data.addColumn('number', 'Devices'); data.addColumn({type: 'string', role: 'tooltip'}); data.addColumn('string', 'url'); data.addRows([ <?php $locations_up = array(); $locations_down = array(); foreach (get_locations() as $location) { $location_name = $location === '' ? OBS_VAR_UNSET : strtr(escape_html($location), "'\\", "`/"); $location_url = generate_location_url($location); $devices_down = array(); $devices_up = array(); $count = $GLOBALS['cache']['device_locations'][$location]; $down = 0; foreach ($GLOBALS['cache']['devices']['id'] as $device) { if ($device['location'] == $location) { if ($device['status'] == "0" && $device['ignore'] == "0") { $down++; $devices_down[] = $device['hostname']; $lat = is_numeric($device['location_lat']) ? $device['location_lat'] : $config['geocoding']['default']['lat']; $lon = is_numeric($device['location_lon']) ? $device['location_lon'] : $config['geocoding']['default']['lon']; } else { if ($device['status'] == "1") { $devices_up[] = $device['hostname']; $lat = is_numeric($device['location_lat']) ? $device['location_lat'] : $config['geocoding']['default']['lat'];
function navbar_location_menu($array) { global $config; ksort($array['entries']); echo '<ul class="dropdown-menu">'; if (count($array['entries']) > "3") { foreach ($array['entries'] as $entry => $entry_data) { $image = '<i class="menu-icon oicon-building"></i>'; if ($entry_data['level'] == "location_country") { $code = $entry; $entry = country_from_code($entry); $image = '<i class="flag flag-' . $code . '"></i>'; } elseif ($entry_data['level'] == "location") { $name = $entry === '' ? OBS_VAR_UNSET : escape_html($entry); echo ' <li><a href="' . generate_location_url($entry) . '"><i class="menu-icon oicon-building-small"></i> ' . $name . ' [' . $entry_data['count'] . ']</a></li>'; continue; } $url = $entry_data['level'] == 'location_country' ? $code : $entry; echo '<li class="dropdown-submenu"><a href="' . generate_url(array('page' => 'devices', $entry_data['level'] => var_encode($url))) . '">' . $image . ' ' . $entry . ' [' . $entry_data['count'] . ']</a>'; navbar_location_menu($entry_data); echo '</li>'; } } else { $new_entry_array = array(); foreach ($array['entries'] as $new_entry => $new_entry_data) { if ($new_entry_data['level'] == "location_country") { $code = $new_entry; $new_entry = country_from_code($new_entry); $image = '<i class="flag flag-' . $code . '"></i> '; } elseif ($new_entry_data['level'] == "location") { $name = $new_entry === '' ? OBS_VAR_UNSET : escape_html($new_entry); echo ' <li><a href="' . generate_location_url($new_entry) . '"><i class="menu-icon oicon-building-small"></i> ' . $name . ' [' . $new_entry_data['count'] . ']</a></li>'; continue; } echo '<li class="nav-header">' . $image . $new_entry . '</li>'; foreach ($new_entry_data['entries'] as $sub_entry => $sub_entry_data) { if (is_array($sub_entry_data['entries'])) { echo '<li class="dropdown-submenu"><a style="" href="' . generate_url(array('page' => 'devices', $sub_entry_data['level'] => var_encode($sub_entry))) . '"> <i class="menu-icon oicon-building"></i> ' . $sub_entry . ' [' . $sub_entry_data['count'] . ']</a>'; navbar_location_menu($sub_entry_data); } else { $name = $sub_entry === '' ? OBS_VAR_UNSET : escape_html($sub_entry); echo ' <li><a href="' . generate_location_url($sub_entry) . '"><i class="menu-icon oicon-building-small"></i> ' . $name . ' [' . $sub_entry_data['count'] . ']</a></li>'; } } } } echo '</ul>'; }
function navbar_location_menu($array) { global $config; ksort($array['entries']); echo '<ul role="menu" class="dropdown-menu">'; if (count($array['entries']) > "5") { foreach ($array['entries'] as $entry => $entry_data) { $image = '<i class="menu-icon oicon-building"></i>'; if ($entry_data['level'] == "location_country") { $code = $entry; $entry = country_from_code($entry); $image = '<i class="flag flag-' . $code . '"></i>'; } else { if ($entry_data['level'] == "location") { $name = $entry === '' ? OBS_VAR_UNSET : escape_html($entry); echo ' <li>' . generate_menu_link(generate_location_url($entry), '<i class="menu-icon oicon-building-small"></i> ' . $name, $entry_data['count']) . '</li>'; continue; } } if ($entry_data['level'] == "location_country") { $url = $code; // Attach country code to sublevel $entry_data['country'] = strtolower($code); } else { $url = $entry; // Attach country code to sublevel $entry_data['country'] = $array['country']; } if ($url === '') { $url = array(''); } $link_array = array('page' => 'devices', $entry_data['level'] => var_encode($url)); if (isset($array['country'])) { $link_array['location_country'] = var_encode($array['country']); } echo '<li class="dropdown-submenu">' . generate_menu_link(generate_url($link_array), $image . ' ' . $entry, $entry_data['count']); navbar_location_menu($entry_data); echo '</li>'; } } else { $new_entry_array = array(); foreach ($array['entries'] as $new_entry => $new_entry_data) { if ($new_entry_data['level'] == "location_country") { $code = $new_entry; $new_entry = country_from_code($new_entry); $image = '<i class="flag flag-' . $code . '"></i> '; } elseif ($new_entry_data['level'] == "location") { $name = $new_entry === '' ? OBS_VAR_UNSET : escape_html($new_entry); echo ' <li>' . generate_menu_link(generate_location_url($new_entry), '<i class="menu-icon oicon-building-small"></i> ' . $name, $new_entry_data['count']) . '</li>'; continue; } echo '<li class="nav-header">' . $image . $new_entry . '</li>'; foreach ($new_entry_data['entries'] as $sub_entry => $sub_entry_data) { if (is_array($sub_entry_data['entries'])) { $link_array = array('page' => 'devices', $sub_entry_data['level'] => var_encode($sub_entry)); if (isset($array['country'])) { $link_array['location_country'] = var_encode($array['country']); } echo '<li class="dropdown-submenu">' . generate_menu_link(generate_url($link_array), '<i class="menu-icon oicon-building"></i> ' . $sub_entry, $sub_entry_data['count']); navbar_location_menu($sub_entry_data); } else { $name = $sub_entry === '' ? OBS_VAR_UNSET : escape_html($sub_entry); echo ' <li>' . generate_menu_link(generate_location_url($sub_entry), '<i class="menu-icon oicon-building-small"></i> ' . $name, $sub_entry_data['count']) . '</li>'; } } } } echo '</ul>'; }