Commit fe1ae125 authored by Krzysztof Kutt's avatar Krzysztof Kutt
Browse files

bugfixing; updates for DokuWiki "Hogfather"

No related merge requests found
Showing with 47 additions and 52 deletions
+47 -52
<?php
/**
* Example Action Plugin: Inserts a button into the toolbar
*
* @author Gina Haeussge <osd@foosel.net>
* @author GEIST Research Group <krzysztof.kutt@uj.edu.pl>
*/
......@@ -23,7 +21,7 @@ class action_plugin_sbvr extends DokuWiki_Action_Plugin {
/**
* Register the eventhandlers
*/
public function register(&$controller) {
public function register(Doku_Event_Handler $controller) {
$controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'export', array());
$controller->register_hook('TPL_ACT_UNKNOWN', 'AFTER', $this, 'export', array());
}
......
<?php
/**
*
* Syntax: <TEST> - will be replaced with "Hello World!"
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Christopher Smith <chris@jalakai.co.uk>
* @author GEIST Research Group <krzysztof.kutt@uj.edu.pl>
*/
if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
......@@ -122,7 +119,7 @@ class syntax_plugin_sbvr extends DokuWiki_Syntax_Plugin {
* @see render()
* @static
*/
function handle($match, $state, $pos, &$handler){
function handle($match, $state, $pos, Doku_Handler $handler){
switch ($state) {
case DOKU_LEXER_ENTER :
return null;
......@@ -161,9 +158,9 @@ class syntax_plugin_sbvr extends DokuWiki_Syntax_Plugin {
* @public
* @see handle()
*/
function render($mode, &$renderer, $data) {
function render($mode, Doku_Renderer $renderer, $data) {
global $conf;
global $INFO;
global $INFO;
global $ID;
global $REV;
global $ACT;
......@@ -173,7 +170,7 @@ class syntax_plugin_sbvr extends DokuWiki_Syntax_Plugin {
list($state, $match) = $data;
switch ($state)
{
{
/*
case DOKU_LEXER_MATCHED :
$button_val = 'ok';
......@@ -201,11 +198,11 @@ class syntax_plugin_sbvr extends DokuWiki_Syntax_Plugin {
$renderer->doc .= $form;
$page=noNS($ID);
if($page!=='terms' && $page!=='facts' && $page!=='rules')
break;
if($page!=='terms' && $page!=='facts' && $page!=='rules')
break;
// $cmd = "java -jar tmp/plantuml.jar tmp/classDiagram.txt";
// exec($cmd, $output, $error);
// exec($cmd, $output, $error);
//PRZYGOTOWANIE LISTY TERMÓW
$namespace = getNS(getID());
......@@ -235,13 +232,13 @@ class syntax_plugin_sbvr extends DokuWiki_Syntax_Plugin {
//PRZYCISK EKSPORTU DANYCH DO XML
if($ACT=='show' && noNS(getID())=='rules'){
$renderer->doc .= '<br><br><form class="button" method="get" action="'.exportlink(getID(), 'sbvr', array('type' => 'xmi')).'">
<div align="right">
<input type="submit" value="Export to XML" class="button" />
<input type="hidden" name="do" value="export_sbvr" />
<input type="hidden" name="id" value="'.getID().'" />
<div align="right">
<input type="submit" value="Export to XML" class="button" />
<input type="hidden" name="do" value="export_sbvr" />
<input type="hidden" name="id" value="'.getID().'" />
<input type="hidden" name="type" value="xml" />
</div>
</form>';
</div>
</form>';
}
//PRZYCISK EKSPORTU DANYCH DO XMI
......@@ -259,13 +256,13 @@ class syntax_plugin_sbvr extends DokuWiki_Syntax_Plugin {
//PRZYCISK EKSPORTU DANYCH DO SKŁADNI PL WIKI
if($ACT=='show' && noNS(getID())=='facts'){
$renderer->doc .= '<br><br><form class="button" method="get" action="'.exportlink(getID(), 'sbvr', array('type' => 'pl')).'">
<div align="right">
<input type="submit" value="Export to PlWiki" class="button" />
<input type="hidden" name="do" value="export_sbvr" />
<input type="hidden" name="id" value="'.getID().'" />
<div align="right">
<input type="submit" value="Export to PlWiki" class="button" />
<input type="hidden" name="do" value="export_sbvr" />
<input type="hidden" name="id" value="'.getID().'" />
<input type="hidden" name="type" value="pl" />
</div>
</form>';
</div>
</form>';
}
//GENEROWANIE WIZUALIZACJI
......@@ -273,41 +270,41 @@ class syntax_plugin_sbvr extends DokuWiki_Syntax_Plugin {
foreach($res[1] as $key => $graph) {
$tempfile = $this->tempdir . '/graph_tmp';
$file = fopen($tempfile.'.txt', 'w');
fwrite($file, "@startuml \n".$graph." \n hide empty members \n hide methods \n @enduml");
fclose($file);
fwrite($file, "@startuml \n".$graph." \n hide empty members \n hide methods \n @enduml");
fclose($file);
$md5 = md5_file($tempfile.'.txt');
$mediadir = $conf["mediadir"]."/".str_replace(":", "/",$INFO['namespace'] );
if( !is_dir($mediadir) )
mkdir($mediadir,0755,true);
if( !is_dir($mediadir) )
mkdir($mediadir,0755,true);
$imagefile = $mediadir.'/graph' . '_' . $md5 . '.png';
if ( !file_exists($imagefile) )
{
$cmd = "java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -jar ".$this->tempdir."/plantuml.jar -charset UTF-8 " . $tempfile.'.txt';
exec($cmd, $output, $error);
if ( !file_exists($imagefile) )
{
$cmd = "java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -jar ".$this->tempdir."/plantuml.jar -charset UTF-8 " . $tempfile.'.txt';
exec($cmd, $output, $error);
if ($error != 0)
{
$renderer->doc .= '---ERROR CREATING GRAPH---';
unlink($tempfile);
if (file_exists($tempfile.'.png'))
unlink($tempfile.'.png');
return false;
}
if ($error != 0)
{
$renderer->doc .= '---ERROR CREATING GRAPH---';
unlink($tempfile);
if (file_exists($tempfile.'.png'))
unlink($tempfile.'.png');
return false;
}
if (file_exists($imagefile))
unlink($imagefile);
if ( !copy($tempfile.'.png', $imagefile) )
return false;
unlink($tempfile.'.png');
}
if (file_exists($imagefile))
unlink($imagefile);
if ( !copy($tempfile.'.png', $imagefile) )
return false;
unlink($tempfile.'.png');
}
unlink($tempfile.'.txt');
unlink($tempfile.'.txt');
$renderer->doc .= "<h2>Graph No: ".($key+1)."</h2>";
$renderer->doc .= $renderer->internalmedia($INFO['namespace'].':graph' . '_' . $md5 . '.png');
$renderer->doc .= $renderer->internalmedia($INFO['namespace'].':graph' . '_' . $md5 . '.png');
}
}
break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment