Source for file data.graphviz.php
Documentation is available at data.graphviz.php
* @subpackage plugins_data
// +----------------------------------------------------------------------+
// | Copyright (c) 2004, bitweaver.org
// +----------------------------------------------------------------------+
// | All Rights Reserved. See below for details and a complete list of authors.
// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details
// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
// | -> see http://phpdocu.sourceforge.net/
// +----------------------------------------------------------------------+
// | Author: StarRider starrrider@sourceforge.net
// +----------------------------------------------------------------------+
// $id: data.example.php,v 1.4.2.9 2005/07/14 09:03:36 starrider Exp $
define( 'PLUGIN_GUID_DATAGRAPHVIZ', 'graphviz' );
$pluginParams = array ( 'tag' => 'GRAPHVIZ',
'auto_activate' => FALSE,
'load_function' => 'data_graphviz',
'help_page' => 'DataPluginExample',
'description' => tra("This plugin renders it's content as a graphviz image (dot or neato). It requies the Image_GraphViz pear plugin and graphviz to be installed: pear install Image_GraphViz"),
'help_function' => 'data_graphviz_help',
'syntax' => "{GRAPHVIZ}digraph ... {/GRAPHVIZ}",
'<table class="data help">'
. '<th>' . tra( "Key" ) . '</th>'
. '<th>' . tra( "Type" ) . '</th>'
. '<th>' . tra( "Comments" ) . '</th>'
. '<td>' . tra( "string") . '<br />' . tra("(optional)") . '</td>'
. '<td>' . tra( "Specifies something / probably to be displayed.")
. '<br />' . tra( "The Default = <strong>Sorry About That</strong>")
. '<td>' . tra( "number") . '<br />' . tra("(optional)") . '</td>'
. '<td>' . tra( "Specifies something / probably to be displayed.")
. '<br />' . tra( "The Default =") . ' <strong>3</strong> ' . tra( "Which means - What")
. tra("Example: ") . "{EXAM x1=' ' x2=5 }<br />"
. tra("This will display");
$storageurl = STORAGE_PKG_URL. 'GraphViz/';
$temppath = TEMP_PKG_PATH. 'GraphViz/';
if( !is_dir( $storagepath ) ) {
$dotFile = $temppath . $file . '.dot';
$pngFile = $storagepath . $file . '.png';
$pngURL = $storageurl . $file . '.png';
if( @include_once('PEAR.php') ) {
if(@include_once( 'Image/GraphViz.php' ) ) {
$graph = new Image_GraphViz;
$error = '<div class=error>'. tra("Unable to write temporary file. Please check your server configuration."). '</div>';
if (!$fp = fopen($dotFile, 'w')) {
if (fwrite($fp, $data)=== false) {
$graph->renderDotFile( $dotFile, $pngFile, 'png' );
// No need to keep this lying around
// If it still isn't there....
return '<div class=error>'. tra("Unable to generate graphviz image file. Please check your data."). '</div>';
return "<div class=error>". tra("The Image_Graphviz pear plugin is not installed. Install with `pear install Image_Graphviz`."). "</div>";
return "<div class=error>". tra("PEAR and the Image_Graphviz pear plugin are not installed."). "</div>";
return "<img src=\"$pngURL\"/> ";
|