Flash detection and embedding JavaScript. The syntax is [kml_flashembed movie="filename.swf" height="250" width="400" /].
Version: 1.4
Author: Michael Bester
Author URI: http://www.kimili.com
Update: http://www.kimili.com/plugins/kml_flashembed/wp
*/
/*
*
* KIMILI FLASH EMBED
*
* Copyright 2007 Michael Bester (http://www.kimili.com)
* Released under the GNU General Public License (http://www.gnu.org/licenses/gpl.html)
*
*/
/***********************************************************************
* Global Vars
************************************************************************/
$kml_request_type = "";
$kml_flashembed_ver = "1.4";
/***********************************************************************
* Load Dependencies
************************************************************************/
require_once('buttonsnap.php');
/***********************************************************************
* Run the main function
************************************************************************/
function kml_flashembed($content) {
$pattern = '/(
[\s\n\r]*)??(([\[<]KML_(FLASH|SWF)EMBED.*\/[\]>])|([\[<]KML_(FLASH|SWF)EMBED.*[\]>][\[<]\/KML_(FLASH|SWF)EMBED[\]>]))([\s\n\r]*<\/p>)??/Umi';
$result = preg_replace_callback($pattern,'kml_flashembed_parse_kfe_tags',$content);
return $result;
}
/***********************************************************************
* Parse out the KFE Tags
************************************************************************/
function kml_flashembed_parse_kfe_tags($match) {
$r = "";
# Clean up and untexturize tag
$strip = array('[KML_FLASHEMBED',
'][/KML_FLASHEMBED]',
'[kml_flashembed',
'][/kml_flashembed]',
'[KML_SWFEMBED',
'][/KML_SWFEMBED]',
'[kml_swfembed',
'][/kml_swfembed]',
'/]',
'',
'',
'',
'',
'/>',
'\n',
' ',
' ',
'
',
'
'
);
$elements = str_replace($strip, '', $match[0]);
$elements = preg_replace("/=(\s*)\"/", "==`", $elements);
$elements = preg_replace("/=(\s*)″/", "==`", $elements);
$elements = preg_replace("/=(\s*)′/", "==`", $elements);
$elements = preg_replace("/=(\s*)”/", "==`", $elements);
$elements = preg_replace("/\"(\s*)/", "`| ", $elements);
$elements = preg_replace("/″(\s*)/", "`|", $elements);
$elements = preg_replace("/′(\s*)/", "`|", $elements);
$elements = preg_replace("/”(\s*)/", "`|", $elements);
$elements = preg_replace("/″(\s*)/", "`|", $elements);
$elements = preg_replace("/‘(\s*)/", "'", $elements);
$elements = preg_replace("/’(\s*)/", "'", $elements);
$attpairs = preg_split('/\|/', $elements, -1, PREG_SPLIT_NO_EMPTY);
$atts = array();
// Create an associative array of the attributes
for ($x = 0; $x < count($attpairs); $x++) {
$attpair = explode('==', $attpairs[$x]);
$attn = trim(strtolower($attpair[0]));
$attv = preg_replace("/`/", "", trim($attpair[1]));
$atts[$attn] = $attv;
}
if (isset($atts['movie']) && isset($atts['height']) && isset($atts['width'])) {
$atts['fversion'] = (isset($atts['fversion'])) ? $atts['fversion'] : 8;
if (isset($atts['fvars'])) {
$fvarpair_regex = "/(?", $atts['alttext']) : '';
// If we're not serving up a feed, generate the script tags
if ($GLOBALS['kml_request_type'] != "feed") {
$r = kml_flashembed_build_fo_script($atts);
} else {
$r = kml_flashembed_build_object_tag($atts);
}
}
return $r;
}
/***********************************************************************
* Build the Javascript from the tags
************************************************************************/
function kml_flashembed_build_fo_script($atts) {
if (is_array($atts)) extract($atts);
$out = array();
$ret = "";
$rand = mt_rand(); // For making sure this instance is unique
// Extract the filename minus the extension...
$swfname = (strrpos($movie, "/") === false) ?
$movie :
substr($movie, strrpos($movie, "/") + 1, strlen($movie));
$swfname = (strrpos($swfname, ".") === false) ?
$swfname :
substr($swfname, 0, strrpos($swfname, "."));
// ... to use as a default ID if an ID is not defined.
$fid = (isset($fid)) ? $fid : "fm_" . $swfname . "_" . $rand;
//echo("clickomg:"+$clickimg);// = '"data/logga/supertryck3_small.jpg"';
// ... as well as an empty target if that isn't defined.
if (empty($target)) {
$targname = "so_targ_" . $swfname . "_" . $rand;
$classname = (empty($targetclass)) ? "flashmovie" : $targetclass;
// Create a target div
if (isset($clickimg)) $out[] = '