diff --git a/datamodels/2.x/itop-change-mgmt-itil/lifecycle/EmergencyChange.png b/datamodels/2.x/itop-change-mgmt-itil/lifecycle/EmergencyChange.png index 04303e020..2cb380c0d 100644 Binary files a/datamodels/2.x/itop-change-mgmt-itil/lifecycle/EmergencyChange.png and b/datamodels/2.x/itop-change-mgmt-itil/lifecycle/EmergencyChange.png differ diff --git a/datamodels/2.x/itop-change-mgmt-itil/lifecycle/NormalChange.png b/datamodels/2.x/itop-change-mgmt-itil/lifecycle/NormalChange.png index ce9ddfb10..23842f486 100644 Binary files a/datamodels/2.x/itop-change-mgmt-itil/lifecycle/NormalChange.png and b/datamodels/2.x/itop-change-mgmt-itil/lifecycle/NormalChange.png differ diff --git a/datamodels/2.x/itop-change-mgmt-itil/lifecycle/RoutineChange.png b/datamodels/2.x/itop-change-mgmt-itil/lifecycle/RoutineChange.png index 5d3632b7e..c1ac7e5ca 100644 Binary files a/datamodels/2.x/itop-change-mgmt-itil/lifecycle/RoutineChange.png and b/datamodels/2.x/itop-change-mgmt-itil/lifecycle/RoutineChange.png differ diff --git a/datamodels/2.x/itop-incident-mgmt-itil/lifecycle/Incident.png b/datamodels/2.x/itop-incident-mgmt-itil/lifecycle/Incident.png index 3a339206e..6680bc90e 100644 Binary files a/datamodels/2.x/itop-incident-mgmt-itil/lifecycle/Incident.png and b/datamodels/2.x/itop-incident-mgmt-itil/lifecycle/Incident.png differ diff --git a/datamodels/2.x/itop-request-mgmt-itil/lifecycle/UserRequest.png b/datamodels/2.x/itop-request-mgmt-itil/lifecycle/UserRequest.png index 2ea721a3d..d0d71538e 100644 Binary files a/datamodels/2.x/itop-request-mgmt-itil/lifecycle/UserRequest.png and b/datamodels/2.x/itop-request-mgmt-itil/lifecycle/UserRequest.png differ diff --git a/pages/graphviz.php b/pages/graphviz.php index 403815cb5..80766d10b 100644 --- a/pages/graphviz.php +++ b/pages/graphviz.php @@ -62,9 +62,10 @@ function GraphvizLifecycle($sClass) $aStates = MetaModel::EnumStates($sClass); $aStimuli = MetaModel::EnumStimuli($sClass); $sDotFileContent .= "digraph finite_state_machine { + graph [bgcolor = \"transparent\"]; rankdir=LR; size=\"12,12\" - node [ fontname=Verdana ]; + node [ fontname=Verdana style=filled fillcolor=\"#ffffff\" ]; edge [ fontname=Verdana ]; "; $aStatesLinks = array(); @@ -108,25 +109,55 @@ function GraphvizLifecycle($sClass) return $sDotFileContent; } -$sClass = utils::ReadParam('class', 'bizIncidentTicket', false, 'class'); -$sDir = dirname(__FILE__); -$sImageFilePath = $sDir."/../images/lifecycle/".$sClass.".png"; +$sClass = utils::ReadParam('class', '', false, 'class'); +$oReflection = new ReflectionClass($sClass); +$sDeclarationFile = $oReflection->getFileName(); +$sModuleDir = dirname($sDeclarationFile); + +$sImageFilePath = $sModuleDir."/lifecycle/".$sClass.".png"; $sDotExecutable = MetaModel::GetConfig()->Get('graphviz_path'); if (file_exists($sDotExecutable)) { // create the file with Graphviz + $sImageFilePath = APPROOT."data/lifecycle/".$sClass.".png"; + if (!is_dir(APPROOT."data")) + { + @mkdir(APPROOT."data"); + } + if (!is_dir(APPROOT."data/lifecycle")) + { + @mkdir(APPROOT."data/lifecycle"); + } $sDotDescription = GraphvizLifecycle($sClass); - $sDotFilePath = $sDir."/tmp-lifecycle.dot"; - // From now on, fail silently, since the image file may - // already exist and we should not "pollute" the page's output - // with warnings in case we are unable to refresh the image + $sDotFilePath = APPROOT."data/lifecycle/{$sClass}.dot"; + $rFile = @fopen($sDotFilePath, "w"); @fwrite($rFile, $sDotDescription); @fclose($rFile); - //echo "

Executing command: $sDotExecutable -Tpng < $sDotFilePath > $sImageFilePath

\n"; - @exec("$sDotExecutable -Tpng < $sDotFilePath > $sImageFilePath"); + $aOutput = array(); + $CommandLine = "$sDotExecutable -v -Tpng < $sDotFilePath -o$sImageFilePath 2>&1"; + + exec($CommandLine, $aOutput, $iRetCode); + if ($iRetCode != 0) + { + header('Content-type: text/html'); + echo "

Error:

"; + echo "

The command:

$CommandLine
returned $iRetCode

"; + echo "

The output of the command is:

\n".implode("\n", $aOutput)."

"; + echo "
"; + echo "

Content of the '".basename($sDotFilePath)."' file:

\n$sDotDescription
"; + } + else + { + header('Content-type: image/png'); + echo file_get_contents($sImageFilePath); + } + @unlink($sDotFilePath); +} +else +{ + header('Content-type: image/png'); + echo file_get_contents($sImageFilePath); } -header('Content-type: image/png'); -echo file_get_contents($sImageFilePath); ?>