1<?php 2if (!defined('DOKU_INC'))define('DOKU_INC', realpath(dirname( __FILE__ ).'/../../../').'/'); 3if (!defined('DOKU_PLUGIN'))define('DOKU_PLUGIN', DOKU_INC.'lib/plugins/'); 4require_once (DOKU_PLUGIN.'syntax.php'); 5 6class syntax_plugin_geogebra_geogebrafile extends DokuWiki_Syntax_Plugin 7{ 8 /* 9 <applet 10 code="geogebra.GeoGebraApplet" 11 codebase="./" 12 archive="./././sources/geogebra/geogebra.jar" 13 width="551" height="359"> 14 <param name="filename" value="./././data/ggb/einheitsvektor.ggb"> 15 <param name="framePossible" value="false"> 16 </applet> 17 */ 18 19 var $dflt = array ( 20 'name'=>'', 21 'width'=>551, 22 'height'=>359, 23 'language'=>'', 24 'country'=>'', 25 'showToolBar'=>false, 26 'showToolBarHelp'=>false, 27 'showAlgebraInput'=>false, 28 'showResetIcon'=>true, 29 'showMenuBar'=>false, 30 'enableShiftDragZoom'=>true, 31 'enableLabelDrags'=>true, 32 'enableRightClick'=>true, 33 'errorDialogsActive' => false, 34 'borderColor'=>'', 35 'bgcolor'=>'', 36 'framePossible'=>'true', 37 'unsigned'=>'false', 38 'maxIconSize' => 32, 39 'ggbOnInitParam' => '', 40 'java_arguments' => '', 41 'customToolBar' => '' 42 ); 43 44 /** 45 * return some info 46 */ 47 function getInfo() 48 { 49 return array ( 50 'author'=>'Jürgen A.Lamers', 51 'email'=>'jaloma.ac@googlemail.com', 52 'date'=>@file_get_contents(DOKU_PLUGIN . 'geogebra/VERSION'), 53 'name'=>'GeoGebra Plugin', 54 'desc'=>'Include GeoGebra-Files to your Wiki with <geogebra name="" width="" height="" />. See http://www.geogebra.org/source/program/applet/geogebra_applet_param.html', 55 'url'=>'http://code.google.com/p/dwpjaloma/wiki/GeoGebra' 56 ); 57 } 58 /** 59 * Plugin Type 60 */ 61 62 function getType() 63 { 64 return 'substition'; 65 } 66 function getSort() 67 { 68 return 316; 69 } 70 function connectTo($mode) 71 { 72 $this->Lexer->addSpecialPattern("<geogebra.*?/>", $mode, 'plugin_geogebra_geogebrafile'); 73 } 74 75 function matchLength() 76 { 77 return strlen("<geogebra "); 78 } 79 80 function handle($match, $state, $pos, & $handler) 81 { 82 // strip markup 83 $match = html_entity_decode(substr($match, $this->matchLength(), -2)); 84 $gmap = $this->_extract_params($match); 85 return $gmap; 86 } 87 88 /** 89 * extract parameters for the gmsdisplay from the parameter string 90 * 91 * @param string $str_params string of key="value" pairs 92 * @return array associative array of parameters key=>value 93 */ 94 function _extract_params($str_params) 95 { 96 $param = array (); 97 preg_match_all('/(\w*)="(.*?)"/us', $str_params, $param, PREG_SET_ORDER); 98 if (sizeof($param) == 0) 99 { 100 preg_match_all("/(\w*)='(.*?)'/us", $str_params, $param, PREG_SET_ORDER); 101 } 102 // parse match for instructions, break into key value pairs 103 $gmap = $this->dflt; 104 foreach ($param as $kvpair) 105 { 106 list ($match, $key, $val) = $kvpair; 107 if ( isset ($gmap[$key]))$gmap[$key] = $val; 108 } 109 110 return $gmap; 111 } 112 113 /** 114 * Create output 115 */ 116 function render($mode, & $renderer, $data) 117 { 118 if ($mode == 'xhtml') 119 { 120 $renderer->doc .= $this->_contact($data); 121 return true; 122 } 123 return false; 124 } 125 126 function getArchive() 127 { 128 return "geogebra.jar"; 129 } 130 function getCode() 131 { 132 return "geogebra.GeoGebraApplet"; 133 } 134 135 function _contact($data) 136 { 137 global $conf; 138 $file = $data['name']; 139 $hasfile = $file != null && $file != ''; 140 141 $file = $conf['savedir'].'/media/'.str_replace(":", "/", $file); 142 143 $width = $data['width']; 144 $height = $data['height']; 145 $unsigned = $data['unsigned']; 146 $showToolBar = $data['showToolBar']; 147 $showToolBarHelp = $data['showToolBarHelp']; 148 $showAlgebraInput = $data['showAlgebraInput']; 149 $showResetIcon = $data['showResetIcon']; 150 $showMenuBar = $data['showMenuBar']; 151 $enableShiftDragZoom = $data['enableShiftDragZoom']; 152 $enableLabelDrags = $data['enableLabelDrags']; 153 $enableRightClick = $data['enableRightClick']; 154 $borderColor = $data['borderColor']; 155 $bgcolor = $data['bgcolor']; 156 $framePossible = $data['framePossible']; 157 $language = $data['language']; 158 $country = $data['country']; 159 $customToolBar = $data['customToolBar']; 160 // 3.2 161 $errorDialogsActive = $data['errorDialogsActive']; 162 $maxIconSize = $data['maxIconSize']; 163 if ($maxIconSize != 16 && $maxIconSize != 32) { 164 $maxIconSize = 32; 165 } 166 $ggbOnInitParam = $data['ggbOnInitParam']; 167 $java_arguments = $data['java_arguments']; 168 169 $txt = ""; 170 if ($unsigned == 'true') 171 { 172 $codebase = $this->getConf('jarbase_unsigned'); 173 $archive = $this->getArchive(); 174 } else 175 { 176 $codebase = $this->getConf('jarbase'); 177 $archive = $this->getArchive(); 178 } 179 $txt .= '<applet'. 180 ' code="'.$this->getCode().'"'. 181 ' archive="'.$archive.'"'. 182 ' codebase="'.$codebase.'"'. 183 ' width="'.$width.'" height="'.$height.'">'; 184 if ($hasfile != '') 185 { 186 $txt .= '<param name="filename" value="'.$file.'"/>'; 187 } 188 $txt .= ' <param name="showToolBar" value="'.$showToolBar.'"/>'; 189 $txt .= ' <param name="showToolBarHelp" value="'.$showToolBarHelp.'"/>'; 190 $txt .= ' <param name="showAlgebraInput" value="'.$showAlgebraInput.'"/>'; 191 $txt .= ' <param name="showResetIcon" value="'.$showResetIcon.'"/>'; 192 $txt .= ' <param name="showMenuBar" value="'.$showMenuBar.'"/>'; 193 $txt .= ' <param name="enableShiftDragZoom" value="'.$enableShiftDragZoom.'"/>'; 194 $txt .= ' <param name="enableLabelDrags" value="'.$enableLabelDrags.'"/>'; 195 $txt .= ' <param name="enableRightClick" value="'.$enableRightClick.'"/>'; 196 $txt .= ' <param name="framePossible" value="'.$framePossible.'"/>'; 197 $txt .= ' <param name="errorDialogsActive" value="'.$errorDialogsActive.'"/>'; 198 $txt .= ' <param name="maxIconSize" value="'.$maxIconSize.'"/>'; 199 200 if ($ggbOnInitParam != '') { 201 $txt .= ' <param name="ggbOnInitParam" value="'.$ggbOnInitParam.'"/>'; 202 } 203 if ($java_arguments != '') { 204 $txt .= ' <param name="java_arguments" value="'.$java_arguments.'"/>'; 205 } 206 if ($customToolBar != '') { 207 $txt .= ' <param name="customToolBar" value="'.$customToolBar.'"/>'; 208 } 209 if ($borderColor != '') 210 { 211 $txt .= ' <param name="borderColor" value="'.$borderColor.'"/>'; 212 } 213 if ($bgcolor != '') 214 { 215 $txt .= ' <param name="bgcolor" value="'.$bgcolor.'"/>'; 216 } 217 if ($language != '') 218 { 219 $txt .= ' <param name="language" value="'.$language.'"/>'; 220 if ($country != '') 221 { 222 $txt .= ' <param name="country" value="'.$country.'"/>'; 223 } 224 } 225 $txt .= 'Please <a href="http://www.java.com">install Java 1.4.2</a> (or later) to use this page.'. 226 '</applet>'; 227 $txt .= '<br />'; 228 if ($this->getConf('showHelpUrl')) 229 { 230 $txt .= '<a href="http://www.geogebra.org/help/docude/" target="help_geogebra">Online-Hilfe</a> —'; 231 } 232 if ($this->getConf('showDownloadUrl') && $hasfile) 233 { 234 $txt .= ' <a href="'.$file.'">Download</a> —'; 235 } 236 $user = $_SERVER['REMOTE_USER']; 237 $txt .= ' Erstellt mit © <a href="http://www.geogebra.at/" target="geogebra">GeoGebra</a> durch '.$user; 238 return $txt; 239 } 240 241}//class 242