/** * generateDirections * This function produces the directions (incoming/outgoing pages) for a particular wiki page. * */ function dir_generateDirections($info, $data, $fanInOnly = false, $fanOutOnly = false, $showGraph = true) { // get current page id (name with namespace) $id = getID(); // parse data to find fan in and fan out // $data comes has associative array with step string (page1->page2) on "key" and occurences of step in "value". // find relevant steps first, order by ocurrences second. $graph = array(); foreach ($data as $key => $value) { $pages = explode("->", $key); $page1 = str_replace('/', ':', $pages[0]); $page1 = trim($page1); $page2 = str_replace('/', ':', $pages[1]); $page2 = trim($page2); if (strcmp($id, $page1) == 0) { $index = $page1 . '->' . $page2; $graph[$index] = $value; $fanOut[$page2] = $value; } if (strcmp($id, $page2) == 0) { $index = $page1 . '->' . $page2; $graph[$index] = $value; $fanIn[$page1] = $value; } //sort if (isset($fanOut)) { arsort($fanOut); } if (isset($fanIn)) { arsort($fanIn); } } // return (printable) results $results .= dir_prettyPrintResults($fanIn, $fanInOnly, $fanOut, $fanOutOnly); if ($showGraph) { if (!in_array('graphviz', plugin_list())) { $results .= '<span class="notify">To view the graph the graphviz plug-in must be installed.</span>'; } else { //graph $results .= dir_generateGraph($info, $graph); } } return $results; }
/** * 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 (globaldirections component): Returned data in 'render' function is not an array</b>"; return false; } // check if graphviz plugin exists. $graph = strcmp($data[0], 'graph') == 0 ? true : false; if ($graph) { if (!in_array('graphviz', plugin_list())) { $renderer->doc .= '<p><i>(directions plug-in: To view the graph the graphviz plug-in must be installed.)</i></p>'; } else { //graph $renderer->doc .= dir_generateGraph($this->getInfo(), $data[1]); } } // table of jumps $renderer->doc .= dir_generateListofJumps($data[1]); return true; } return false; }