Flash Extension

From www.ChopStork.com

Jump to: navigation, search

This is a very simple extension and could be done easier with a template. But it's still kinda fun. It takes in a url to a flash app and embeds that app into the current page.

The Tag

<flash>http://game.panlogic.net/boredmeeting.swf</flash>

The Output

The Code

<?php
 # Flash WikiMedia extension
 # Luke Bunselmeyer
 # 4/22/2005
 #
 # Syntax:
 #   <flash>http://example.com/example.swf<flash>
 #
 
 $wgExtensionFunctions[] = "wfFlashExtension";
 
 function wfFlashExtension() {
     global $wgParser;

     # register the extension with the WikiText parser
     $wgParser->setHook( "Flash", "renderFlash" );
	 $wgParser->setHook( "flash", "renderFlash" );

 }
 
 # The callback function for converting the input text to HTML output
 function renderFlash( $url ) {

	if (!$width) $width = 550;
	else $width = (int)$width;
	if ($width>950) $width = 950;

	if (!$height) $height = 400;
	else $height = (int)$height;
	if ($height>950) $height = 950;

	if (!$url) $url = $vars[0];
	$url = htmlspecialchars($url);

	if ($url)
	{
		$html = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width='$width' height='$height'>";
		$html.= "<param name=\"movie\" value='$url' />";
		$html.= "<param name=\"quality\" value=\"high\" />";
		$html.= "<embed src='$url' quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width='$width' height='$height'></embed></object>";

	}

	return $html;
 }
?>
Personal tools