-
Notifications
You must be signed in to change notification settings - Fork 0
/
syntax.php
55 lines (43 loc) · 1.24 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
<?php
/**
* Multilingual farms
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
* @author Jakub Skokan <[email protected]>
*/
if (!defined('DOKU_INC')) die();
class syntax_plugin_mlfarm extends DokuWiki_Syntax_Plugin {
public function getType() {
return 'substition';
}
public function getSort() {
return 32;
}
public function getAllowedTypes() {
return array('disabled');
}
public function connectTo($mode) {
$this->Lexer->addEntryPattern('<page>(?=.*?</page>)', $mode, 'plugin_mlfarm');
}
public function postConnect() {
$this->Lexer->addExitPattern('</page>', 'plugin_mlfarm');
}
public function handle($match, $state, $pos, Doku_Handler $handler){
switch ($state) {
case DOKU_LEXER_UNMATCHED:
return $match;
}
return null;
}
public function render($mode, Doku_Renderer $renderer, $data) {
if ($mode === 'xhtml')
return true;
$name = trim($data);
if ($mode === 'metadata' && $name) {
$renderer->meta['identifier'] = $name;
$renderer->persistent['identifier'] = $name;
return true;
}
return false;
}
}