*/ class syntax_plugin_dwtimeline_milestone extends syntax_plugin_dwtimeline_dwtimeline { /** @inheritDoc */ public function getType() { return 'plugin_dwtimeline_milestone'; } public function accepts($mode) { if ($mode == 'plugin_dwtimeline_timeline') { return true; } return parent::accepts($mode); } /** * @return array Things that may be inside the syntax */ public function getAllowedTypes() { return ['container', 'formatting', 'substition', 'protected', 'disabled', 'paragraphs']; } /** * Set the EntryPattern * @param string $mode */ public function connectTo($mode) { $pattern = '"\']+|"(?:[^"\\\\]|\\\\.)*"|\'(?:[^\'\\\\]|\\\\.)*\')*>(?=.*?\)'; $this->Lexer->addEntryPattern($pattern, $mode, 'plugin_dwtimeline_milestone'); } /** * Set the ExitPattern */ public function postConnect() { $this->Lexer->addExitPattern('', 'plugin_dwtimeline_milestone'); } /** * Handle the match * @param string $match The match of the syntax * @param int $state The state of the handler * @param int $pos The position in the document * @param Doku_Handler $handler The handler * @return array Data for the renderer */ public function handle($match, $state, $pos, Doku_Handler $handler) { switch ($state) { case DOKU_LEXER_ENTER: $match = trim(substr($match, 10, -1));// returns match between (-1) $data = $this->getTitleMatches($match); $data['align'] = parent::$align; return [$state, $data]; case DOKU_LEXER_UNMATCHED: return [$state, $match]; case DOKU_LEXER_EXIT: return [$state, '']; } return []; } /** * Create output * * @param string $mode string output format being rendered * @param Doku_Renderer $renderer the current renderer object * @param array $data data created by handler() * @return bool rendered correctly? */ public function render($mode, Doku_Renderer $renderer, $data) { if ($mode == 'xhtml') { if (!parent::$direction) { parent::$direction = $this->getDirection(); } [$state, $indata] = $data; switch ($state) { case DOKU_LEXER_ENTER: $renderer->doc .= '
' . DOKU_LF; $renderer->doc .= '
' . DOKU_LF; if (isset($indata['title'])) { if (!empty($indata['link'])) { // get back raw title-value $label = htmlspecialchars_decode($indata['title'], ENT_QUOTES); // create link with label $wikilink = '[[' . $indata['link'] . '|' . $label . ']]'; // render link $info = []; $renderer->doc .= '
' . p_render('xhtml', p_get_instructions($wikilink), $info) . '
' . DOKU_LF; } else { $renderer->doc .= '
' . $indata['title'] . '
' . DOKU_LF; } } if (isset($indata['description'])) { $renderer->doc .= '
' . $indata['description'] . '
' . DOKU_LF; } break; case DOKU_LEXER_UNMATCHED: $renderer->cdata($indata); break; case DOKU_LEXER_EXIT: $renderer->doc .= '
' . DOKU_LF; $renderer->doc .= '
' . DOKU_LF; parent::$direction = $this->changeDirection(parent::$direction); break; } return true; } return false; } }