1<?php 2/** 3 * QRCode Plugin 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Daniel Pätzold <mailto://obel1x@web.de> 7 */ 8 9// must be run within Dokuwiki 10if (!defined('DOKU_INC')) die(); 11 12/** 13 * All DokuWiki plugins to extend the parser/rendering mechanism 14 * need to inherit from this class 15 */ 16class syntax_plugin_qrcode2 extends DokuWiki_Syntax_Plugin { 17 18 /** 19 * What kind of syntax are we? 20 */ 21 function getType(){ return 'substition'; } 22 23 /** 24 * What about paragraphs? 25 */ 26 function getPType(){ return 'block'; } 27 28 /** 29 * Where to sort in? 30 */ 31 function getSort(){ return 32; } 32 33 /** 34 * Connect pattern to lexer 35 */ 36 function connectTo($mode) { 37// $this->Lexer->addSpecialPattern('\{\{QRCODE>[^}]*\}\}',$mode,'plugin_qrcode2'); 38 $this->Lexer->addSpecialPattern('<QRCODE ".*?">',$mode,'plugin_qrcode2'); 39 } 40 41 42 /** 43 * Handle the match 44 */ 45 function handle($match, $state, $pos, Doku_Handler $handler){ 46// $ret = urlencode(substr($match,9,-2)); //strip {{QRCODE> from start and }} from end 47 $ret = urlencode(substr($match,9,-2)); //strip "<QRCODE " from start and ">" from end 48 return $ret; 49 } 50 51 /** 52 * Create output 53 */ 54 public function render($mode, Doku_Renderer $renderer, $data) { 55 global $conf; 56 57 // $data is what the function handle return'ed. 58 if($mode == 'xhtml'){ 59 /** @var Doku_Renderer_xhtml $renderer */ 60 $addrenderer=""; 61 if(isset($conf['userewrite']) && $conf['userewrite'] == 2) { 62 $addrenderer=".."; 63 } 64 $renderer->doc .= '<img src="'.$addrenderer.'lib/plugins/qrcode2/png.php?id='.$data.'" />'; 65 66 return true; 67 } 68 return false; 69 } 70} 71 72//Setup VIM: ex: et ts=4 enc=utf-8 : 73