mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
Fixed issue in the lifecycle generation tool (escape double quotes)
SVN:trunk[950]
This commit is contained in:
@@ -32,6 +32,17 @@ require_once('../application/utils.inc.php');
|
||||
require_once('../application/loginwebpage.class.inc.php');
|
||||
LoginWebPage::DoLogin(); // Check user rights and prompt if needed
|
||||
|
||||
/**
|
||||
* Escape a label (string) in a manner suitable for use with graphviz' DOT syntax
|
||||
* @param string $s The string to escape
|
||||
* @return string The escaped string
|
||||
*/
|
||||
function GraphvizEscape($s)
|
||||
{
|
||||
$s = str_replace('"', '\\"', $s);
|
||||
return $s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to generate a Graphviz code for displaying the life cycle of a class
|
||||
* @param string $sClass The class to display
|
||||
@@ -71,7 +82,7 @@ function GraphvizLifecycle($sClass)
|
||||
$aStatesLinks[$aTransitionDef['target_state']]['in']++;
|
||||
$sStimulusLabel = $aStimuli[$sStimulusCode]->GetLabel();
|
||||
$sTargetStateLabel = MetaModel::GetStateLabel($sClass, $aTransitionDef['target_state']);
|
||||
$sDotFileContent .= "\t$sStateCode -> {$aTransitionDef['target_state']} [ label=\"$sStimulusLabel\"];\n";
|
||||
$sDotFileContent .= "\t$sStateCode -> {$aTransitionDef['target_state']} [ label=\"".GraphvizEscape($sStimulusLabel)."\"];\n";
|
||||
}
|
||||
}
|
||||
foreach($aStates as $sStateCode => $aStateDef)
|
||||
@@ -83,11 +94,11 @@ function GraphvizLifecycle($sClass)
|
||||
if ( ($aStatesLinks[$sStateCode]['in'] == 0) || ($aStatesLinks[$sStateCode]['out'] == 0))
|
||||
{
|
||||
// End or Start state, make it look different
|
||||
$sDotFileContent .= "\t$sStateCode [ shape=doublecircle,label=\"$sStateLabel\"];\n";
|
||||
$sDotFileContent .= "\t$sStateCode [ shape=doublecircle,label=\"".GraphvizEscape($sStateLabel)."\"];\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sDotFileContent .= "\t$sStateCode [ shape=circle,label=\"$sStateLabel\"];\n";
|
||||
$sDotFileContent .= "\t$sStateCode [ shape=circle,label=\"".GraphvizEscape($sStateLabel)."\"];\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user