liberty
[ class tree: liberty ] [ index: liberty ] [ all elements ]

Source for file data.wikigraph.php

Documentation is available at data.wikigraph.php

  1. <?php
  2. /**
  3.  * @version  $Revision: 1.6 $
  4.  * @package  liberty
  5.  * @subpackage plugins_data
  6.  */
  7. /**
  8.  * definitions
  9.  */
  10. global $gBitSystem$gLibertySystem;
  11.  
  12. // only include this plugin if wiki is active and we have GraphViz
  13. if@include_once'Image/GraphViz.php' )) {
  14.  
  15. define'PLUGIN_GUID_DATAWIKIGRAPH''datawikigraph' );
  16. $pluginParams array (
  17.     'tag'           => 'wikigraph',
  18.     'auto_activate' => FALSE,
  19.     'requires_pair' => TRUE,
  20.     'load_function' => 'data_wikigraph',
  21.     'title'         => 'WikiGraph',
  22.     'help_page'     => 'DataPluginWikiGraph',
  23.     'description'   => tra"Inserts a graph for visual navigation. The graph shows the page and every page that can be reached from that page. It requies the Image_GraphViz pear plugin and graphviz to be installed: <strong>pear install Image_GraphViz</strong>" ),
  24.     'help_function' => 'data_wikigraph_help',
  25.     'syntax'        => "{wikigraph level= title= }".tra"Wiki page name" )."{/wikigraph}",
  26.     'plugin_type'   => DATA_PLUGIN
  27. );
  28. $gLibertySystem->registerPluginPLUGIN_GUID_DATAWIKIGRAPH$pluginParams );
  29. $gLibertySystem->registerDataTag$pluginParams['tag']PLUGIN_GUID_DATAWIKIGRAPH );
  30.  
  31. function data_wikigraph_help({
  32.     $help =
  33.         '<table class="data help">'
  34.             .'<tr>'
  35.                 .'<th>'.tra"Key" ).'</th>'
  36.                 .'<th>'.tra"Type" ).'</th>'
  37.                 .'<th>'.tra"Comments" ).'</th>'
  38.             .'</tr>'
  39.             .'<tr class="odd">'
  40.                 .'<td>level</td>'
  41.                 .'<td>'.tra"numeric").'<br />'.tra"(optional)" ).'</td>'
  42.                 .'<td>'.tra"The number of levels that will be followed from the starting page." ).' '.tra"Default").': 0</td>'
  43.             .'</tr>'
  44.             .'<tr class="even">'
  45.                 .'<td>title</td>'
  46.                 .'<td>'.tra"string").'<br />'.tra"(optional)" ).'</td>'
  47.                 .'<td>'.tra"Title of the graph.").' '.tra"Default ").': Wiki-Graph</td>'
  48.             .'</tr>'
  49.             .'<tr class="odd">'
  50.                 .'<td>nodesep</td>'
  51.                 .'<td>'.tra"numeric").'<br />'.tra"(optional)" ).'</td>'
  52.                 .'<td>'.tra"Distance between nodes in inches.").' '.tra"Default").': 1.2</td>'
  53.             .'</tr>'
  54.             .'<tr class="even">'
  55.                 .'<td>rankdir</td>'
  56.                 .'<td>'.tra"string").'<br />'.tra"(optional)" ).'</td>'
  57.                 .'<td>'.tra"Direction of graph layout - can be Left to Right (LR), Right to Left (RL), Top to Bottom (TB), Bottom to Top (BT).").' '.tra"Default").': TB</td>'
  58.             .'</tr>'
  59.             .'<tr class="odd">'
  60.                 .'<td>bgcolor</td>'
  61.                 .'<td>'.tra"html colour").'<br />'.tra"(optional)" ).'</td>'
  62.                 .'<td>'.tra"Background colour of the graph.").' '.tra"Default").': transparent</td>'
  63.             .'</tr>'
  64.             .'</table>'
  65.         .tra"Example: " )."{wikigraph level=1}Welcome{/wikigraph}";
  66.     return $help;
  67. }
  68.  
  69. function data_wikigraph$pData$pParams {
  70.     global $gContent$gBitThemes;
  71.     $ret " ";
  72.  
  73.     // check to see if we have pear available.
  74.     if$error pear_check"Image/GraphViz.php" )) {
  75.         return $error;
  76.     }
  77.  
  78.     if!empty$gContent && is_object$gContent )) {
  79.         $querystring "";
  80.  
  81.         $title !empty$pParams['title'$pParams['title''Wiki-Graph' );
  82.         unset$pParams['title');
  83.  
  84.         foreach$pParams as $param => $value {
  85.             $querystring .= "&amp;{$param}={$value}";
  86.         }
  87.  
  88.         ifempty$pData ) ) {
  89.             $pData (( is_object$gContent || !empty$gContent->mPageName )) $gContent->mPageName NULL );
  90.         }
  91.  
  92.         if!empty$pData ) ) {
  93.             $params array(
  94.                 'graph' => $gBitThemes->getGraphvizGraphAttributes$pParams ),
  95.                 'node'  => $gBitThemes->getGraphvizNodeAttributes$pParams ),
  96.                 'edge'  => $gBitThemes->getGraphvizEdgeAttributes$pParams ),
  97.             );
  98.  
  99.             $mapname md5microtime() );
  100.             $mapdata $gContent->linkStructureMap$pDataisset$pParams['level'$pParams['level')$params );
  101.  
  102.             $ret "
  103.                 <div style='text-align:center'>
  104.                 <img src=\"".WIKI_PKG_URL."wiki_graph.php?page=".urlencode$pData )."{$querystring}\" alt='{$title}' usemap='#$mapname' />
  105.                 <map name='$mapname'>$mapdata</map>
  106.                 </div>";
  107.             $ret preg_replace"/\n|\r/"''$ret );
  108.         }
  109.     }
  110.     return $ret;
  111. }
  112.  
  113. // graphviz check
  114. ?>

Documentation generated on Wed, 29 Jul 2015 13:56:22 +0000 by phpDocumentor 1.5.0-lsces