xref: /plugin/bez/syntax/qlink.php (revision 65cfcae34db95a109f32abb2cc9d026d9a132f88)
1<?php
2/**
3 * Plugin Now: Inserts a timestamp.
4 *
5 * @license    GPL 3 (http://www.gnu.org/licenses/gpl.html)
6 * @author     Szymon Olewniczak <szymon.olewniczak@rid.pl>
7 */
8// must be run within DokuWiki
9if(!defined('DOKU_INC')) die();
10
11/**
12 * All DokuWiki plugins to extend the parser/rendering mechanism
13 * need to inherit from this class
14 */
15class syntax_plugin_bds_qlink extends DokuWiki_Syntax_Plugin {
16
17    function getType() { return 'substition'; }
18    function getSort() { return 34; }
19
20	function connectTo($mode) {
21		$this->Lexer->addSpecialPattern('#[0-9]+:?[0-9]*',$mode,'plugin_bds_qlink');
22	}
23
24
25    function handle($match, $state, $pos, &$handler) {
26		$whash = substr($match, 1, strlen($match));
27		$ex = explode(':', $whash);
28		return array($ex[0], isset($ex[1]) ? $ex[1] : 0);
29    }
30
31    function render($mode, &$renderer, $data) {
32		if ($mode == 'xhtml') {
33			list($issue, $event) = $data;
34
35			$bds = $this->loadHelper('bds');
36			$renderer->doc .= $bds->html_anchor_to_event($issue, $event, true);
37
38			return true;
39		}
40		return false;
41    }
42}
43