1<?php 2/** 3 * render time based text 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Robin Gareus <robin@gareus.org> 7 */ 8 9if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 10if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 11require_once(DOKU_PLUGIN.'syntax.php'); 12require_once(DOKU_INC.'inc/search.php'); 13require_once(DOKU_INC.'inc/JpegMeta.php'); 14 15class syntax_plugin_tbt extends DokuWiki_Syntax_Plugin { 16 /** 17 * return some info 18 */ 19 function getInfo(){ 20 return array( 21 'author' => 'Robin Gareus', 22 'email' => 'robin@gareus.org', 23 'date' => '2008-12-28', 24 'name' => 'tbt', 25 'desc' => 'render time based text.', 26 'url' => 'http://mir.dnsalias.com/wiki/tbt', 27 ); 28 } 29 30 function getType(){ return 'substition'; } 31 function getPType(){ return 'block'; } 32 function getSort(){ return 301; } 33 34 /** 35 * Connect pattern to lexer 36 */ 37 function connectTo($mode) { 38 $this->Lexer->addSpecialPattern('\{\{tbt>[^}]*\}\}',$mode,'plugin_tbt'); 39 } 40 41 42 /** 43 * Handle the match 44 */ 45 function handle($match, $state, $pos, &$handler){ 46 $data = array(); 47 48 if (!strncasecmp($match,"{{tbt>",6) ) { 49 $match = substr($match,6,-2); 50 } 51 $data['tbt'] = $match; 52 return $data; 53 } 54 55 /** 56 * Create output 57 */ 58 function render($mode, &$renderer, $data) { 59 global $myfckinguniqid; 60 if (empty($myfckinguniqid))$myfckinguniqid=1; 61 else $myfckinguniqid++; 62 $uid=$myfckinguniqid; 63 64 if($mode == 'xhtml'){ 65 $renderer->doc .= '<span onclick="tbt_'.$uid.'.startTyping(\'textDestination_'.$uid.'\', TimeBasedText_'.$uid.');" class="toc_close tbtbutton">Restart</span><br/><br/>'."\n"; 66 $renderer->doc .= '<div id="textDestination_'.$uid.'" class="tbtdest"> </div>'; 67 $renderer->doc .= '<script language="JavaScript"><!--'."\n"; 68 $renderer->doc .= 'var TimeBasedText_'.$uid.'='.$data['tbt'].";\n\n"; 69 $renderer->doc .= 'var tbt_'.$uid.' = new TBT();'."\n"; 70 $renderer->doc .= 'tbt_'.$uid.'.setRowCarriageReturn(1);'."\n"; 71 $renderer->doc .= 'tbt_'.$uid.'.setXhtml(1);'."\n"; 72 $renderer->doc .= 'tbt_'.$uid.'.startTyping("textDestination_'.$uid.'", TimeBasedText_'.$uid.');'."\n"; 73 $renderer->doc .= '//--></script>'."\n"; 74 return true; 75 } 76 return false; 77 } 78} 79//Setup VIM: ex: et sw=2 ts=2 enc=utf-8 : 80