185220f43Ssaggi-dw<?php 285220f43Ssaggi-dw/** 385220f43Ssaggi-dw * DokuWiki Plugin dwtimeline (Syntax Component) 485220f43Ssaggi-dw * 585220f43Ssaggi-dw * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 685220f43Ssaggi-dw * @author saggi <saggi@gmx.de> 785220f43Ssaggi-dw */ 84ff971beSsaggi-dw 94ff971beSsaggi-dw// must be run within Dokuwiki 104ff971beSsaggi-dwif(!defined('DOKU_INC')) die(); 114ff971beSsaggi-dw 1285220f43Ssaggi-dwclass syntax_plugin_dwtimeline_milestone extends \dokuwiki\Extension\SyntaxPlugin 1385220f43Ssaggi-dw{ 1485220f43Ssaggi-dw /** @inheritDoc */ 1585220f43Ssaggi-dw public function getType() 1685220f43Ssaggi-dw { 1785220f43Ssaggi-dw return 'substition'; 1885220f43Ssaggi-dw } 1985220f43Ssaggi-dw 2085220f43Ssaggi-dw /** @inheritDoc */ 2185220f43Ssaggi-dw public function getPType() 2285220f43Ssaggi-dw { 2385220f43Ssaggi-dw return 'stack'; 2485220f43Ssaggi-dw } 2585220f43Ssaggi-dw 2685220f43Ssaggi-dw /** @inheritDoc */ 2785220f43Ssaggi-dw public function getSort() 2885220f43Ssaggi-dw { 294ff971beSsaggi-dw return 320; 3085220f43Ssaggi-dw } 3185220f43Ssaggi-dw 3285220f43Ssaggi-dw /** 3385220f43Ssaggi-dw * @return array Things that may be inside the syntax 3485220f43Ssaggi-dw */ 3585220f43Ssaggi-dw function getAllowedTypes() { 3685220f43Ssaggi-dw return array('container', 'formatting', 'substition', 'protected', 'disabled', 'paragraphs'); 3785220f43Ssaggi-dw } 3885220f43Ssaggi-dw 3985220f43Ssaggi-dw /** 4085220f43Ssaggi-dw * Set the EntryPattern 4185220f43Ssaggi-dw * @param type $mode 4285220f43Ssaggi-dw */ 4385220f43Ssaggi-dw public function connectTo($mode) 4485220f43Ssaggi-dw { 45*08c5c745SSteffen Sagert if ($mode == "plugin_dwtimeline_timeline") { 464ff971beSsaggi-dw $this->Lexer->addEntryPattern('<milestone\b.*?>',$mode,'plugin_dwtimeline_milestone'); 4785220f43Ssaggi-dw } 48*08c5c745SSteffen Sagert } 4985220f43Ssaggi-dw 5085220f43Ssaggi-dw /** 5185220f43Ssaggi-dw * Set the ExitPattern 5285220f43Ssaggi-dw */ 5385220f43Ssaggi-dw public function postConnect() 5485220f43Ssaggi-dw { 5585220f43Ssaggi-dw $this->Lexer->addExitPattern('</milestone>', 'plugin_dwtimeline_milestone'); 5685220f43Ssaggi-dw } 5785220f43Ssaggi-dw 5885220f43Ssaggi-dw /** 5985220f43Ssaggi-dw * Handle the match 6085220f43Ssaggi-dw * @param type $match 6185220f43Ssaggi-dw * @param type $state 6285220f43Ssaggi-dw * @param type $pos 6385220f43Ssaggi-dw * @param Doku_Handler $handler 6485220f43Ssaggi-dw * @return type 6585220f43Ssaggi-dw */ 6685220f43Ssaggi-dw public function handle($match, $state, $pos, Doku_Handler $handler) 6785220f43Ssaggi-dw { 6885220f43Ssaggi-dw $data = []; 6985220f43Ssaggi-dw switch ($state) { 7085220f43Ssaggi-dw case DOKU_LEXER_ENTER : 7185220f43Ssaggi-dw $match = trim(substr($match, 10,-1));// returns match between <milestone(10) and >(-1) 7285220f43Ssaggi-dw $data = helper_plugin_dwtimeline::getTitleMatches($match, 'title'); 734ff971beSsaggi-dw global $align; 744ff971beSsaggi-dw $data['align'] = $align; 7585220f43Ssaggi-dw return array($state,$data); 7685220f43Ssaggi-dw case DOKU_LEXER_UNMATCHED : 7785220f43Ssaggi-dw return array($state,$match); 7885220f43Ssaggi-dw case DOKU_LEXER_EXIT : 7985220f43Ssaggi-dw return array($state,''); 8085220f43Ssaggi-dw } 8185220f43Ssaggi-dw return array(); 8285220f43Ssaggi-dw } 8385220f43Ssaggi-dw 8485220f43Ssaggi-dw /** 8585220f43Ssaggi-dw * Render Function 8685220f43Ssaggi-dw * @param type $mode 8785220f43Ssaggi-dw * @param Doku_Renderer $renderer 8885220f43Ssaggi-dw * @param type $data 8985220f43Ssaggi-dw * @return boolean 9085220f43Ssaggi-dw */ 9185220f43Ssaggi-dw public function render($mode, Doku_Renderer $renderer, $data) 9285220f43Ssaggi-dw { 9385220f43Ssaggi-dw if ($mode == 'xhtml') { 9485220f43Ssaggi-dw global $direction; 95*08c5c745SSteffen Sagert if (!$direction) {$direction='tl-'.$this->getConf('direction');} 9685220f43Ssaggi-dw list($state,$indata) = $data; 9785220f43Ssaggi-dw switch ($state) { 9885220f43Ssaggi-dw case DOKU_LEXER_ENTER : 994ff971beSsaggi-dw $renderer->doc .= '<div class="container-'.$indata['align'].' '.$direction.'"'.$indata['data'].$indata['backcolor'].'>'. DOKU_LF; 100*08c5c745SSteffen Sagert $renderer->doc .= '<div class="tlcontent">'. DOKU_LF; 1014ff971beSsaggi-dw if (isset($indata['title'])) { 1024ff971beSsaggi-dw if (isset($indata['link'])) { 1034ff971beSsaggi-dw $renderer->doc .= '<div class="mstitle">'.$this->render_text('[['.$indata['link'].'|'.$indata['title'].']]').'</div>'. DOKU_LF; 10485220f43Ssaggi-dw } else { 1054ff971beSsaggi-dw $renderer->doc .= '<div class="mstitle">'.$indata['title'].'</div>'. DOKU_LF; 10685220f43Ssaggi-dw } 10785220f43Ssaggi-dw } 1084ff971beSsaggi-dw if (isset($indata['description'])) {$renderer->doc .= '<div class="msdesc">'.$indata['description'].'</div>'. DOKU_LF;} 10985220f43Ssaggi-dw break; 11085220f43Ssaggi-dw case DOKU_LEXER_UNMATCHED : 1114ff971beSsaggi-dw $renderer->doc .= $renderer->cdata($indata); 11285220f43Ssaggi-dw break; 11385220f43Ssaggi-dw case DOKU_LEXER_EXIT : 11485220f43Ssaggi-dw $renderer->doc .= '</div>'. DOKU_LF; 11585220f43Ssaggi-dw $renderer->doc .= '</div>'. DOKU_LF; 11685220f43Ssaggi-dw $direction = helper_plugin_dwtimeline::getDirection($direction); 11785220f43Ssaggi-dw break; 11885220f43Ssaggi-dw } 11985220f43Ssaggi-dw return true; 12085220f43Ssaggi-dw } 12185220f43Ssaggi-dw return false; 12285220f43Ssaggi-dw } 12385220f43Ssaggi-dw 12485220f43Ssaggi-dw} 12585220f43Ssaggi-dw 126