*/ // must be run within Dokuwiki if(!defined('DOKU_INC')) die(); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'syntax.php'); /** * All DokuWiki plugins to extend the parser/rendering mechanism * need to inherit from this class */ class syntax_plugin_pdftools extends DokuWiki_Syntax_Plugin { private $dw2pdf_inst = false; function getType(){return 'substition';} function getSort(){return 59;} # Checks if dw2pdf is installed/activated function __construct() { $list = plugin_list(); if(in_array('dw2pdf',$list)) { $this->dw2pdf_inst = true; } } # Returns list of installed dw2pdf-templates function templateList(){ if ($this->dw2pdf_inst) { $path = DOKU_PLUGIN."/dw2pdf/tpl/"; $dirs = array(); // directory handle $dir = dir($path); while (false !== ($entry = $dir->read())) { if ($entry != '.' && $entry != '..') { if (is_dir($path . '/' .$entry)) { $dirs[] = $entry; } } } return $dirs; } return false; } # Add patterns function connectTo($mode) { $this->Lexer->addEntryPattern(')',$mode,'plugin_pdftools'); $this->Lexer->addSpecialPattern('',$mode,'plugin_pdftools'); $this->Lexer->addSpecialPattern('',$mode,'plugin_pdftools'); $this->Lexer->addSpecialPattern('',$mode,'plugin_pdftools'); $this->Lexer->addSpecialPattern('',$mode,'plugin_pdftools'); $this->Lexer->addSpecialPattern('',$mode,'plugin_pdftools'); $this->Lexer->addSpecialPattern('',$mode,'plugin_pdftools'); $this->Lexer->addSpecialPattern('',$mode,'plugin_pdftools'); } function postConnect() { $this->Lexer->addExitPattern('>','plugin_pdftools'); } /* Handle the match */ function handle($match, $state, $pos, Doku_Handler $handler){ return array($state,$match); } /* Create output */ function render($format, Doku_Renderer $renderer, $data) { global $ID; if($format != 'xhtml') return false; $match = $data[0]; list($state, $match) = $data; if ($match=='') {$renderer->doc .= '';return true;} if ($match=='') {$renderer->doc .= '';return true;} if ($match=='') {$renderer->doc .= '';return true;} if ($match=='') {$renderer->doc .= '';return true;} if ($match=='') {$renderer->doc .= '';return true;} if ($match=='') {$renderer->doc .= '';return true;} if ($match=='') { $renderer->doc .= ''; return true; } if (!$this->dw2pdf_inst) { $renderer->doc .= 'Plugin dw2pdf benötigt.
'; } else { if ($state == DOKU_LEXER_UNMATCHED) { $t=$this->templateList(); # The tag "quer" creates landscape orientation if (strpos($match,"quer")>0) { $quer = '&orientation=landscape'; $match = str_replace("quer","",$match); $match = trim($match); } else $quer = ''; if (!in_array($match,$t)) { $msg = "Vorlage '$match' existiert nicht. Bitte einer der folgende Vorlagen verwenden:
"; $msg .= ''.implode(", ",$t).''; $renderer->doc .= "
$msg
"; } else { $renderer->doc .= "'; } } } return true; } # function render } //Setup VIM: ex: et ts=4 enc=utf-8 :