<?php

require_once DOKU_PLUGIN . 'directions/syntax/localdirections.php';
require_once DOKU_PLUGIN . 'directions/syntax/common.php';
global $conf;
$filename = DOKU_INC . $conf['plugin']['directions']['hitslog'];
$data = dir_parseHitsFile($filename);
// header
print '<table class=driver_dbox_table style="border-bottom: 0px"><tr><td class=driver_dbox_table_title_column>Directions</td></tr></table>';
//incoming
// $info can go unset (Used only by graph generator -> check graph.php).
print dir_generateDirections($info, $data, true, false, false);
//outgoing
// $info can go unset (Used only by graph generator -> check graph.php).
print dir_generateDirections($info, $data, false, true, false);
 /**
  * Handle the actual output creation.
  *
  * <p>
  * The method checks for the given <tt>$aFormat</tt> and returns
  * <tt>FALSE</tt> when a format isn't supported. <tt>$aRenderer</tt>
  * contains a reference to the renderer object which is currently
  * handling the rendering. The contents of <tt>$aData</tt> is the
  * return value of the <tt>handle()</tt> method.
  * </p>
  * @param $aFormat String The output format to generate.
  * @param $aRenderer Object A reference to the renderer object.
  * @param $aData Array The data created by the <tt>handle()</tt>
  * method.
  * @return Boolean <tt>TRUE</tt> if rendered successfully, or
  * <tt>FALSE</tt> otherwise.
  * @public
  * @see handle()
  */
 function render($mode, &$renderer, $data)
 {
     if ($mode == 'xhtml') {
         if (!is_array($data)) {
             $renderer->doc .= "<b>directions plug-in (localdirections component): Returned data in 'render' function is not an array.</b>";
             return false;
         }
         $graph = strcmp($data[0], 'graph') == 0 ? true : false;
         if ($graph) {
             if (!in_array('graphviz', plugin_list())) {
                 $renderer->doc .= '<i>(directions plug-in: To view the graph the graphviz plug-in must be installed)</i>';
             } else {
                 //graph
                 $renderer->doc .= dir_generateDirections($this->getInfo(), $data[1]);
                 return true;
             }
         }
         $renderer->doc .= dir_generateDirections($this->getInfo(), $data[1], false, false, false);
         return true;
     }
     return false;
 }