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)

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 -

      