-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyntax.php
106 lines (97 loc) · 3.43 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
/**
* Plugin orgapp: OrgApp applet integration - GPL>=3 - See licence COPYING file
*
* @author Enrico Croce & Simona Burzio (staff@eiroca.net)
* @copyright Copyright (C) 2009-2019 eIrOcA - Enrico Croce & Simona Burzio
* @license GPL >=3 (http://www.gnu.org/licenses/)
* @version 19.02
* @link http://www.eiroca.net/doku_orgapp
*/
if (!defined('DOKU_INC')) die();
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/');
if (!defined('DOKU_PLUGIN_ORGAPP')) define('DOKU_PLUGIN_ORGAPP', DOKU_PLUGIN . 'orgapp/');
require_once (DOKU_PLUGIN . 'syntax.php');
class syntax_plugin_orgapp extends DokuWiki_Syntax_Plugin {
function getType() {
return 'disabled';
}
function getSort() {
return 150;
}
function connectTo($mode) {
$this->Lexer->addEntryPattern('<orgapp.*?>(?=.*?</orgapp>)', $mode, 'plugin_orgapp');
}
function postConnect() {
$this->Lexer->addExitPattern('</orgapp>', 'plugin_orgapp');
}
function handle($match, $state, $pos, Doku_Handler $handler) {
$out = [ ];
switch ($state) {
case DOKU_LEXER_ENTER :
$out['width'] = $this->getConf('width');
$out['height'] = $this->getConf('height');
$out['name'] = $this->getConf('name');
$out['code'] = $this->getConf('code');
$out['archive'] = $this->getConf('archive');
$out['target'] = $this->getConf('target');
$out['type'] = $this->getConf('type');
$matches = '';
$found = preg_match_all('#([^\s=]+)\s*=\s*(\'[^<\']*\'|"[^<"]*"|[\d\w]+)#', $match, $matches, PREG_SET_ORDER);
if ($found != 0) {
foreach ($matches as $attribute) {
if ($attribute[2][0] == '"') {
$out[$attribute[1]] = substr($attribute[2], 1, -1);
}
else {
$out[$attribute[1]] = $attribute[2];
}
}
}
return array (
$state, $out
);
case DOKU_LEXER_UNMATCHED :
return array (
$state, $match
);
case DOKU_LEXER_EXIT :
return array (
$state, ''
);
}
}
var $data;
function render($mode, Doku_Renderer $renderer, $data) {
$renderer->info['cache'] = false;
if ($mode == 'xhtml') {
list ($state, $match) = $data;
switch ($state) {
case DOKU_LEXER_ENTER :
$code = $match['code'];
$renderer->doc .= '<applet name="' . $match['name'] . '" code="' . $code . '" archive="' . $match['archive'] . '" width="' . $match['width'] . '" height="' . $match['height'] . '">';
if ($match['target'] != '') {
$renderer->doc .= '<param name="Target" value="' . $match['target'] . '" />';
}
$renderer->doc .= '<param name="DataType" value="' . $match['type'] . '" />';
if ($match['url'] != '') {
$renderer->doc .= '<param name="DataSource" value="' . $match['url'] . '" />';
}
$this->data = '';
break;
case DOKU_LEXER_UNMATCHED :
$this->data .= $match;
break;
case DOKU_LEXER_EXIT :
if ($this->data != '') {
$renderer->doc .= '<param name="Data" value="' . $renderer->_xmlEntities($this->data) . '" />';
}
$renderer->doc .= '</applet>';
break;
}
return true;
}
return false;
}
}
?>