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
|
<?php
/**
* Simple Tree Navigation Plugin
* @author Yves Fischer <yvesf-git@xapek.org>
*/
if(!defined('DOKU_INC')) die();
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once DOKU_PLUGIN.'syntax.php';
class syntax_plugin_treenav extends DokuWiki_Syntax_Plugin {
var $_keys = array('icon', 'title');
function getType() { return 'baseonly'; }
function getSort() { return 32; }
function connectTo($mode) {
foreach ($this->_keys as $key) {
$this->Lexer->addSpecialPattern('~~'.$key.':.*?~~',$mode,'plugin_treenav');
}
}
function handle($match, $state, $pos, &$handler) {
switch ($state) {
case DOKU_LEXER_SPECIAL:
$match = substr($match, 2, -2);
@list($key, $value) = explode(':', $match, 2);
if (in_array($key, $this->_keys)) {
return array($key, $value);
}
}
}
function render($mode, &$renderer, $data) {
if ($mode === 'metadata') {
$renderer->meta['treenav'][$data[0]] = $data[1];
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* Local Variables: */
/* tab-width: 4 */
/* indent-tabs-mode: nil */
/* c-basic-offset: 4 */
/* End: */
|