1<?php 2 3use dokuwiki\Extension\SyntaxPlugin; 4 5/** 6 * DokuWiki Plugin dokuflashcard (Syntax Component) 7 * 8 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 9 * @author dodotori@dokuwikiforum <dodotori@dokuwikiforum> 10 */ 11class syntax_plugin_dokuflashcard extends SyntaxPlugin 12{ 13 14 15 16 17 18 19 20 21 22 /** @inheritDoc */ 23 public function getType() 24 { 25 return 'protected'; 26 } 27 28 /** @inheritDoc */ 29 public function getPType() 30 { 31 return 'block'; 32 } 33 34 /** @inheritDoc */ 35 public function getSort() 36 { 37 return 32; 38 } 39 40 /** @inheritDoc */ 41 public function connectTo($mode) 42 { 43 // $this->Lexer->addSpecialPattern('<FIXME>', $mode, 'plugin_dokuflashcard'); 44 $this->Lexer->addEntryPattern('<flashcard>', $mode, 'plugin_dokuflashcard'); 45 } 46 47// /** @inheritDoc */ 48 public function postConnect() 49 { 50 $this->Lexer->addExitPattern('</flashcard>', 'plugin_dokuflashcard'); 51 } 52 53 /** @inheritDoc */ 54 public function handle($match, $state, $pos, Doku_Handler $handler) 55 { 56 57 58 switch ($state) { 59 case DOKU_LEXER_ENTER : 60 return array($state, ''); 61 62 case DOKU_LEXER_UNMATCHED : 63 return array($state, $match); 64 65 66 case DOKU_LEXER_EXIT : 67 return array($state, ''); 68 } 69 70 71 72 return array(); 73 74 75 76 77 } 78 79 /** @inheritDoc */ 80 public function render($mode, Doku_Renderer $renderer, $data) 81 { 82 if ($mode !== 'xhtml') { 83 return false; 84 } 85 86 87 list($state,$match) = $data; 88 switch ($state) { 89 case DOKU_LEXER_ENTER : 90 $renderer->doc .= '<div id="cardpanel" class="unflipped" onclick="flipcard()">Start!</div>'; 91 $renderer->doc .= ' 92 <div class="fbuttoncontainer"> 93 <button class="flashcardbutton" onclick="startcard()">start</button> 94 <button class="flashcardbutton" onclick="oldcard()">back</button> 95 <button class="flashcardbutton" onclick="newcard()">next</button> 96 </div>'; 97 $renderer->doc .= '<div id = "carddata">'; 98 break; 99 100 case DOKU_LEXER_UNMATCHED : 101 102 $renderer->doc .= $renderer->_xmlEntities($match); 103 104 break; 105 case DOKU_LEXER_EXIT : 106 $renderer->doc .= '</div>'; 107 break; 108 109 110 111 112 return true; 113 } 114 } 115} 116