Extension:Flash swf

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
Flash swf

Release status: unknown

Implementation Tag
Description embeds a widget that plays flash movies
Author(s) Brigitte Jellinek
Last version 0.2
License No license specified
Download see below

Check usage (experimental)

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

[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://example.org/wiki/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">Media:Mini.swf</swf>
 <swf>Media:Mini.swf|width=50|height=50</swf>

(To allow uploading of .swf files, add 'swf' to $wgFileExtensions)

<?php
 
/**
 * MediaWiki Flash SWF extension
 * set up MediaWiki to react to the "<swf>" tag
 *
 * @version 1.0
 * @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' => '1.0',
    'author' => 'Brigitte Jellinek',
    'description' => 'Allows the display of flash movies within a wiki with the <tt>&lt;swf&gt;</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 ) {
      $output = "";
      // external URL
      if ( strpos($input , "http") === 0 && strpos($input, ".swf") == strlen($input)-4 ) {
          $url = $input;
      }
      // internal Media:
      else if ( strpos($input , "Media:") === 0 ) {
            $title = Title::makeTitleSafe("Media",$input);
            $img = new Image($title);
            $url = $img->getViewURL(false);
            if( !$img->exists() ) {
                return "Mediafile does not exist: $input";
            }
      }
      else {
         return "Not an internal Mediafile (does not start with Media:) $input";
      }
      $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
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox