Extension talk:Flash

From mediawiki.org
Latest comment: 12 years ago by Link0ff in topic Doesn't work on 1.18, 1.19, 1.20
The following discussion has been transferred from Meta-Wiki.
Any user names refer to users of that site, who are not necessarily users of MediaWiki.org (even if they share the same username).

Code Change Proposal[edit]

-- Improved code posted by somebody, unchecked Mmtux 22:12, 13 August 2006 (UTC)Reply


with wikimedia 1.5 rc4

change the code in flash.php:

        function getTitle() {
                $title = Title::makeTitleSafe("Image","Scale.swf");
                $filename = $title->getDBKey();
                $img = new Image($title);
                $path = $img->getViewURL(false);
                return $path;
        }

to


        function getTitle($file) {
                $title = Title::makeTitleSafe("Image",$file);
                //$filename = $title->getDBKey();
                $img = new Image($title);
                $path = $img->getViewURL(false);
                return $path;
        }

Not compatible with v1.7.x?[edit]

Running php 5 and 1.7.1 the Flash extension is not working. Since I am inept with php any clues as to how to render this extension compatible? MikeCLovett 15:23, 20 July 2006 (UTC)Reply

PHP 5.1.2 and MW 1.7.1 here, and I also get errors. It doesn't show anything on the page when I have the <flash>...</flash> tag, but instead it coughs this:
Image constructor given bogus title.

Backtrace:

#0 /home/.xenophon/fatorcao/xug/wiki/extensions/flash.php(95): Image->Image(NULL)
#1 /home/.xenophon/fatorcao/xug/wiki/extensions/flash.php(86): Flash->getTitle(NULL)
#2 /home/.xenophon/fatorcao/xug/wiki/extensions/flash.php(33): Flash->genCode()
#3 /home/.xenophon/fatorcao/xug/wiki/extensions/flash.php(108): Flash->Flash('file=swf/unit_s...')
#4 /home/.xenophon/fatorcao/xug/wiki/includes/Parser.php(533): renderFlash('file=swf/unit_s...', Array, Object(Parser))
#5 /home/.xenophon/fatorcao/xug/wiki/includes/Parser.php(279): Parser->strip('renderFlash', Array)
#6 /home/.xenophon/fatorcao/xug/wiki/includes/EditPage.php(1401): Parser->parse('{{P??gina tempo...', Array)
#7 /home/.xenophon/fatorcao/xug/wiki/includes/EditPage.php(1244): EditPage->getPreviewText('{{P??gina tempo...', Object(Title), Object(ParserOptions))
#8 /home/.xenophon/fatorcao/xug/wiki/includes/EditPage.php(1004): EditPage->showPreview()
#9 /home/.xenophon/fatorcao/xug/wiki/includes/EditPage.php(379): EditPage->showEditForm()
#10 /home/.xenophon/fatorcao/xug/wiki/includes/EditPage.php(217): EditPage->edit()
#11 /home/.xenophon/fatorcao/xug/wiki/includes/Wiki.php(380): EditPage->submit()
#12 /home/.xenophon/fatorcao/xug/wiki/includes/Wiki.php(50): MediaWiki->performAction()
#13 /home/.xenophon/fatorcao/xug/wiki/index.php(123): MediaWiki->initialize(Object(OutputPage), Object(Article), Object(Title), Object(User), Object(WebRequest))
#14 {main}
I've tested it with 1.7.1 a bit just now, it works for me. Maybe you're using the wrong PHP version (4 or 5?) --Mmtux 14:44, 14 August 2006 (UTC)Reply
Hrm.. will have to experiment. We are using PHP 5.1.4 mcl 15:58, 4 September 2006 (UTC)Reply

Trying to understand the code (newbie)[edit]

I understand some functionality in this is borrowed from Image.php. Is that where this->file is determined? I don't see the parser ever saving this->file anywhere in 0.01 or 0.02 versions of the code. I'm new, and will keep digging on my own, but if someone has a tip, I'd appreciate it. Thanks, Jonathan Jcobbers 15:28, 26 January 2006 (UTC)Reply

this->file is not defined explicitly in the extension. The variable contains the file name of the flash file that should be displayed (e.g. flashfile.swf). The user defines it in the wiki code (<flash>file=flashfile.swf|...</flash>). From there it is automatically saved into this->file. To be precise, this happens in line 56:
$this->{$this->instr} = $this->value;
I hope this helps... Cheers --Mmtux 14:50, 14 August 2006 (UTC)Reply

Flashes that only display in preview mode- Solution[edit]

There are certain swf's which assume current directory. These may work in preview mode but not after the article is saved. The solution is to correct the current directory assumptions in the Flash code. MakThorpe 19:29, 10 March 2006 (UTC)Reply

I could not solve this situation. I can't play any swf in "final" mode. There is no current directory assumptions in the swf's I'm using, they are simply animations!!! Clinisbut 0:10, 19 Dec 2007 {GTM+1}

Curious about why New Image[edit]

Since no one has made an authoritative response to Jcobbers' inquiry above, I will make a stab at it. I am guessing that the purpose of the instantiation of an Image object in function getTitle is simply to discover the URL to the .SWF stored in the Wiki. If the .SWF was external to the wiki and the URL was known, then this step would be unnecessary. The purpose is not to store a new persistant object in the wiki database. Is that correct? MakThorpe 19:29, 10 March 2006 (UTC)Reply

Yes. Unless it's disabled, the image folder administrated by mediawiki. To find the path, the Image class is used. --Mmtux 14:57, 14 August 2006 (UTC)Reply

Question regarding arguments[edit]

Is it possible to add arguments to the .swf file. I have a flash file that takes a flv video filename as the argument. I.e. test.swf?file=video.flv.

I guess this could be implemented. I'll see if I find time. --Mmtux 15:00, 14 August 2006 (UTC)Reply

Notice[edit]

On my system with php4 the extension is working, but I got some Notice lines, because not all the variables have been initialiased.

To get rid of these Notices I added three lines:

