Extension:Flash swf

From MediaWiki.org

Jump to: navigation, search
Manual on MediaWiki Extensions
List of MediaWiki Extensions
Flash swf

Release status: unknown

Implementation Tag
Description embeds a widget that plays flash movies
Author(s) Brigitte Jellinek
Version 0.0
Download see below

Flash swf is just another Flash extension. See also Flash and Flashow.

Contents

[edit] Syntax

The Flash extension uses <swf></swf> tags. The swf-Files can either be external or Media: files.

[edit] Sample

Give the URL of the swf-file as the content of the swf-tag, specify Width and Height as attributes. (default to width=550, height=400)

 <swf width="50" height="50">https://multimediaart.at/mmawiki/images/b/bb/Mini.swf</swf>

if you have uploaded a file Media:Mini.swf to your Wiki, you can use that instead of the url:

 <swf width="50" height="50">Mini.swf</swf>

(To allow uploding of swf-Files, add the extension to $wgFileExtensions)

[edit] Installation

You need to copy the code from below to a file called swf.php and then place this file into your extensions folder, and place require_once("extensions/swf.php"); at the end of LocalSettings.php.

The PHP source code for swf.php:

<?php
// MediaWiki Swf Extension Ver 0.0
// set up MediaWiki to react to the "<swf>" tag
// created by Brigitte Jellinek
$wgExtensionFunctions[] = "wfSwf";
function wfSwf() {
        global $wgParser;
        $wgParser->setHook( "swf", "RenderSwf" );
}
function RenderSwf( $input, $argv ) {
     global $wgScriptPath;
     $output = "";
     // external URL
     if ( strpos($input , "http") === 0 && strpos($input, ".swf") == strlen($input)-4 ) {
       $url = $input;
     }
     // internal Media:
     else {
            $img = Image::newFromName( $input );
            if ( $img == null ) return "Not an internal Media/swf: $input";
            $img->load();
            if ( ! $img->imagePath ) return "No path for internal Media:$input";
            $dir = dirname($_SERVER['SCRIPT_FILENAME']);
            $url = str_replace($dir, $wgScriptPath, $img->imagePath );
     }
     $width  = isset($argv['width']) ? $argv['width']  : 550;
     $height = isset($argv['height'])? $argv['height'] : 400;
     $id = basename($input, ".swf");
     $output  .=<<<EOM
<!-- display a swf -->
<div class="swf" style="width:{$width}px">
<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="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;
}

[edit] Alternatives

Personal tools