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