Team:TzuChiU Formosa
From 2009.igem.org
Line 1: | Line 1: | ||
+ | <?php | ||
+ | /** | ||
+ | * MediaWiki Flash SWF extension | ||
+ | * set up MediaWiki to react to the "<swf>" tag | ||
+ | * | ||
+ | * @version 0.2 | ||
+ | * @author Brigitte Jellinek | ||
+ | */ | ||
+ | |||
+ | /** | ||
+ | * Protect against register_globals vulnerabilities. | ||
+ | * This line must be present before any global variable is referenced. | ||
+ | */ | ||
+ | if (!defined('MEDIAWIKI')) die(); | ||
+ | |||
+ | //Avoid unstubbing $wgParser too early on modern (1.12+) MW versions, as per r35980 | ||
+ | if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) { | ||
+ | $wgHooks['ParserFirstCallInit'][] = 'wfSwf'; | ||
+ | } else { | ||
+ | $wgExtensionFunctions[] = 'wfSwf'; | ||
+ | } | ||
+ | |||
+ | $wgExtensionCredits['parserhook'][] = array( | ||
+ | 'name' => 'Flash SWF', | ||
+ | 'version' => '0.2', | ||
+ | 'author' => 'Brigitte Jellinek', | ||
+ | 'description' => 'Allows the display of flash movies within a wiki with the <tt><swf></tt> tag', | ||
+ | 'url' => 'http://www.mediawiki.org/wiki/Extension:Flash_swf', | ||
+ | ); | ||
+ | |||
+ | function wfSwf() { | ||
+ | global $wgParser; | ||
+ | $wgParser->setHook( 'swf', 'renderSwf' ); | ||
+ | return true; | ||
+ | } | ||
+ | |||
+ | function renderSwf( $input, $argv ) { | ||
+ | global $wgScriptPath; | ||
+ | $output = ""; | ||
+ | |||
+ | #parse fields in flashow-section | ||
+ | $fields = explode("|",$input); | ||
+ | $input = $fields[0]; | ||
+ | |||
+ | //added functionality for parameters passed within the tag's body | ||
+ | //<swf>movie.swf|width=200|height=300|loop=false</swf> | ||
+ | for ($i=1; $i < sizeof($fields); $i++) { | ||
+ | $newArg = explode("=", $fields[$i]); | ||
+ | $argv[$newArg[0]] = $newArg[1]; | ||
+ | } | ||
+ | |||
+ | // external URL | ||
+ | if ( (strpos($input , "http") === 0) && | ||
+ | (strpos($input, ".swf") == strlen($input)-4) | ||
+ | ) { | ||
+ | $url = $input; | ||
+ | } | ||
+ | |||
+ | // internal media: | ||
+ | else { | ||
+ | $img = Image::newFromTitle( $input ); | ||
+ | if ( $img == null ) return "Not an internal Media/swf: $input"; | ||
+ | $img->load(); | ||
+ | $path = $img->getPath(); | ||
+ | if ( ! $path ) return "No path for internal Media:$input"; | ||
+ | $dir = dirname($_SERVER['SCRIPT_FILENAME']); | ||
+ | $url = str_replace($dir, $wgScriptPath, $path ); | ||
+ | } | ||
+ | |||
+ | $width = isset($argv['width']) ? $argv['width'] : 550; | ||
+ | $height = isset($argv['height'])? $argv['height'] : 400; | ||
+ | |||
+ | if (strpos($width,"%") == (strlen($width) - 1)) { | ||
+ | $divWidth = "width:$width"; | ||
+ | } else { | ||
+ | $divWidth = "width:$width"."px"; | ||
+ | } | ||
+ | if (strpos($height,"%") == (strlen($height) - 1)) { | ||
+ | $divHeight= "height:$height"; | ||
+ | } else { | ||
+ | $divHeight= "height:$height"."px"; | ||
+ | } | ||
+ | |||
+ | $id = basename($input, ".swf"); | ||
+ | $output .=<<<EOM | ||
+ | <!-- display a swf --> | ||
+ | <div class="swf" style="$divWidth;$divHeight"> | ||
+ | <object | ||
+ | classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" | ||
+ | codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" | ||
+ | width="$width" height="$height" id="$id" align="middle"> | ||
+ | <param name="allowScriptAccess" value="sameDomain" /> | ||
+ | <param name="menu" value="true" /> | ||
+ | <param name="movie" value="$url" /> | ||
+ | <param name="quality" value="high" /> | ||
+ | <param name="bgcolor" value="#ffffff" /> | ||
+ | <embed src="$url" quality="high" bgcolor="#ffffff" | ||
+ | width="$width" height="$height" | ||
+ | name="$id" align="middle" allowScriptAccess="sameDomain" | ||
+ | type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> | ||
+ | </object> | ||
+ | </div> | ||
+ | <!-- end of swf display --> | ||
+ | EOM; | ||
+ | $output = str_replace("\n", "", $output); | ||
+ | |||
+ | |||
+ | return $output; | ||
+ | } | ||
+ | |||
[[Flash:title.swf]] | [[Flash:title.swf]] | ||
+ | |||
Revision as of 10:54, 12 September 2009
<?php /**
* MediaWiki Flash SWF extension * set up MediaWiki to react to the "<swf>" tag * * @version 0.2 * @author Brigitte Jellinek */
/**
* Protect against register_globals vulnerabilities. * This line must be present before any global variable is referenced. */
if (!defined('MEDIAWIKI')) die();
//Avoid unstubbing $wgParser too early on modern (1.12+) MW versions, as per r35980 if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) { $wgHooks['ParserFirstCallInit'][] = 'wfSwf'; } else { $wgExtensionFunctions[] = 'wfSwf'; }
$wgExtensionCredits['parserhook'][] = array( 'name' => 'Flash SWF', 'version' => '0.2', 'author' => 'Brigitte Jellinek', 'description' => 'Allows the display of flash movies within a wiki with the <swf> tag', 'url' => 'http://www.mediawiki.org/wiki/Extension:Flash_swf', );
function wfSwf() {
global $wgParser; $wgParser->setHook( 'swf', 'renderSwf' );
return true; }
function renderSwf( $input, $argv ) { global $wgScriptPath; $output = "";
#parse fields in flashow-section $fields = explode("|",$input); $input = $fields[0];
//added functionality for parameters passed within the tag's body //<swf>movie.swf|width=200|height=300|loop=false</swf> for ($i=1; $i < sizeof($fields); $i++) { $newArg = explode("=", $fields[$i]); $argv[$newArg[0]] = $newArg[1]; }
// external URL if ( (strpos($input , "http") === 0) && (strpos($input, ".swf") == strlen($input)-4) ) { $url = $input; }
// internal media: else { $img = Image::newFromTitle( $input ); if ( $img == null ) return "Not an internal Media/swf: $input"; $img->load(); $path = $img->getPath(); if ( ! $path ) return "No path for internal Media:$input"; $dir = dirname($_SERVER['SCRIPT_FILENAME']); $url = str_replace($dir, $wgScriptPath, $path ); }
$width = isset($argv['width']) ? $argv['width'] : 550; $height = isset($argv['height'])? $argv['height'] : 400;
if (strpos($width,"%") == (strlen($width) - 1)) { $divWidth = "width:$width"; } else { $divWidth = "width:$width"."px"; } if (strpos($height,"%") == (strlen($height) - 1)) { $divHeight= "height:$height"; } else { $divHeight= "height:$height"."px"; }
$id = basename($input, ".swf"); $output .=<<<EOM
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="$width" height="$height" id="$id" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="menu" value="true" /> <param name="movie" value="$url" /> <param name="quality" value="high" /> <param name="bgcolor" value="#ffffff" /> <embed src="$url" quality="high" bgcolor="#ffffff" width="$width" height="$height" name="$id" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> </object>
EOM;
$output = str_replace("\n", "", $output); return $output;
}
You can write a background of your team here. Give us a background of your team, the members, etc. Or tell us more about something of your choosing. | |
Tell us more about your project. Give us background. Use this is the abstract of your project. Be descriptive but concise (1-2 paragraphs) | |
Team Example |
Home | The Team | The Project | Parts Submitted to the Registry | Modeling | Notebook |
---|
(Or you can choose different headings. But you must have a team page, a project page, and a notebook page.)