function parseInput( $input ) {
$this->tmp="";
 $this->codeEmbed="";
 $this->codeObject="";
for($pos=0; $pos<strlen($input); $pos++) { // go through all arguments

Now it works for me.

Interesting. PHP should auto-inizialize all variable names. Please let me know if you find out why this hasn't happened in your case. --Mmtux 15:01, 14 August 2006 (UTC)Reply

Is there a syntax for allowing left - right positioning and wrapping of text?[edit]

I would like to be able to do the same things that you can do with images in mediawiki. It makes an artcle look much nicer if you can position an image left or right and have the text appear in line with the image...

Since this is not exactly an Image object, the image attributes can't be used directly. It probably is possible though to use the Image class to wrap the flash file as it wraps an image. I'll check that out as I have time again. --Mmtux 15:04, 14 August 2006 (UTC)Reply

Flashvars attribute[edit]

The flashvars attribute cannot be parsed easily because of the form of the parameters "value1=parameter&value2=parameter"

The = signs are parsed through the complete argument and the result is an undefind flashvars.


I propose a trick each time you need to obtain :

flashvars=value1=parameter&value2=parameter

try instead

flashvars=value1<nowiki>=</nowiki>parameter&value2<nowiki>=</nowiki>parameter


I have a small patch to do this.

Basically, it skips the '=' check if the attribute is flashvars. So, you can specify entire query strings as is in flashvars. E.g.

<flash>file=sample.swf|width=800|height=460|flashvars=?arg1=value1&arg2=value2</flash>

Patch:

*** Flash.php	2006-05-21 14:04:02.000000000 -0700
--- extensions/Flash.php	2006-05-21 14:01:37.000000000 -0700
***************
*** 37,46 ****
--- 37,64 ----
          function parseInput( $input ) {
                  for($pos=0; $pos<strlen($input); $pos++) { // go through all arguments
                          if($input{$pos}=='=') { // separator between command
+                         
+                                 //ignore '=' if the attribute is flashvars
+                                 //this will enable to pass query string to flash files
+                                 if($gotflashvars) {
+                                         $this->tmp .= $input{$pos};
+                                         continue;
+                                 }
+ 
                                  $this->instr = $this->tmp;
                                  $this->tmp = '';
+ 
+                                 //set the flag for flashvars
+                                 if($this->instr == 'flashvars') {
+                                         $gotflashvars = 1;
+                                 }
                          }
                          else if($input{$pos}=='|') { // separator between arguments
+ 
+                                 //reset the flags for other attributes
+                                 if($gotflashvars) {
+                                     $gotflashvars = 0;
+                                 }
                                  Flash::setValue();
                                  $this->tmp='';
                          } else {
***************
*** 54,59 ****
--- 72,78 ----
          function setValue() {
                  $this->value = $this->tmp;
                  $this->{$this->instr} = $this->value;
+ 
                  if($this->instr=='play'|| // Whitelist of flash commands. Anything else but flash commands is ignored.
                          $this->instr=='loop'||
                          $this->instr=='quality'||
***************
*** 85,92 ****
--- 104,117 ----
                  $this->version='7,0,0,0'; // Version settings for <object>
                  $this->url = $this->getTitle($this->file);//Flash::imageUrl( $this->file, $this->fromSharedDirectory ); // get Wiki internal url
  
+                 // if flashvars is set append to the url
+                 if($this->flashvars) {
+                     $this->url .= $this->flashvars;
+                 }
+ 
                  /* Final Code */
                  $this->code = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="' . $this->width . '" height="' . $this->height . '" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' . $this->version . '"><param name="movie" value="' . $this->url . '">' . $this->codeObject . '<embed src="' . $this->url . '" width="' . $this->width . '" height="' . $this->height . '"' . $this->codeEmbed . ' pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed></object>';
+                 
                  return $this->code;
          }
          function getTitle($file) {
 
Thanks for the patch, I've applied it to 1.0 beta. I could not credit you as you did not sign your post, nor were you logged in at the time you wrote it. Post your username here if you want to be credited. You'll have to post with your IP address. Thanks, --Mmtux 15:22, 14 August 2006 (UTC)Reply

Security?[edit]

I made a proposal here to implement this extension into the Homestar Runner Fanstuff Wiki, but it was rejected by the admins due to security issues. What security measures does this thing have in place? The Mu 02:37, 10 August 2006 (UTC)Reply

I do not qualify as a security expert, but I am fairly sure that Flash can pose a minor security risk to clients running Flash files put on servers. For starters, Flash is a client side technology, meaning it's downloaded and executed on the clients machine (hence the reason the player needs to be installed to view the files). IMHO, this restricts Flash to operations on the client's machine. The security risk on the client's machine can be severe. What it can do for example, and this may have serious consequences, is to reload the current page to any other web page. Some other Flash features could probably also be exploited. The other problem with Flash is that it is not compiled from it's source format and it may not be directly visible if a certain Flash file contains malicious parts. Yet again, I'm not a security expert, neither do I have any practical experience regarding this matter, so don't trust my information. --Mmtux 22:48, 13 August 2006 (UTC)Reply
Uh, I think Phlip had a different view of that. (See the page in question.) The Mu 21:36, 16 August 2006 (UTC)Reply
Well, I don't have the time to read so much of that, but it seems to me as if "Phlip" is even less qualified. Judging from his comments, it seems as if he is misunderstanding the basic theory behind how Flash, Mediawiki and the Web in general works. But honestly, it's not so much my business to try and convince random wiki admins to use this extension. --Mmtux

Assumed File Location?[edit]

What is the default file location that this extension looks for to find the flash file? I can't get it to register anything. My file is located in .../images/Folder/File.swf What should I type after "file=" to get it to work? Thanks for the help!

It will attempt to find it in the default images folder, therefore filename=File.swf is the way to go. --Marius

IE "click here to activate" focus rectangle.[edit]

When I view flash on a page with this extension via Internet Explorer (6 or 7), a focus rectangle surrounds Flash movies and a tooltip saying Click here to activate this control appears when the mouse cursor is over the Flash movie. I assume that it's related to this issue/fix: http://www.tekool.net/javascript/backtothehtml/index_en.html

Anyone want to take a shot at updating this extension?

--Travisk 02:52, 4 December 2006 (UTC)Reply

There is an actual reason for IE to display that rectangle. It can be overwritten using JavaScript, however, the use of JavaScript in an extension is a whole different topic. If users would like to disable this constraint using JavaScript, they should do it themselves. JavaScript should not be used in such an extension by default. And even if anybody would like to fork this extension to include this fix, it probably wouldn't work: JavaScript would have to be included into the page header, which is afaik not possible from an extension. PHP can add header information, but not at the time the extension is loaded. Last but not least, the fix has a poor performance (iterating all HTML objects) and I personally doubt that it will work with many future versions of the software. --Marius

Alignment[edit]

The attribute reference doesn't list any variables for the align and salign attributes. So, I went by the MSDN Library listings (and a few other listings which agreed), and the flash object didn't move anywhere.

The listings were:

absbottom Aligns the bottom of the object with the absolute bottom of the surrounding text. The absolute bottom is equal to the baseline of the text minus the height of the largest descender in the text.
absmiddle Aligns the middle of the object with the middle of the surrounding text. The absolute middle is the midpoint between the absolute bottom and text top of the surrounding text.
baseline Aligns the bottom of the object with the baseline of the surrounding text.
bottom Aligns the bottom of the object with the bottom of the surrounding text. The bottom is equal to the baseline minus the standard height of a descender in the text.
left Default Aligns the object to the left of the surrounding text. All preceding and subsequent text flows to the right of the object.
middle Aligns the middle of the object with the surrounding text.
right Aligns the object to the right of the surrounding text. All subsequent text flows to the left of the object.
texttop Aligns the top of the object with the absolute top of the surrounding text. The absolute top is the baseline plus the height of the largest ascender in the text.
top Aligns the top of the object with the top of the text. The top of the text is the baseline plus the standard height of an ascender in the text.

Any Suggestions???? --Qsheets 01:41, 28 December 2006 (UTC)Reply

Keep getting Error ?!?!?![edit]

I am using Media Wiki 1.6.7 and I keep recieving this error

Notice: Undefined property: tmp in flash.php on line 47

Notice: Undefined property: codeEmbed in flash.php on line 73

Notice: Undefined property: codeObject in flash.php on line 74

Any idea why I might be getting this?

MetalHellsAngel 19:29, 14 January 2007 (UTC)Reply

Request: embedding an external flash file[edit]

I want the MediaWiki extension that can embed an external flash file. So I propose a new function that embeds an external flash file (markup example: <flash>file=http://www.yourdomain.org/flash.swf|width=400|height=300</flash>). Please develop new version of the extension in this way. --Yes0song 09:34, 25 March 2007 (UTC)Reply

A similar example: Video extension can embed both internal and external file. --Yes0song 09:40, 25 March 2007 (UTC)Reply

Can Crash this[edit]

Enter newlines inside the <flash> tags and it crashes.

Was trying to get prettier code so i could figure out why it wasn't working by getting some formats for it. would be nice if it would provide some layout in the code -

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="822" height="651" id="FLVPlayer">
  <param name="movie" value="FLVPlayer_Progressive.swf" />
  <param name="salign" value="lt" />
  <param name="quality" value="high" />
  <param name="scale" value="noscale" />
  <param name="FlashVars" value="&MM_ComponentVersion=1&skinName=Halo_Skin_3&streamName=/flash_media_player/video&autoPlay=false&autoRewind=false" />
  <embed src="FLVPlayer_Progressive.swf" flashvars="&MM_ComponentVersion=1&skinName=Halo_Skin_3&streamName=/wiki/images/video/&autoPlay=false&autoRewind=false" quality="high" scale="noscale" width="822" height="651" name="FLVPlayer" salign="LT" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>


FlashVars[edit]

I would like to be able to use a defined variable {{#var:myVariable}} (see Variables Extension) in the list of FlashVars.

For example <flash> ... |flashvars=?myVariable={{#var:myVariable}}</flash>

Unfortunately, the .swf gets something other than the value of myVariable -- probably {{#var:myVariable}} as a string.

Any thoughts on how to do this?

Thanks Kruhly 22:45, 6 February 2008 (UTC)Reply

Error Checking[edit]

Unfortunately, there is not way to guarantee that the users will pass in the correct parameters to this extension. So, it would be nice if the code did some error checking prior to porcessing them. For example, on our wiki, a user posted a comment like "it would be nice to have the ability to use the <flash> extension available on some wikis. --[[:User:Someuser|Some User]]". This, of course, caused the extenstion to start processing the code, but it failed with nasty error messages. I'd like to suggest the following improvements:

  • Declare your class variables and initialize them to something useful. The you can do error checking like so
class Flash {
        var $instr;
        var $tmp;
        var $value;
        var $codeEmbed;
        var $codeObject;
        var $file = '';
        var $url;
        var $version;
        var $flashvars;
        var $code;
        var $width;
        var $height;
        

        /* Constructor */
        function Flash( $input ) {
                Flash::parseInput( $input ); // Parse the input
                if ($this->file == '') return NULL;
                Flash::genCode(); // Generate the final code
        }
  • Do some error checking when processing parameters. For the time being, I added the following (but admittedly, it's not how it should look in the final version)
        function parseInput( $input ) {
                ...
                if (!isset($this->instr)) return;
                Flash::setValue();
  • also, I'm not sure why the code to parse the arguments is so complicated. It seems like all parameters are passed in as name=value separated by a '|' character. You could simply use preg_split() and preg_match() to extract your name/value pairs. alternatively, you could pass in the parameters in the extension tag itself (the preferred MediaWiki way). Take a look at Manual:Tag_extensions. --Gri6507 13:00, 7 April 2008 (UTC)Reply


Image::__construct is deprecated[edit]

I'm using the extension on the Main_Page of my wiki and all users are getting this error at the top of the page: Notice: Use of Image::__construct is deprecated in /var/www/repo-server/w/includes/GlobalFunctions.php on line 2474

We're running MW trunk: MediaWiki 1.13alpha (r32886)

Any ideas? --Paul.irish 15:31, 9 April 2008 (UTC)Reply

For others, you can avoid this nasty error popping up by disabling warnings in php. In /etc/php5/apache2/php.ini there's a section about error reporting that you can tweak. --Paul.irish 15:47, 9 April 2008 (UTC)Reply


Even better than above!
Edit wiki/includes/DefaultSettings.php set your error messages to false.
e.g. $wgShowExceptionDetails = false; // --Thor.Hammaraxx 4:35 PM 2/03/2011 (AEST)

External Files[edit]

How do you hand the flash file external txt files? Do i need to use the flashvars attribute? --Adam 15:45, 21 May 2008 (GMT)

Height/Width attributes actually positional attributes[edit]

I've posted a swf file on our company's wiki (MediaWiki 1.6.10). In attempting to change the height and width of the file, I discovered changing those attributes actually shifted where the file was displayed - increasing the 'width' moved the image to the right, and increasing the 'height' actually moved it down the page. Kinda amusing, but it doesn't help get it sized properly. Any suggestions?


Undefined variable error[edit]

Using version 1.0 Beta, I continually get Undefined variable errors, eight messages for each embedded Flash file, as follows (8 lines shown for each file):

Notice: Undefined variable: gotflashvars in D:\pub\wwwroot\mediawiki\extensions\Flash.php on line 51 PHP
Notice: Undefined variable: gotflashvars in D:\pub\wwwroot\mediawiki\extensions\Flash.php on line 62 PHP
Notice: Undefined variable: gotflashvars in D:\pub\wwwroot\mediawiki\extensions\Flash.php on line 51 PHP
Notice: Undefined variable: gotflashvars in D:\pub\wwwroot\mediawiki\extensions\Flash.php on line 62 PHP
Notice: Undefined variable: gotflashvars in D:\pub\wwwroot\mediawiki\extensions\Flash.php on line 51 PHP
Notice: Undefined variable: gotflashvars in D:\pub\wwwroot\mediawiki\extensions\Flash.php on line 62 PHP
Notice: Undefined variable: gotflashvars in D:\pub\wwwroot\mediawiki\extensions\Flash.php on line 51 PHP
Notice: Undefined property: Flash::$flashvars in D:\pub\wwwroot\mediawiki\extensions\Flash.php on line 108 PHP

Somehow pertains to flashvars, but occurs when I have not even specified any (though the errors occur, as well, if I include that attribute and var/value pairs). Even more oddly, if I include flashvar var/value pair(s), while the Show preview still works, using Save page submits the changes, but returns an empty page.

Byron Canfield

Undefined variable error - continued[edit]

Add:

if(!isset($gotflashvars)) $gotflashvars = Null;

Else use:

<flash>file=flash.swf|width=720|height=540|flashvars=?var1=value1&var2=value2</flash>

Doesn't work on 1.18, 1.19, 1.20[edit]

This very much appreciated extension doesn't work under 1.18 and later versions. Screen remains white or (at best) a black area is visible on the location of the flash video. I would appreciate very very much if you take a look into that-Bert

Strange enough it is now working for filenames without spaces. In case already have swf filenames with spaces, consider the extension AnyWeb as a work around-Bert

I got it to work (with help) in 1.18.1 with the above gotflashvars patch and the following change (while keeping the format file=Example.swf ) in the file Flash.php I replaced the line:

$title = Title::makeTitleSafe("Image",$file)->getFullURL();

with the following line on 1.18:

$title = wfLocalFile(Title::makeTitleSafe("File",$file))->getFullURL();

or on 1.19:

$title = wfLocalFile(Title::makeTitleSafe("File",$file)->getText())->getFullURL();

or on 1.20:

$title = wfLocalFile(Title::makeTitleSafe(NS_FILE,$file)->getText())->getFullURL();

And the method name getTitle could be changed to more appropriate name getURL. Link0ff (talk) 04:08, 28 February 2012 (UTC)Reply

Cached version?[edit]

Since this has been removed for security reasons (I can't argue that for a public wiki), is there a cached version somewhere? I use an internal wiki, thus there is no real security risk to using this plugin. This seems to be the best flash plugin. Any ideas? Google just keeps bringing me back to this page, where it's been removed.