forked from Imhodad/dokuwiki-plugin-acronym4glossary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyntax.php
73 lines (59 loc) · 1.94 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
<?php
/**
* DokuWiki Plugin acronym4glossary (Syntax Component)
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
* @author Michael Schuh <mike.schuh@gmx.at>
*/
// must be run within Dokuwiki
if (!defined('DOKU_INC')) die();
if (!defined('DOKU_LF')) define('DOKU_LF', "\n");
if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t");
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once DOKU_PLUGIN.'syntax.php';
class syntax_plugin_acronym4glossary extends DokuWiki_Syntax_Plugin {
var $acrData = array();
function getInfo() {
return array(
'author' => 'Michael Schuh',
'email' => 'mike.schuh@gmx.at',
'date' => '2010-06-16',
'name' => 'acronym4glossary plugin (syntax component)',
'desc' => 'This plugin uses the acronyms to build a glossary',
'url' => 'http://blog.imho.at/20100819/artikel/dokuwiki-plugin-acronym4glossary',
);
}
function getType() {
return 'container';
//return 'FIXME: container|baseonly|formatting|substition|protected|disabled|paragraphs';
}
function getPType() {
return 'normal';
//return 'FIXME: normal|block|stack';
}
function getSort() {
return 190;
}
function connectTo($mode) {
$this->Lexer->addSpecialPattern('<GLOSSARY>',$mode,'plugin_acronym4glossary');
}
function handle($match, $state, $pos, &$handler){
$this->acrData = getAcronyms();
return $data;
}
function render($mode, &$renderer, $data) {
if($mode != 'xhtml') return false;
$renderer->doc .= "<ul>\n";
$actLetter = "a";
foreach($this->acrData as $key => $value) {
if(strtolower($key{0}) != $actLetter) {
$actLetter = strtolower($key{0});
$renderer->doc .= "<br />";
}
$renderer->doc .= "<li>\n".$key." - " . $value."</li>";
}
$renderer->doc .= "</ul>";
return true;
}
}
// vim:ts=4:sw=4:et:enc=utf-8: