aboutsummaryrefslogtreecommitdiff
path: root/mod/dokuwiki/vendors/dokuwiki/lib/plugins/tbt/syntax.php
blob: 28c4363e82bbed07c3b1cdfa9c5f8c098e9b7bf7 (plain)
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
/**
 * render time based text
 * 
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Robin Gareus <robin@gareus.org>
 */

if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once(DOKU_PLUGIN.'syntax.php');
require_once(DOKU_INC.'inc/search.php');
require_once(DOKU_INC.'inc/JpegMeta.php');

class syntax_plugin_tbt extends DokuWiki_Syntax_Plugin {
    /**
     * return some info
     */
    function getInfo(){
        return array(
            'author' => 'Robin Gareus',
            'email'  => 'robin@gareus.org',
            'date'   => '2008-12-28',
            'name'   => 'tbt',
            'desc'   => 'render time based text.',
            'url'    => 'http://mir.dnsalias.com/wiki/tbt',
        );
    }

    function getType(){ return 'substition'; }
    function getPType(){ return 'block'; }
    function getSort(){ return 301; }

    /**
     * Connect pattern to lexer
     */
    function connectTo($mode) {
        $this->Lexer->addSpecialPattern('\{\{tbt>[^}]*\}\}',$mode,'plugin_tbt');
    }


    /**
     * Handle the match
     */
    function handle($match, $state, $pos, &$handler){
        $data = array();

        if (!strncasecmp($match,"{{tbt>",6) ) {
                $match = substr($match,6,-2); 
        }
        $data['tbt'] = $match;
        return $data;
    }

    /**
     * Create output
     */
    function render($mode, &$renderer, $data) {
        global $myfckinguniqid;
        if (empty($myfckinguniqid))$myfckinguniqid=1;
        else $myfckinguniqid++;
        $uid=$myfckinguniqid;

        if($mode == 'xhtml'){
              $renderer->doc .= '<span onclick="tbt_'.$uid.'.startTyping(\'textDestination_'.$uid.'\', TimeBasedText_'.$uid.');" class="toc_close tbtbutton">Restart</span><br/><br/>'."\n";
              $renderer->doc .= '<div id="textDestination_'.$uid.'" class="tbtdest"> </div>';
              $renderer->doc .= '<script language="JavaScript"><!--'."\n";
              $renderer->doc .= 'var TimeBasedText_'.$uid.'='.$data['tbt'].";\n\n";
              $renderer->doc .= 'var tbt_'.$uid.' = new TBT();'."\n";
              $renderer->doc .= 'tbt_'.$uid.'.setRowCarriageReturn(1);'."\n";
              $renderer->doc .= 'tbt_'.$uid.'.setXhtml(1);'."\n";
              $renderer->doc .= 'tbt_'.$uid.'.startTyping("textDestination_'.$uid.'", TimeBasedText_'.$uid.');'."\n";
              $renderer->doc .= '//--></script>'."\n";
              return true;
	      }
        return false;
    }
}
//Setup VIM: ex: et sw=2 ts=2 enc=utf-8 :