From 07bf32b240a999581627aadcc58c044a577dc62a Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 16 Jan 2009 18:41:40 +0100 Subject: new html_flashobject() function for simple and XHTML valid flash embeds darcs-hash:20090116174140-7ad00-4eb1fe3269d10cb21819a5b220484b7114cbb4de.gz --- inc/html.php | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) (limited to 'inc/html.php') 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 + * @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 array $flashvars - parameters to be passed in the flashvar parameter + * @param array $atts - additional attributes for the 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 .= ''.NL; + $out .= ''.NL; + $out .= ''.NL; + $out .= ''.NL; + + // print params + if(is_array($params)) foreach($params as $key => $val){ + $out .= ' '.NL; + } + + // add flashvars + if(is_array($flashvars)){ + $out .= ' '.NL; + } + + // alternative content + if($alt){ + $out .= $alt.NL; + }else{ + $out .= $lang['noflash'].NL; + } + + // finish + $out .= ''.NL; + $out .= ''.NL; + + return $out; +} + //Setup VIM: ex: et ts=2 enc=utf-8 : -- cgit v1.2.3