mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 08:14:38 +02:00
Update networkmap class with simple map
Former-commit-id: cb6bd489ba973cf0f9c6eda8dee062518f33f382
This commit is contained in:
parent
7e345035e1
commit
8a7702e054
@ -117,6 +117,16 @@ class NetworkMap
|
||||
*/
|
||||
public $mapOptions;
|
||||
|
||||
/**
|
||||
* loadfile function array
|
||||
* file path
|
||||
* function name
|
||||
* extra parameter(cluster)
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $loadfile;
|
||||
|
||||
|
||||
/**
|
||||
* Base constructor.
|
||||
@ -154,6 +164,15 @@ class NetworkMap
|
||||
$this->mapOptions['strict_user'] = false;
|
||||
$this->mapOptions['size_canvas'] = null;
|
||||
$this->mapOptions['old_mode'] = false;
|
||||
$this->mapOptions['baseurl'] = ui_get_full_url(false, false, false, false);
|
||||
$this->mapOptions['width'] = '100%';
|
||||
$this->mapOptions['height'] = 600;
|
||||
$this->mapOptions['node_radius'] = 40;
|
||||
$this->mapOptions['id_cluster'] = null;
|
||||
$this->mapOptions['tooltip'] = false;
|
||||
$this->mapOptions['size_image'] = 40;
|
||||
$this->mapOptions['page_tooltip'] = null;
|
||||
|
||||
$this->mapOptions['map_filter'] = [
|
||||
'dont_show_subgroups' => 0,
|
||||
'node_radius' => 40,
|
||||
@ -206,6 +225,14 @@ class NetworkMap
|
||||
}
|
||||
}
|
||||
|
||||
// loadfile options
|
||||
// This is only used while generating simple maps
|
||||
if (is_array($options['loadfile'])) {
|
||||
foreach ($options['loadfile'] as $k => $v) {
|
||||
$this->loadfile[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
// Load from tmap.
|
||||
if ($options['id_map']) {
|
||||
$this->idMap = $options['id_map'];
|
||||
@ -482,6 +509,22 @@ class NetworkMap
|
||||
public function generateDotGraph()
|
||||
{
|
||||
if (!isset($this->dotGraph)) {
|
||||
if (isset($this->mode) && $this->mode === 'simple') {
|
||||
include_once $config['homedir'].'/include/functions_maps.php';
|
||||
$graph .= open_graph();
|
||||
|
||||
foreach ($this->nodes as $key => $value) {
|
||||
$graph .= create_node($value, $this->mapOptions['font_size']);
|
||||
}
|
||||
|
||||
foreach ($this->relations as $key => $relation) {
|
||||
$graph .= create_edge($key, $relation);
|
||||
}
|
||||
|
||||
$graph .= close_graph();
|
||||
|
||||
$this->dotGraph = $graph;
|
||||
} else {
|
||||
// Generate dot file.
|
||||
$this->dotGraph = networkmap_generate_dot(
|
||||
get_product_name(),
|
||||
@ -510,7 +553,7 @@ class NetworkMap
|
||||
$this->mapOptions['map_filter']
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -652,6 +695,19 @@ class NetworkMap
|
||||
|
||||
unlink($filename_dot);
|
||||
|
||||
if (isset($this->mode) && $this->mode === 'simple') {
|
||||
if (isset($this->loadfile)) {
|
||||
include_once $this->loadfile[0];
|
||||
$func = $this->loadfile[1];
|
||||
// Extra parameter. Used in clustermap.
|
||||
if (isset($this->mapOptions['id_cluster'])) {
|
||||
$this->graph = $func($filename_plain, $this->dotGraph, $this->mapOptions['id_cluster']);
|
||||
} else {
|
||||
$this->graph = $func($filename_plain, $this->dotGraph);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
} else {
|
||||
$nodes = networkmap_loadfile(
|
||||
$this->idMap,
|
||||
$filename_plain,
|
||||
@ -803,7 +859,7 @@ class NetworkMap
|
||||
}
|
||||
|
||||
$this->graph = $nodes_and_relations;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -814,6 +870,29 @@ class NetworkMap
|
||||
*/
|
||||
public function loadMapData()
|
||||
{
|
||||
if (isset($this->mode) && $this->mode === 'simple') {
|
||||
$output .= '<script type="text/javascript">';
|
||||
$output .= "var controller_map = null;\n";
|
||||
$output .= 'var size_image ='.json_encode($this->mapOptions['size_image']).";\n";
|
||||
$output .= 'var tooltipster ='.json_encode($this->mapOptions['tootltip']).";\n";
|
||||
$output .= 'var nodes = '.json_encode($this->graph['nodes']).";\n";
|
||||
$output .= 'var arrows = '.json_encode($this->graph['arrows']).";\n";
|
||||
$output .= 'var height = '.json_encode($this->mapOptions['height']).";\n";
|
||||
$output .= 'var node_radius ='.json_encode($this->mapOptions['node_radius']).";\n";
|
||||
$output .= 'var font_size ='.json_encode($this->mapOptions['font_size']).";\n";
|
||||
$output .= 'var homedir ='.json_encode($this->mapOptions['baseurl']).";\n";
|
||||
$output .= "var custom_params = {};\n";
|
||||
$output .= "custom_params['get_tooltip_info'] = 1;\n";
|
||||
if ($this->mapOptions['id_cluster'] != null) {
|
||||
$output .= "custom_params['id_cluster'] = ".$this->mapOptions['id_cluster'].";\n";
|
||||
$output .= 'var id_cluster ='.json_encode($this->mapOptions['id_cluster']).";\n";
|
||||
}
|
||||
|
||||
$output .= "custom_params['page'] = 'enterprise/include/ajax/clustermap';\n";
|
||||
$output .= '</script>';
|
||||
|
||||
return $output;
|
||||
} else {
|
||||
$networkmap = $this->map;
|
||||
|
||||
$simulate = false;
|
||||
@ -1030,6 +1109,7 @@ class NetworkMap
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -1446,10 +1526,20 @@ class NetworkMap
|
||||
{
|
||||
$output = '';
|
||||
|
||||
if (isset($this->mode) && $this->mode === 'simple') {
|
||||
$output .= '<script type="text/javascript">
|
||||
var controller = null
|
||||
$(function() {
|
||||
controller = new SimpleMapController("#simple_map");
|
||||
controller.init_map();
|
||||
});
|
||||
</script>';
|
||||
echo $output;
|
||||
} else {
|
||||
// Generate JS for advanced controller.
|
||||
$output .= '
|
||||
|
||||
<script type="text/javascript">
|
||||
<script type="text/javascript">
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// document ready
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
@ -1479,13 +1569,14 @@ class NetworkMap
|
||||
}
|
||||
);
|
||||
});
|
||||
</script>';
|
||||
</script>';
|
||||
|
||||
if ($return === false) {
|
||||
echo $output;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1499,10 +1590,27 @@ class NetworkMap
|
||||
{
|
||||
global $config;
|
||||
|
||||
$output = '';
|
||||
|
||||
if (isset($this->mode) && $this->mode === 'simple') {
|
||||
$output .= '<script type="text/javascript" src="'.$config['homeurl'].'include/javascript/d3.3.5.14.js" charset="utf-8"></script>';
|
||||
$output .= '<script type="text/javascript" src="'.$config['homeurl'].'enterprise/include/javascript/SimpleMapController.js"></script>';
|
||||
$output .= '<script type="text/javascript" src="'.$config['homeurl'].'enterprise/include/javascript/tooltipster.bundle.min.js"></script>';
|
||||
$output .= '<script type="text/javascript" src="'.$config['homeurl'].'include/javascript/jquery.svg.js"></script>';
|
||||
$output .= '<script type="text/javascript" src="'.$config['homeurl'].'include/javascript/jquery.svgdom.js"></script>';
|
||||
$output .= '<link rel="stylesheet" type="text/css" href="'.$this->mapOptions['baseurl'].'/enterprise/include/styles/tooltipster.bundle.min.css" />'."\n";
|
||||
|
||||
$output .= '<div id="simple_map" data-id="<?php echo $this->name;?>" style="border: 1px #dddddd solid;">';
|
||||
$output .= '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" pointer-events="all" width="'.$this->mapOptions['width'].'" height="'.$this->mapOptions['height'].'px">';
|
||||
|
||||
$output .= '</svg>';
|
||||
$output .= '</div>';
|
||||
|
||||
return $output;
|
||||
} else {
|
||||
ui_require_css_file('networkmap');
|
||||
ui_require_css_file('jquery.contextMenu', 'include/styles/js/');
|
||||
|
||||
$output = '';
|
||||
$minimap_display = '';
|
||||
if ($this->mapOptions['pure']) {
|
||||
$minimap_display = 'none';
|
||||
@ -1549,6 +1657,7 @@ class NetworkMap
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user