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

View File

@ -1,5 +1,6 @@
<html> <html>
<head> <head>
<% base_tag %>
<title>Data Model</title> <title>Data Model</title>
</head> </head>

View File

@ -1,9 +1,17 @@
digraph g { 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 Modules %>
<% control Models %> <% control Models %>
$Name [shape=record,label="{$Name|Field1\\nField2}"]; $Name [shape=record,label="{$Name|<% control Fields %>$Name\\n<% end_control %>}"];
<% if ParentModel %>
$Name -> $ParentModel [style=dotted];
<% end_if %>
<% control Relations %> <% control Relations %>
$Model.Name -> $RelatedClass [label="$Name\\n$RelationType"]; $Model.Name -> $RelatedClass [label="$Name\\n$RelationType"];
<% end_control %> <% end_control %>