Extension talk:Flash

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

with wikimedia 1.5 rc4 change the code in flash.php:

to

Not compatible with v1.7.x?
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)


 * 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 ... tag, but instead it coughs this:

Image constructor given bogus title. Backtrace:
 * 1) 0 /home/.xenophon/fatorcao/xug/wiki/extensions/flash.php(95): Image->Image(NULL)
 * 2) 1 /home/.xenophon/fatorcao/xug/wiki/extensions/flash.php(86): Flash->getTitle(NULL)
 * 3) 2 /home/.xenophon/fatorcao/xug/wiki/extensions/flash.php(33): Flash->genCode
 * 4) 3 /home/.xenophon/fatorcao/xug/wiki/extensions/flash.php(108): Flash->Flash('file=swf/unit_s...')
 * 5) 4 /home/.xenophon/fatorcao/xug/wiki/includes/Parser.php(533): renderFlash('file=swf/unit_s...', Array, Object(Parser))
 * 6) 5 /home/.xenophon/fatorcao/xug/wiki/includes/Parser.php(279): Parser->strip('renderFlash', Array)
 * 7) 6 /home/.xenophon/fatorcao/xug/wiki/includes/EditPage.php(1401): Parser->parse('{{P??gina tempo...', Array)
 * 8) 7 /home/.xenophon/fatorcao/xug/wiki/includes/EditPage.php(1244): EditPage->getPreviewText('{{P??gina tempo...', Object(Title), Object(ParserOptions))
 * 9) 8 /home/.xenophon/fatorcao/xug/wiki/includes/EditPage.php(1004): EditPage->showPreview
 * 10) 9 /home/.xenophon/fatorcao/xug/wiki/includes/EditPage.php(379): EditPage->showEditForm
 * 11) 10 /home/.xenophon/fatorcao/xug/wiki/includes/EditPage.php(217): EditPage->edit
 * 12) 11 /home/.xenophon/fatorcao/xug/wiki/includes/Wiki.php(380): EditPage->submit
 * 13) 12 /home/.xenophon/fatorcao/xug/wiki/includes/Wiki.php(50): MediaWiki->performAction
 * 14) 13 /home/.xenophon/fatorcao/xug/wiki/index.php(123): MediaWiki->initialize(Object(OutputPage), Object(Article), Object(Title), Object(User), Object(WebRequest))
 * 15) 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)


 * Hrm.. will have to experiment. We are using PHP 5.1.4 mcl 15:58, 4 September 2006 (UTC)

Trying to understand the code (newbie)
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)


 * 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 ( file=flashfile.swf|... ). 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)

Flashes that only display in preview mode- Solution
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)


 * 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
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)
 * 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)

Question regarding arguments
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)

Notice
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)

Is there a syntax for allowing left - right positioning and wrapping of text?
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)

Flashvars attribute
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&lt;nowiki&gt;= parameter&value2&lt;nowiki&gt;= 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. file=sample.swf|width=800|height=460|flashvars=?arg1=value1&arg2=value2

Patch:

--- extensions/Flash.php	2006-05-21 14:01:37.000000000 -0700 --- 37,64          function parseInput( $input ) { for($pos=0; $postmp .= $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 { --- 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'|| --- 104,117                   $this->version='7,0,0,0'; // Version settings for                   $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 = 'width . '" height="' . $this->height . '" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='. $this->version. '">url. '">' . $this->codeObject . 'url. '" width="'. $this->width. '" height="'. $this->height. '"' . $this->codeEmbed . ' pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"> '; +                                   return $this->code;          }          function getTitle($file) {
 * Flash.php	2006-05-21 14:04:02.000000000 -0700
 * 37,46 ****
 * 37,46 ****
 * 54,59 ****
 * 54,59 ****
 * 85,92 ****
 * 85,92 ****


 * 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)

Security?
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)


 * 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)


 * Uh, I think Phlip had a different view of that. (See the page in question.) The Mu 21:36, 16 August 2006 (UTC)


 * 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?
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.
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)


 * 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
The attribute reference doesn't list any variables for the  and   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:

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

Keep getting Error ?!?!?!
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)

Request: embedding an external flash file
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: ). Please develop new version of the extension in this way. --Yes0song 09:34, 25 March 2007 (UTC)


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

Can Crash this
Enter newlines inside the 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 -

      

FlashVars
I would like to be able to use a defined variable (see Variables Extension) in the list of FlashVars.

For example ... |flashvars=?myVariable=

Unfortunately, the .swf gets something other than the value of myVariable -- probably as a string.

Any thoughts on how to do this?

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

Error Checking
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 extension available on some wikis. --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
 * 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)
 * 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)

Image::__construct is deprecated
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:

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

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


 * 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)

External Files
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
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
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.

[mailto:bcanfield@headsprout.com Byron Canfield]

Undefined variable error - continued
Add:

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

Else use: file=flash.swf|width=720|height=540|flashvars=?var1=value1&var2=value2