xref: /plugin/bez/syntax/qlink.php (revision 05c9d3bc9b772f5572ae110000a17e18ec941f20)
165cfcae3Sghi<?php
265cfcae3Sghi/**
365cfcae3Sghi * Plugin Now: Inserts a timestamp.
465cfcae3Sghi *
565cfcae3Sghi * @license    GPL 3 (http://www.gnu.org/licenses/gpl.html)
665cfcae3Sghi */
765cfcae3Sghi// must be run within DokuWiki
865cfcae3Sghiif(!defined('DOKU_INC')) die();
965cfcae3Sghi
10b898877eSghiif(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
11b898877eSghirequire_once DOKU_PLUGIN.'syntax.php';
1265cfcae3Sghi/**
1365cfcae3Sghi * All DokuWiki plugins to extend the parser/rendering mechanism
1465cfcae3Sghi * need to inherit from this class
1565cfcae3Sghi */
16b898877eSghiclass syntax_plugin_bez_qlink extends DokuWiki_Syntax_Plugin {
1765cfcae3Sghi
1865cfcae3Sghi    function getType() { return 'substition'; }
1965cfcae3Sghi    function getSort() { return 34; }
2065cfcae3Sghi	function connectTo($mode) {
21b898877eSghi		$this->Lexer->addSpecialPattern('#[0-9]+',$mode,'plugin_bez_qlink');
2265cfcae3Sghi	}
2365cfcae3Sghi
2465cfcae3Sghi
2565cfcae3Sghi    function handle($match, $state, $pos, &$handler) {
264913c0fbSghi		$nr = substr($match, 1, strlen($match));
274913c0fbSghi		return $nr;
2865cfcae3Sghi    }
2965cfcae3Sghi
304913c0fbSghi    function render($mode, &$renderer, $nr) {
3165cfcae3Sghi		if ($mode == 'xhtml') {
32*05c9d3bcSghi			$id = $_GET['id'];
33*05c9d3bcSghi			$ex = explode(':', $id);
3465cfcae3Sghi
35*05c9d3bcSghi			$lang_code = '';
36*05c9d3bcSghi			/*english namespace*/
37*05c9d3bcSghi			switch($ex[0]) {
38*05c9d3bcSghi				case 'en':
39*05c9d3bcSghi					$lang_code = $ex[0].':';
40*05c9d3bcSghi			}
41*05c9d3bcSghi			$renderer->doc .= '<a href="?id='.$lang_code.'bez:issue_show:'.$nr.'">#'.$nr.'</a>';
4265cfcae3Sghi			return true;
4365cfcae3Sghi		}
4465cfcae3Sghi		return false;
4565cfcae3Sghi    }
4665cfcae3Sghi}
47