Fixed maps in Windows. Tiquet: #2153

(cherry picked from commit 298b509b97)
This commit is contained in:
m-lopez-f 2015-06-23 15:12:42 +02:00
parent 8b518ae9b2
commit 83a88d7a91
2 changed files with 22 additions and 4 deletions

View File

@ -109,8 +109,16 @@ else {
io_safe_output($config['graphviz_bin_dir'] . "/")
:
"";
$is_windows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN';
if ($is_windows) {
$graphviz_path = str_replace("/", "\\", $graphviz_path );
$filter = $filter . '.exe';
}
$cmd = escapeshellarg($graphviz_path.$filter) . " -Tcmapx " . escapeshellarg("-o$filename_map") . " -Tpng ". escapeshellarg("-o$filename_img") . " " . escapeshellarg($filename_dot);
$cmd = escapeshellarg($graphviz_path.$filter) . " -Tcmapx " .
escapeshellarg("-o$filename_map") . " -Tpng ".
escapeshellarg("-o$filename_img") . " " .
escapeshellarg($filename_dot);
$result = system ($cmd);
fclose ($fh);
unlink ($filename_dot);
@ -128,7 +136,10 @@ if ($result !== false) {
return;
}
echo "<div style='text-align:center'>";
$image_url = str_replace(realpath(io_safe_output($config['homedir'])), "", realpath($filename_img));
if ($is_windows)
$image_url = str_replace('\\',"/",str_replace($config['homedir'], "", $filename_img));
else
$image_url = str_replace(realpath(io_safe_output($config['homedir'])), "", realpath($filename_img));
html_print_image ($image_url, false, array ("alt" => __('Network map'), "usemap" => "#networkmap"));
echo "</div>";
require ($filename_map);

View File

@ -114,13 +114,20 @@ else {
io_safe_output($config['graphviz_bin_dir'] . "/")
:
"";
$is_windows = strtoupper(substr(PHP_OS, 0, 3)) == 'WIN';
if ($is_windows) {
$graphviz_path = str_replace("/", "\\", $graphviz_path );
$filename_map = str_replace("/", "\\", $filename_map );
$filename_img = str_replace("/", "\\", $filename_img );
$filename_dot = str_replace("/", "\\", $filename_dot );
$filter = $filter . '.exe';
}
$cmd = escapeshellarg($graphviz_path . $filter) .
" -Tcmapx " . escapeshellarg("-o$filename_map") .
" -Tpng ". escapeshellarg("-o$filename_img") .
" " . escapeshellarg($filename_dot);
$result = system ($cmd);
fclose ($fh);
unlink ($filename_dot);
//~ html_debug_print($cmd);