Extension:Java Applet

This Mediawiki extension enables you to add Java applets using the "java_applet" tag. The Java binary must be uploaded to the wiki (either class file or jar file). You may need to add 'jar' and 'class' to the $wgFileExtensions variable in LocalSettings.php.

Arguments

 * code, java class file (required)
 * width, applet width (required)
 * height, applet height (required)
 * archive, jar file name (required)

Example


Installation
To install copy the code below to "JavaApplet.php" and put it in your Mediawiki extensions directory and add... include("extensions/JavaApplet.php"); ...to your LocalSettings.php file.

This is my first try at coding php so I don't promise it to be secure, easy to use or even work. Use this program at your own risk.

setHook( 'java_applet', 'getAppletOutput' ); } function getAppletOutput( $input, $args, $parser ) {	// URL of the WIKI's server global $wgServer;

// Look for required elements if( !isset( $args['code'] )   || // Eventualy remove the "archive" parameter and            !isset( $args['archive'] ) || // make the extention detect if the code is a jar            !isset( $args['width'] )   || // and read it's manifest to determin the main class.            !isset( $args['height'] ) ) return "\n"; // Set the appletBinary to the JAR file $appletBinary = $args['archive']; // Get the Image object from the file name $file = Image::newFromName( $appletBinary ) ; // Need to check this better

// Get the mediawiki path of the file $fileURL = $file->getURL; // Need to check this better too

// Strip the filename from the path $fileURL = str_replace( $appletBinary, "", $fileURL );

// Attach wiki site path $codeBase = $wgServer. $fileURL;

// Output the opening applet tag $output = "\n\n<APPLET";

// Add code value to tag $output = $output. ' code="' . $args['code'] . '"';

// Add codebase value to tag //$output = $output. ' codebase="' . $args['codebase'] . '"'; $output = $output. ' codebase="' . $codeBase . '"';

// Add width value to tag $output = $output. ' width="' . $args['width'] . '"';

// Add height value to tag $output = $output. ' height="' . $args['height'] . '"';

// Add Archive value to tag if it exists if( isset( $args['archive'] ) ) $output = $output. ' archive="' . $args['archive'] . '"';

// The closing applet tag $output = $output. ">\n";

// Send the output to the browser return $output; } ?>

To Do
Automatically detect the 'code' value from jar files with properly setup manifests.