1<?php 2/** 3 * Plugin Geogebra: Sets new colors for text and background. 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Christopher Smith <chris@jalakai.co.uk> 7 */ 8 9// must be run within DokuWiki 10if(!defined('DOKU_INC')) die(); 11 12if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 13require_once(DOKU_PLUGIN.'syntax.php'); 14 15/** 16 * All DokuWiki plugins to extend the parser/rendering mechanism 17 * need to inherit from this class 18 */ 19class syntax_plugin_ggb extends DokuWiki_Syntax_Plugin { 20 21 function getType(){ return 'formatting'; } 22 function getAllowedTypes() { return array('formatting', 'substition', 'disabled'); } 23 function getSort(){ return 158; } 24 function connectTo($mode) { $this->Lexer->addEntryPattern('<ggb.*?>(?=.*?</ggb>)',$mode,'plugin_ggb'); } 25 function postConnect() { $this->Lexer->addExitPattern('</ggb>','plugin_ggb'); } 26 27 28 /** 29 * Handle the match 30 */ 31 function handle($match, $state, $pos, Doku_Handler $handler){ 32 switch ($state) { 33 case DOKU_LEXER_ENTER : 34 list($strheight) = preg_split("/\//u", substr($match, 4, -1), 1); 35 $height = intval($strheight); 36 if (($height<100)||($height>480)) $height=480; 37 return array($state, $height); 38 39 case DOKU_LEXER_UNMATCHED : 40 return array($state, $match); 41 case DOKU_LEXER_EXIT : 42 return array($state, ''); 43 } 44 return array(); 45 } 46 47 /** 48 * Create output 49 */ 50 function render($mode, Doku_Renderer $renderer, $data) { 51 if($mode == 'xhtml'){ 52 list($state, $match) = $data; 53 switch ($state) { 54 case DOKU_LEXER_ENTER : 55 //list($color, $background) = $match; 56 $renderer->doc .= " <script type=\"text/javascript\" src=\"https://www.geogebra.org/web/5.0/web/web.nocache.js\"></script> 57 <h1>Sinus und Kosinus am Einheitskreis<h1> 58 <article class=\"geogebraweb\" 59 id=\"applet1\" 60 data-param-id=\"applet1\" 61 data-param-showMenubar=\"false\" 62 data-param-showToolbar=\"false\" 63 data-param-showAlgebraInput=\"false\" 64 data-param-showResetIcon=\"true\" 65 data-param-width=\"640\" 66 data-param-height=\"$match\" 67 data-param-language=\"de\" 68 data-param-ggbbase64=\""; 69 break; 70 71 case DOKU_LEXER_UNMATCHED : 72 //$datei = "/var/www/html/dokuwiki2/data/media/".$match; 73 $datei = "./data/media/".$match; 74 $inhalt = file_get_contents($datei); 75 //$renderer->doc .= $renderer->_xmlEntities($match); 76 $renderer->doc .= wordwrap(base64_encode($inhalt), 40)."\"></article>\n"; 77 break; 78 case DOKU_LEXER_EXIT : $renderer->doc .= ""; 79 break; 80 } 81 return true; 82 } 83 return false; 84 } 85} 86?> 87