1<?php 2 3class syntax_plugin_fkstimer extends DokuWiki_Syntax_Plugin { 4 5 public function getType() { 6 return 'substition'; 7 } 8 9 public function getPType() { 10 return 'normal'; 11 } 12 13 public function getAllowedTypes() { 14 return []; 15 } 16 17 public function getSort() { 18 return 225; 19 } 20 21 public function connectTo($mode) { 22 $this->Lexer->addSpecialPattern('{{timer>.+?}}', $mode, 'plugin_fkstimer'); 23 } 24 25 public function handle($match, $state, $pos, Doku_Handler $handler) { 26 27 switch ($state) { 28 case DOKU_LEXER_SPECIAL: 29 $match = substr($match, 8, -2); 30 $dateString = date('Y-m-d\TH:i:s', strtotime($match)); 31 return [$state, ['date' => $dateString]]; 32 default: 33 return [$state, []]; 34 } 35 } 36 37 public function render($mode, Doku_Renderer $renderer, $data) { 38 39 if ($mode == 'xhtml') { 40 list($state, $params) = $data; 41 switch ($state) { 42 case DOKU_LEXER_SPECIAL: 43 $renderer->doc .= '<span class="fks-timer" data-date="' . $params['date'] . '">'; 44 $renderer->doc .= '</span>'; 45 return true; 46 default: 47 return true; 48 } 49 } 50 return false; 51 } 52} 53