* @version 2.0
*
*/
if(!defined('DW_LF')) define('DW_LF',"\n");
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');
class syntax_plugin_clock extends DokuWiki_Syntax_Plugin {
function getType(){
return 'substition';
}
function getAllowedTypes() {
return array();
}
function getSort(){
return 290;
}
function getPType(){
return 'block';
}
function connectTo($mode) {
$this->Lexer->addSpecialPattern (
'^\{\{clock\}\}$', $mode, 'plugin_clock');
}
function handle($match, $state, $pos, Doku_Handler $handler){
$data= array();
$theJS= $this->getConf('nojs_fallback');
// if 'nojs_fallback' is set, we get the time from the server
// if 'clock_infopage' contains a link, we convert it
/* compose the data array */
$data['type'] = $this->getConf('clock_type');
$data['style'] = $this->getConf('clock_style');
$data['text'] = $theJS ? date('H:i:s') : 'clock';
/* Are we ready yet? */
return $data;
}
function render($mode, Doku_Renderer $renderer, $data) {
static $wasrendered= false;
if ($wasrendered===true) {return true; }
if ($mode == 'xhtml') {
$nl = DW_LF;
$cty = $this->getConf('clock_type');
$cid = $this->getConf('clock_id');
$html = $this->_clock_createblock_html($data, $cty);
$hbar = ($this->getConf('helpbar')) ? $this->_get_clock_helpbar() : '';
$renderer->doc .= << ,