====== Applet Plugin ====== ---- plugin ---- description: A basic plugin for inserting Java applets in wiki pages author : Stylianos Dritsas email : stylianos [at] dritsas [dot] net type : syntax lastupdate : 2006-03-05 compatible : 2007-10-06 depends : conflicts : similar : tags : !obsolete, java, !experimental downloadurl: https://trello.com/1/cards/5aff147263a8bc1675cbda30/attachments/5aff1498968161adb80c9c3e/download/applet-v2.zip bugtracker : sourcerepo : donationurl: screenshot_img: ---- Java applets as facilitated by this plugin are not supported in recent browsers anymore. A basic plugin for inserting Java applets in wiki pages. Currently there is very little error checking so be extremely careful using the plugin. There is also no support for applet parameters i.e. ''%%%%''. The limitations and assumptions are described in the code in detail. Feel free to improve and have fun. //Stelios// === Acknowledgments === The [[plugin:draw]] plugin author(s) for a clean example of how to hack up a simple wiki plugin. === Usage === **Where** * ''APPLET_CLASS'' -- is the class name of the applet.\\ Example: "MyApplet" * ''ARCHIVE_IN_NAMESPACE'' -- the jar or zip archive that the applet is stored.\\ Example: "Projects:MyAppletProject:MyApplet.jar" * ''WIDTH_IN_PIXELS'' -- the width of the applet window * ''HEIGHT_IN_PIXELS'' -- the height of the applet window ===== Version 2.0 ===== Works on servers with higher security settings. (Uses the fetch.php mechanism). Make sure that you add a jar mime type for better results or make your jars into zips. === syntax.php === 'Stylianos Dritsas', 'email' => 'stylianos [at] dritsas [dot] net', 'date' => '2006-03-05', 'name' => 'applet', 'desc' => 'Java Applet Plugin', 'url' => 'https://www.dokuwiki.org/plugin:applet', ); } /** * Typology? */ function getType( ) { return 'substition'; } /** * Sort Code? */ function getSort( ) { return 316; } /** * Pattern Matching? */ function connectTo($mode) { $this->Lexer->addSpecialPattern( '', $mode, 'plugin_applet' ); } /** * Parsing * 1. Very rough parsing involved * 2. Applet parameters not included */ function handle( $match, $state, $pos, &$handler ) { preg_match( '/width=([0-9]+)/i', substr( $match, 6, -1 ), $match_width ); preg_match( '/height=([0-9]+)/i', substr( $match, 6, -1 ), $match_height ); preg_match( '/code=([a-zA-Z_0-9.]+)/i', substr( $match, 6, -1 ), $match_code ); preg_match( '/archive=([a-zA-Z_0-9:.]+)/i', substr( $match, 6, -1 ), $match_archive ); return array( $match_code[1], $match_width[1], $match_height[1], $match_archive[1] ); } /** * Rendering * 1. There is no error checking involved whatsoever * 2. Assuming that all applets come in a jar or zip archive * 3. The namespace to path conversion is highly ad-hoc-ish */ function render( $mode, &$renderer, $data ) { if($mode == 'xhtml'){ list( $code, $width, $height, $archive ) = $data; //$archive = 'data/media/' . str_replace( ":", "/", $archive ); $archive = DOKU_BASE . 'lib/exe/fetch.php?media=' . $archive; $renderer->doc .= ""; return true; } else { return false; } } } ===== Version 1.0 ===== Works on servers with low security settings. === syntax.php === 'Stylianos Dritsas', 'email' => 'stylianos [at] dritsas [dot] net', 'date' => '2006-03-05', 'name' => 'applet', 'desc' => 'Java Applet Plugin', 'url' => 'https://www.dokuwiki.org/plugin:applet', ); } /** * Typology? */ function getType( ) { return 'substition'; } /** * Sort Code? */ function getSort( ) { return 316; } /** * Pattern Matching? */ function connectTo($mode) { $this->Lexer->addSpecialPattern( '', $mode, 'plugin_applet' ); } /** * Parsing * 1. Very rough parsing involved * 2. Applet parameters not included */ function handle( $match, $state, $pos, &$handler ) { preg_match( '/width=([0-9]+)/i', substr( $match, 6, -1 ), $match_width ); preg_match( '/height=([0-9]+)/i', substr( $match, 6, -1 ), $match_height ); preg_match( '/code=([a-zA-Z_0-9].+)/i', substr( $match, 6, -1 ), $match_code ); preg_match( '/archive=([a-zA-Z_0-9:.]+)/i', substr( $match, 6, -1 ), $match_archive ); return array( $match_code[1], $match_width[1], $match_height[1], $match_archive[1] ); } /** * Rendering * 1. There is no error checking involved whatsoever * 2. Assuming that all applets come in a jar or zip archive * 3. The namespace to path conversion is highly ad-hoc-ish */ function render( $mode, &$renderer, $data ) { if($mode == 'xhtml'){ list( $code, $width, $height, $archive ) = $data; $archive = 'data/media/' . str_replace( ":", "/", $archive ); $renderer->doc .= ""; return true; } else { return false; } } }