forked from xdreamer/searchtablejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyntax.php
79 lines (74 loc) · 2.4 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
<?php
/**
* SearchTablejs: Javascript for Searchable table
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Robert Henjes
* version 0.1 Initial version copied from sortablejs plugin
*/
// must be run within Dokuwiki
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_searchtablejs extends DokuWiki_Syntax_Plugin {
function getInfo(){
return array(
'author' => 'Robert Henjes',
'email' => 'dokuwiki@rhenjes.de',
'date' => '2010-10-22',
'name' => 'Searchable javascript',
'desc' => 'Add <searchtable> and </searchtable> around your table.',
'url' => 'http://www3.informatik.uni-wuerzburg.de/',
);
}
function getType() { return 'container';}
function getPType(){ return 'normal';}
function getSort() { return 999; }
function connectTo($mode) {
$this->Lexer->addEntryPattern('<searchtable[^>]*>(?=.*?\x3C/searchtable\x3E)',$mode,'plugin_searchtablejs');
}
function postConnect() {
$this->Lexer->addExitPattern('</searchtable>','plugin_searchtablejs');
}
function handle($match, $state, $pos, &$handler){
switch ($state) {
case DOKU_LEXER_ENTER :
$match = substr($match,12,-1);
$match=trim($match);
$scl="";
if (strlen($match)>0) {
$scl=" search$match";
}
return array($state, $scl);
break;
case DOKU_LEXER_UNMATCHED :
return array($state, $match);
break;
case DOKU_LEXER_EXIT :
return array($state, "");
break;
}
return array();
}
function render($mode, &$renderer, $data) {
list($state,$match) = $data;
if ($mode == 'xhtml'){
switch ($state) {
case DOKU_LEXER_ENTER :
$id = mt_rand();
$renderer->doc .= '<div class="searchtable'.$match.'" id="'.$id.'">';
$renderer->doc .= '<form class="searchtable" onsubmit="return false;"><input class="searchtable" name="filtertable" onkeyup="searchtable.filterall(this, \''.$id.'\')" type="text"></form>';
break;
case DOKU_LEXER_UNMATCHED :
$renderer->doc .= p_render('xhtml',p_get_instructions($match),$info);
break;
case DOKU_LEXER_EXIT :
$renderer->doc .= '</div>';
break;
}
return true;
}
return false;
}
}
?>