Improved graphs displayed on dev/viewmodel

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@67432 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2008-12-04 04:12:37 +00:00
parent 850989e158
commit 9bf209b0ab
3 changed files with 20 additions and 9 deletions

View File

@ -56,7 +56,7 @@ class ModelViewer extends Controller {
$output = new DataObjectSet();
foreach($modules as $moduleName => $models) {
$output->push(new ArrayData(array(
'Link' => 'dev/viewcode/' . $moduleName,
'Link' => 'dev/viewmodel/' . $moduleName,
'Name' => $moduleName,
'Models' => $models,
)));
@ -83,8 +83,10 @@ class ModelViewer_Module extends ModelViewer {
$dotContent = $this->renderWith("ModelViewer_dotsrc");
$CLI_dotContent = escapeshellarg($dotContent);
header("Content-type: image/png");
echo `neato -Tpng:gd &> /dev/stdout`;
$output= `echo $CLI_dotContent | neato -Tpng:gd &> /dev/stdout`;
if(substr($output,1,3) == 'PNG') header("Content-type: image/png");
else header("Content-type: text/plain");
echo $output;
}
}
@ -170,4 +172,4 @@ class ModelViewer_Relation extends ViewableData {
}
?>
?>

View File

@ -1,5 +1,6 @@
<html>
<head>
<% base_tag %>
<title>Data Model</title>
</head>
@ -30,4 +31,4 @@
<% end_control %>
</body>
</html>

View File

@ -1,12 +1,20 @@
digraph g {
edge[len=3];
orientation=portrait;
overlap=false;
splines=true;
edge[fontsize=8,len=1.5];
node[fontsize=10,shape=box];
<% control Modules %>
<% control Models %>
$Name [shape=record,label="{$Name|Field1\\nField2}"];
<% control Relations %>
$Name [shape=record,label="{$Name|<% control Fields %>$Name\\n<% end_control %>}"];
<% if ParentModel %>
$Name -> $ParentModel [style=dotted];
<% end_if %>
<% control Relations %>
$Model.Name -> $RelatedClass [label="$Name\\n$RelationType"];
<% end_control %>
<% end_control %>
<% end_control %>
}
}