-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsyntax.php
62 lines (53 loc) · 1.82 KB
/
syntax.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/**
* DokuWiki Plugin sapnotelink (Syntax Component)
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
* @author Florian Lamml <[email protected]>
*/
// must be run within Dokuwiki
if (!defined('DOKU_INC')) die();
class syntax_plugin_sapnotelink extends DokuWiki_Syntax_Plugin {
public function getType() {
return 'substition';
}
public function getPType() {
return 'normal';
}
public function getSort() {
return 256;
}
# responds to everything starts with SAP# or sap# followed by 1 - 10 numbers
public function connectTo($mode) {
$this->Lexer->addSpecialPattern('SAP#[0-9]{1,10}',$mode,'plugin_sapnotelink');
$this->Lexer->addSpecialPattern('sap#[0-9]{1,10}',$mode,'plugin_sapnotelink');
}
public function handle($match, $state, $pos, Doku_Handler $handler){
$data = array($match, $state);
return $data;
}
public function render($mode, Doku_Renderer $renderer, $data) {
# Dokuwiki Renderer
if($mode == 'xhtml'){
$sapnote = explode('#', $data[0]);
$url = $this->getConf('sapnoteurl')."/".$sapnote[1];
$renderer->doc .= "<a href=\"".$url."\" target=\"_blank\"><img src=\"".DOKU_BASE."lib/plugins/sapnotelink/images/sap.gif\" alt=\"".$this->getLang('url_alt')." ".$sapnote[1]."\"> ".$sapnote[1]."</a>";
return true;
}
# ODT Export Renderer
elseif ($mode == 'odt'){
if (!class_exists('ODTDocument')) {
// support of "old" dokuwiki-plugin-odt
$sapnote = explode('#', $data[0]);
$renderer->doc .= "$sapnote[1]";
return true;
} else {
// support of redesign dokuwiki-plugin-odt
$sapnote = explode('#', $data[0]);
$renderer->cdata ("$sapnote[1]");
return true;
}
}
return false;
}
}