1<?php 2/** 3 * Plugin Now: Inserts a timestamp. 4 * 5 * @license GPL 3 (http://www.gnu.org/licenses/gpl.html) 6 */ 7// must be run within DokuWiki 8if(!defined('DOKU_INC')) die(); 9 10if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 11require_once DOKU_PLUGIN.'syntax.php'; 12/** 13 * All DokuWiki plugins to extend the parser/rendering mechanism 14 * need to inherit from this class 15 */ 16class syntax_plugin_bez_qlink extends DokuWiki_Syntax_Plugin { 17 18 function getType() { return 'substition'; } 19 function getSort() { return 34; } 20 function connectTo($mode) { 21 $this->Lexer->addSpecialPattern('#[z]?[0-9]+',$mode,'plugin_bez_qlink'); 22 } 23 24 25 function handle($match, $state, $pos, Doku_Handler $handler) { 26 $code = substr($match, 1, 1); 27 if ($code === 'z') { 28 $nr = substr($match, 2, strlen($match)); 29 return array('z', $nr); 30 } else { 31 $nr = substr($match, 1, strlen($match)); 32 return array('', $nr); 33 } 34 } 35 36 function render($mode, Doku_Renderer $renderer, $link) { 37 if ($mode == 'xhtml') { 38 $id = $_GET['id']; 39 $ex = explode(':', $id); 40 41 $lang_code = ''; 42 /*english namespace*/ 43 switch($ex[0]) { 44 case 'en': 45 $lang_code = $ex[0].':'; 46 } 47 $nr = $link[1]; 48 if ($link[0] === 'z') { 49 $renderer->doc .= '<a href="?id='.$lang_code.'bez:task:tid:'.$nr.'">#z'.$nr.'</a>'; 50 } else { 51 $renderer->doc .= '<a href="?id='.$lang_code.'bez:issue:id:'.$nr.'">#'.$nr.'</a>'; 52 } 53 return true; 54 } 55 return false; 56 } 57} 58