diff options
author | Andreas Gohr <andi@splitbrain.org> | 2009-01-16 18:41:40 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2009-01-16 18:41:40 +0100 |
commit | 07bf32b240a999581627aadcc58c044a577dc62a (patch) | |
tree | 3ded7a0950d9b69c4afdec21acaa7c54c094b798 /inc/html.php | |
parent | 883179a4d109b59b43041f979e362f8800a9052f (diff) | |
download | rpg-07bf32b240a999581627aadcc58c044a577dc62a.tar.gz rpg-07bf32b240a999581627aadcc58c044a577dc62a.tar.bz2 |
new html_flashobject() function for simple and XHTML valid flash embeds
darcs-hash:20090116174140-7ad00-4eb1fe3269d10cb21819a5b220484b7114cbb4de.gz
Diffstat (limited to 'inc/html.php')
-rw-r--r-- | inc/html.php | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/inc/html.php b/inc/html.php index 982d01860..43ab397d0 100644 --- a/inc/html.php +++ b/inc/html.php @@ -1434,4 +1434,81 @@ function html_form_output($data) { $data->printForm(); } +/** + * Embed a flash object in HTML + * + * This will create the needed HTML to embed a flash movie in a cross browser + * compatble way using valid XHTML + * + * The parameters $params, $flashvars and $atts need to be associative arrays. + * No escaping needs to be done for them. The alternative content *has* to be + * escaped because it is used as is. If no alternative content is given + * $lang['noflash'] is used. + * + * @author Andreas Gohr <andi@splitbrain.org> + * @link http://latrine.dgx.cz/how-to-correctly-insert-a-flash-into-xhtml + * + * @param string $swf - the SWF movie to embed + * @param int $width - width of the flash movie in pixels + * @param int $height - height of the flash movie in pixels + * @param array $params - additional parameters (<param>) + * @param array $flashvars - parameters to be passed in the flashvar parameter + * @param array $atts - additional attributes for the <object> tag + * @param string $alt - alternative content (is NOT automatically escaped!) + * @returns string - the XHTML markup + */ +function html_flashobject($swf,$width,$height,$params=null,$flashvars=null,$atts=null,$alt=''){ + global $lang; + + $out = ''; + + // prepare the object attributes + if(is_null($atts)) $atts = array(); + $atts['width'] = (int) $width; + $atts['height'] = (int) $heigh; + if(!$atts['width']) $atts['width'] = 425; + if(!$atts['height']) $atts['height'] = 350; + + // add object attributes for standard compliant browsers + $std = $atts; + $std['type'] = 'application/x-shockwave-flash'; + $std['data'] = $swf; + + // add object attributes for IE + $ie = $atts; + $ie['classid'] = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'; + + // open object (with conditional comments) + $out .= '<!--[if !IE]> -->'.NL; + $out .= '<object '.buildAttributes($std).'>'.NL; + $out .= '<!-- <![endif]-->'.NL; + $out .= '<!--[if IE]>'.NL; + $out .= '<object '.buildAttributes($ie).'>'.NL; + $out .= ' <param name="movie" value="'.hsc($swf).'" />'.NL; + $out .= '<!--><!--dgx-->'.NL; + + // print params + if(is_array($params)) foreach($params as $key => $val){ + $out .= ' <param name="'.hsc($key).'" value="'.hsc($val).'" />'.NL; + } + + // add flashvars + if(is_array($flashvars)){ + $out .= ' <param name="flashvars" value="'.hsc(buildURLparams($flashvars)).'" />'.NL; + } + + // alternative content + if($alt){ + $out .= $alt.NL; + }else{ + $out .= $lang['noflash'].NL; + } + + // finish + $out .= '</object>'.NL; + $out .= '<!-- <![endif]-->'.NL; + + return $out; +} + //Setup VIM: ex: et ts=2 enc=utf-8 : |