Difference between revisions of "Swf.php"
(General todo outline) |
|||
Line 1: | Line 1: | ||
<? | <? | ||
+ | # SWF Compiler for XmlWiki Environment | ||
+ | |||
+ | #todo: get w,h,bg,fps,params,output-method from properties | ||
+ | |||
+ | #todo: create basic object set: square, circle, triangle, linear, radial | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
# Check weather required extentions are available (GD2 and Ming) | # Check weather required extentions are available (GD2 and Ming) | ||
global $xwDebug; | global $xwDebug; |
Revision as of 04:19, 15 March 2006
<?
- SWF Compiler for XmlWiki Environment
- todo: get w,h,bg,fps,params,output-method from properties
- todo: create basic object set: square, circle, triangle, linear, radial
- Check weather required extentions are available (GD2 and Ming)
global $xwDebug; $ext = get_loaded_extensions(); if (!in_array('gd', $ext)) xwMessage("Warning: GD extention not loaded! (image processing unavailable)",'red'); else { $gdi = gd_info(); ereg('([0-9])([0-9.]+)', $gdi['GD Version'], $m); if ($xwDebug) xwMessage("GD Version is $m[1]$m[2]"); if ($m[1] < 2) xwMessage("Warning: At least GD version 2 required (image processing unavailable)",'red'); } if (!in_array('ming', $ext)) xwMessage("Ming extention not loaded! (at least version 0.3 required)",'red'); elseif ($xwDebug) xwMessage("Ming extention ok.");
- Override <language> in properties object to 'raw' so no wiki-parsing
$node = $properties->create_element('language'); $node->set_content('raw'); $root = $properties->document_element(); $lang = xwXPathQuery($properties, "/properties/language"); if (is_array($lang) && count($lang)) $lang[0]->replace_node($node); else $root->append_child($node);
- Get compile parameters from properties object
$output = count($results = xwXPathQuery($properties, "$path/output")) ? $results[0]->get_content() : 'html'; $width = count($results = xwXPathQuery($properties, "$path/width")) ? $results[0]->get_content() : 200; $height = count($results = xwXPathQuery($properties, "$path/height")) ? $results[0]->get_content() : 150; $frameRate = count($results = xwXPathQuery($properties, "$path/frameRate")) ? $results[0]->get_content() : 25; $bg = count($results = xwXPathQuery($properties, "$path/background")) ? $results[0]->get_content() : '#cccccc'; eregi('^#([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])$',$bg,$m); list(,$r,$g,$b) = $m;
- Create new SWF
ming_useswfversion(6); $swf = new SWFMovie(); $swf->setDimension($width, $height); $swf->setBackground(hexdec($r), hexdec($g), hexdec($b)); $swf->setRate($frameRate); if ($xwDebug) xwMessage("SWF movie created ($width"."x$height@$frameRate"."fps)");
- If output is html embed object as url, else output swf now and die
if ($output == 'html') { $url = "$script?title=$title&xpath:/properties/ming-swf/output:=swf"; $article = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\" width=\"$width\" height=\"$height\" id=\"$title\" align=\"\" type=\"application/x-shockwave-flash\" data=\"$title\"> <param name=\"movie\" value=\"$title\"> <param name=\"quality\" value=\"high\"> <param name=\"bgcolor\" value=\"$bg\"> <embed src=\"$url\" quality=\"high\" bgcolor=\"$bg\" width=\"$width\" height=\"$height\" align=\"\" name=\"$title\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /> </object>"; } else { eval($article); ob_end_clean(); header('Content-Type: application/x-shockwave-flash'); $swf->output(9); die(); }
?>