2016-02-04 12:06:45 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// Pandora FMS - http://pandorafms.com
|
|
|
|
// ==================================================
|
|
|
|
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
|
|
|
// Please see http://pandorafms.org for full contribution list
|
|
|
|
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation; version 2
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @package Include
|
|
|
|
* @subpackage Maps
|
|
|
|
*/
|
|
|
|
|
2016-02-04 16:59:40 +01:00
|
|
|
abstract class Map {
|
2016-02-08 13:47:46 +01:00
|
|
|
protected $status = STATUS_OK;
|
|
|
|
|
2016-02-04 12:06:45 +01:00
|
|
|
protected $id = null;
|
|
|
|
|
2016-02-04 16:59:40 +01:00
|
|
|
protected $type = null;
|
|
|
|
protected $subtype = null;
|
2016-02-08 13:47:46 +01:00
|
|
|
protected $id_group = null;
|
2016-02-09 13:52:03 +01:00
|
|
|
protected $generation_method = null;
|
2016-02-17 12:25:03 +01:00
|
|
|
|
2016-02-10 14:17:08 +01:00
|
|
|
protected $width = null;
|
|
|
|
protected $height = null;
|
2016-02-17 12:25:03 +01:00
|
|
|
|
2016-02-22 12:05:28 +01:00
|
|
|
protected $nodes = array();
|
|
|
|
protected $edges = array();
|
2016-02-04 16:59:40 +01:00
|
|
|
|
|
|
|
protected $requires_js = null;
|
|
|
|
|
2016-02-22 13:18:54 +01:00
|
|
|
public static function getName($id = null) {
|
|
|
|
if (empty($id)) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return db_get_value('name', 'tmap', 'id', $id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-04 12:06:45 +01:00
|
|
|
public function __construct($id) {
|
|
|
|
$this->id = $id;
|
2016-02-04 16:59:40 +01:00
|
|
|
|
2016-02-09 11:02:41 +01:00
|
|
|
$this->requires_js = array();
|
|
|
|
$this->requires_js[] = "include/javascript/d3.3.5.14.js";
|
|
|
|
$this->requires_js[] = "include/javascript/map/MapController.js";
|
2016-02-18 10:51:33 +01:00
|
|
|
$this->requires_js[] = "include/javascript/jquery.tooltipster.js";
|
2016-02-19 13:17:18 +01:00
|
|
|
$this->requires_js[] = "include/javascript/jquery.svg.js";
|
|
|
|
$this->requires_js[] = "include/javascript/jquery.svgdom.js";
|
2016-02-22 13:18:54 +01:00
|
|
|
|
2016-02-08 13:47:46 +01:00
|
|
|
if (!$this->loadDB()) {
|
|
|
|
$this->status = STATUS_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function processDBValues($dbValues) {
|
|
|
|
$this->type = (int)$dbValues['type'];
|
|
|
|
$this->subtype = (int)$dbValues['subtype'];
|
2016-02-04 16:59:40 +01:00
|
|
|
|
2016-02-08 13:47:46 +01:00
|
|
|
$this->id_group = (int)$dbValues['id_group'];
|
2016-02-09 13:52:03 +01:00
|
|
|
$this->generation_method = (int)$dbValues['generation_method'];
|
2016-02-12 17:22:44 +01:00
|
|
|
|
2016-02-10 14:17:08 +01:00
|
|
|
$this->width = (int)$dbValues['width'];
|
|
|
|
$this->height = (int)$dbValues['height'];
|
2016-02-04 12:06:45 +01:00
|
|
|
}
|
|
|
|
|
2016-02-04 16:59:40 +01:00
|
|
|
private function loadDB() {
|
|
|
|
$row = db_get_row_filter('tmap', array('id' => $this->id));
|
|
|
|
|
2016-02-08 13:47:46 +01:00
|
|
|
if (empty($row))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
switch (get_class($this)) {
|
|
|
|
case 'Networkmap':
|
|
|
|
Networkmap::processDBValues($row);
|
|
|
|
break;
|
|
|
|
case 'NetworkmapEnterprise':
|
|
|
|
NetworkmapEnterprise::processDBValues($row);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$this->processDBValues($row);
|
|
|
|
break;
|
|
|
|
}
|
2016-02-04 16:59:40 +01:00
|
|
|
}
|
|
|
|
|
2016-02-08 13:47:46 +01:00
|
|
|
abstract function printJSInit();
|
2016-02-04 16:59:40 +01:00
|
|
|
|
2016-02-17 15:36:44 +01:00
|
|
|
public function writeJSGraph() {
|
|
|
|
?>
|
|
|
|
<script type="text/javascript">
|
|
|
|
<?php
|
|
|
|
echo "var nodes = " . json_encode($this->nodes) . ";";
|
|
|
|
echo "var edges = " . json_encode($this->edges) . ";";
|
|
|
|
?>
|
2016-02-22 12:05:28 +01:00
|
|
|
var temp = [];
|
|
|
|
for (var i in nodes) { temp[parseInt(i)] = nodes[i];}
|
|
|
|
nodes = temp;
|
|
|
|
|
|
|
|
temp = [];
|
|
|
|
for (var i in edges) { temp[parseInt(i)] = edges[i];}
|
|
|
|
edges = temp;
|
2016-02-17 15:36:44 +01:00
|
|
|
</script>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
2016-02-04 12:06:45 +01:00
|
|
|
public function show() {
|
2016-02-18 15:33:24 +01:00
|
|
|
// Tooltip css
|
|
|
|
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"include/styles/tooltipster.css\"/>" . "\n";
|
2016-02-22 11:48:42 +01:00
|
|
|
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"include/styles/tooltipster-punk.css\"/>" . "\n";
|
|
|
|
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"include/styles/tooltipster-shadow.css\"/>" . "\n";
|
|
|
|
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"include/styles/tooltipster-noir.css\"/>" . "\n";
|
|
|
|
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"include/styles/tooltipster-light.css\"/>" . "\n";
|
2016-02-24 13:04:38 +01:00
|
|
|
//Tooltips spinner
|
|
|
|
echo "<div id='spinner_tooltip' style='display:none;'>";
|
|
|
|
html_print_image('images/spinner.gif');
|
|
|
|
echo "</div>";
|
2016-02-04 16:59:40 +01:00
|
|
|
foreach ($this->requires_js as $js) {
|
|
|
|
echo "<script type='text/javascript' src='$js'></script>" . "\n";
|
|
|
|
}
|
|
|
|
|
2016-02-17 15:36:44 +01:00
|
|
|
$this->writeJSContants();
|
|
|
|
$this->writeJSGraph();
|
|
|
|
|
2016-02-04 12:06:45 +01:00
|
|
|
?>
|
2016-02-25 16:18:14 +01:00
|
|
|
<style type="text/css">
|
|
|
|
.title_bar {
|
|
|
|
border-bottom: 1px solid black;
|
|
|
|
}
|
|
|
|
.title_bar .title {
|
|
|
|
font-weight: bolder;
|
|
|
|
}
|
|
|
|
|
|
|
|
.title_bar .open_click {
|
|
|
|
float: right;
|
|
|
|
display: table-cell;
|
|
|
|
font-weight: bolder;
|
|
|
|
font-size: 20px;
|
|
|
|
background: blue none repeat scroll 0% 0%;
|
|
|
|
color: white;
|
|
|
|
width: 17px;
|
|
|
|
height: 17px;
|
|
|
|
cursor: pointer;
|
|
|
|
text-align: center;
|
|
|
|
vertical-align: middle;
|
|
|
|
margin: 1px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.title_bar .close_click {
|
|
|
|
float: right;
|
|
|
|
display: table-cell;
|
|
|
|
font-weight: bolder;
|
|
|
|
font-size: 20px;
|
|
|
|
background: blue none repeat scroll 0% 0%;
|
|
|
|
color: white;
|
|
|
|
width: 17px;
|
|
|
|
height: 17px;
|
|
|
|
cursor: pointer;
|
|
|
|
text-align: center;
|
|
|
|
vertical-align: middle;
|
|
|
|
margin: 1px;
|
|
|
|
}
|
|
|
|
</style>
|
2016-02-22 17:14:18 +01:00
|
|
|
<div id="map" data-id="<?php echo $this->id;?>" style="border: 1px red solid;">
|
2016-02-24 14:12:07 +01:00
|
|
|
<div class="zoom_box" style="position: absolute;">
|
2016-02-22 18:54:19 +01:00
|
|
|
<style type="text/css">
|
|
|
|
.zoom_controller {
|
|
|
|
width: 30px;
|
|
|
|
height: 210px;
|
|
|
|
background: blue;
|
|
|
|
border-radius: 15px;
|
|
|
|
|
2016-02-24 14:12:07 +01:00
|
|
|
top: 50px;
|
2016-02-22 18:54:19 +01:00
|
|
|
left: 10px;
|
|
|
|
position: absolute;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.vertical_range {
|
|
|
|
padding: 0;
|
|
|
|
-webkit-transform: rotate(270deg);
|
|
|
|
-moz-transform: rotate(270deg);
|
|
|
|
transform: rotate(270deg);
|
|
|
|
width: 200px;
|
|
|
|
height: 20px;
|
|
|
|
position: relative;
|
|
|
|
background: transparent !important;
|
|
|
|
border: 0px !important;
|
|
|
|
}
|
|
|
|
|
|
|
|
.vertical_range {
|
|
|
|
left: -92px;
|
|
|
|
top: 93px;
|
|
|
|
}
|
|
|
|
|
|
|
|
@media screen and (-webkit-min-device-pixel-ratio:0)
|
|
|
|
{
|
|
|
|
/* Only for chrome */
|
|
|
|
|
|
|
|
.vertical_range {
|
|
|
|
left: -87px;
|
|
|
|
top: 93px;
|
|
|
|
}
|
2016-02-23 16:48:58 +01:00
|
|
|
}
|
2016-02-22 18:54:19 +01:00
|
|
|
|
|
|
|
.home_zoom {
|
2016-02-24 14:12:07 +01:00
|
|
|
top: 310px;
|
2016-02-23 16:48:58 +01:00
|
|
|
left: 10px;
|
|
|
|
|
|
|
|
display: table-cell;
|
2016-02-22 18:54:19 +01:00
|
|
|
position: absolute;
|
|
|
|
font-weight: bolder;
|
|
|
|
font-size: 20px;
|
|
|
|
background: blue;
|
|
|
|
color: white;
|
2016-02-23 16:48:58 +01:00
|
|
|
border-radius: 15px;
|
|
|
|
width: 30px;
|
|
|
|
height: 30px;
|
|
|
|
cursor:pointer;
|
|
|
|
text-align: center;
|
|
|
|
vertical-align: middle;
|
|
|
|
}
|
|
|
|
|
|
|
|
.zoom_in {
|
|
|
|
top: 10px;
|
|
|
|
left: 10px;
|
|
|
|
|
|
|
|
display: table-cell;
|
2016-02-24 14:12:07 +01:00
|
|
|
position: absolute;
|
2016-02-23 16:48:58 +01:00
|
|
|
font-weight: bolder;
|
|
|
|
font-size: 20px;
|
|
|
|
background: blue;
|
|
|
|
color: white;
|
|
|
|
border-radius: 15px;
|
|
|
|
width: 30px;
|
|
|
|
height: 30px;
|
|
|
|
cursor:pointer;
|
|
|
|
text-align: center;
|
|
|
|
vertical-align: middle;
|
|
|
|
}
|
|
|
|
|
|
|
|
.zoom_out {
|
2016-02-24 14:12:07 +01:00
|
|
|
top: 270px;
|
2016-02-23 16:48:58 +01:00
|
|
|
left: 10px;
|
|
|
|
|
|
|
|
display: table-cell;
|
|
|
|
position: absolute;
|
|
|
|
font-weight: bolder;
|
|
|
|
font-size: 20px;
|
|
|
|
background: blue;
|
|
|
|
color: white;
|
|
|
|
border-radius: 15px;
|
|
|
|
width: 30px;
|
|
|
|
height: 30px;
|
2016-02-23 09:33:49 +01:00
|
|
|
cursor:pointer;
|
2016-02-23 16:48:58 +01:00
|
|
|
text-align: center;
|
|
|
|
vertical-align: middle;
|
2016-02-22 18:54:19 +01:00
|
|
|
}
|
|
|
|
</style>
|
2016-02-23 16:48:58 +01:00
|
|
|
<div class="zoom_controller">
|
|
|
|
<input class="vertical_range" type="range" name="range" min="-666" max="666" step="1" value="666" />
|
|
|
|
</div>
|
|
|
|
<div class="zoom_in">+</div>
|
|
|
|
<div class="zoom_out">-</div>
|
|
|
|
<div class="home_zoom">H</div>
|
2016-02-22 18:54:19 +01:00
|
|
|
</div>
|
2016-02-17 15:36:44 +01:00
|
|
|
<?php
|
|
|
|
if ($this->width == 0) {
|
|
|
|
$width = "100%";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$width = $this->width . "px";
|
|
|
|
}
|
|
|
|
if ($this->height == 0) {
|
|
|
|
$height = "500px";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$height = $this->height . "px";
|
|
|
|
}
|
|
|
|
?>
|
2016-02-22 17:14:18 +01:00
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" pointer-events="all" width="<?php echo $width;?>" height="<?php echo $height;?>">
|
2016-02-04 12:06:45 +01:00
|
|
|
</svg>
|
|
|
|
</div>
|
2016-02-04 16:59:40 +01:00
|
|
|
|
2016-02-04 12:06:45 +01:00
|
|
|
<?php
|
2016-02-08 13:47:46 +01:00
|
|
|
$this->printJSInit();
|
|
|
|
}
|
|
|
|
|
2016-02-17 15:36:44 +01:00
|
|
|
public function writeJSContants() {
|
2016-02-17 18:31:46 +01:00
|
|
|
$contants = array();
|
|
|
|
$contants["ITEM_TYPE_AGENT_NETWORKMAP"] = ITEM_TYPE_AGENT_NETWORKMAP;
|
|
|
|
$contants["ITEM_TYPE_MODULE_NETWORKMAP"] = ITEM_TYPE_MODULE_NETWORKMAP;
|
|
|
|
$contants["ITEM_TYPE_EDGE_NETWORKMAP"] = ITEM_TYPE_EDGE_NETWORKMAP;
|
2016-02-17 15:36:44 +01:00
|
|
|
?>
|
|
|
|
<script type="text/javascript">
|
|
|
|
<?php
|
2016-02-17 18:31:46 +01:00
|
|
|
foreach ($contants as $name => $value) {
|
|
|
|
echo "var $name = $value \n";
|
|
|
|
}
|
2016-02-17 15:36:44 +01:00
|
|
|
?>
|
|
|
|
</script>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
2016-02-08 13:47:46 +01:00
|
|
|
public function getType() {
|
|
|
|
return $this->type;
|
2016-02-04 12:06:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|