From: <ru...@us...> - 2009-10-13 06:58:45
|
Revision: 7208 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=7208&view=rev Author: rurban Date: 2009-10-13 06:58:34 +0000 (Tue, 13 Oct 2009) Log Message: ----------- Standardize Video plugin to use ImgObject() for embedded objects. Check arguments. Support hash as ImgObject argument not to split sensitive (support spaces in args). Modified Paths: -------------- trunk/lib/plugin/Video.php trunk/lib/stdlib.php Modified: trunk/lib/plugin/Video.php =================================================================== --- trunk/lib/plugin/Video.php 2009-10-13 06:15:17 UTC (rev 7207) +++ trunk/lib/plugin/Video.php 2009-10-13 06:58:34 UTC (rev 7208) @@ -2,6 +2,7 @@ rcs_id('$Id$'); /* * Copyright 2009 Roger Guignard and Marc-Etienne Vargenau, Alcatel-Lucent + * Copyright 2009 Reini Urban * * This file is part of PhpWiki. * @@ -59,11 +60,12 @@ } function getDefaultArguments() { - return array('width' => 460, - 'height' => 320, - 'url' => '', - 'file' => '', + return array('width' => 460, + 'height' => 320, + 'url' => '', + 'file' => '', 'autoplay' => 'false' + 'image' => '', ); } @@ -76,74 +78,35 @@ if (! $url && ! $file) { return $this->error(_("Both 'url' or 'file' parameters missing.")); } elseif ($url && $file) { - return $this->error(_("Choose only one of 'url' or 'page' parameters.")); + return $this->error(_("Choose only one of 'url' or 'file' parameters.")); } elseif ($file) { - // $url = SERVER_URL . getUploadDataPath() . '/' . $file; - $url = getUploadDataPath() . '/' . $file; + $url = getUploadDataPath() . $file; } + // TODO: Check HTML5 browser capabilities if (string_ends_with($url, ".ogg")) { return HTML::video(array('autoplay' => 'true', 'controls' => 'true', 'src' => $url), _("Your browser does not understand the HTML 5 video tag.")); } + if (!$image) $image = $url; + if ($autoplay != 'true' and $autoplay != 'false') + return $this->error(fmt("Invalid argument %s", "autoplay")); + if (!is_numeric($width)) + return $this->error(fmt("Invalid argument %s", "width")); + if (!is_numeric($height)) + return $this->error(fmt("Invalid argument %s", "height")); + if (preg_match("/'/", $url)) + return $this->error(fmt("Invalid argument %s", "url")); - $html = HTML(); - - if (isBrowserIE()) { - $object = HTML::object(array('id' => 'flowplayer', - 'classid' => 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000', - 'width' => $width, - 'height' => $height)); - - $param = HTML::param(array('name' => 'movie', - 'value' => SERVER_URL . $WikiTheme->_findData('flowplayer-3.1.3.swf'))); - $object->pushContent($param); - - $param = HTML::param(array('name' => "allowfullscreen", - 'value' => "true")); - $object->pushContent($param); - - $param = HTML::param(array('name' => "allowscriptaccess", - 'value' => "false")); - $object->pushContent($param); - - $flashvars = "config={'clip':{'url':'" . $url . "','autoPlay':" . $autoplay . "}}"; - - $param = HTML::param(array('name' => 'flashvars', - 'value' => $flashvars)); - $object->pushContent($param); - - $embed = HTML::embed(array('type' => 'application/x-shockwave-flash', - 'width' => $width, - 'height' => $height, - 'src' => SERVER_URL . $WikiTheme->_findData('flowplayer-3.1.3.swf'), - 'flashvars' => $flashvars)); - $object->pushContent($embed); - - $html->pushContent($object); - - } else { - $object = HTML::object(array('data' => SERVER_URL . $WikiTheme->_findData('flowplayer-3.1.3.swf'), - 'type' => "application/x-shockwave-flash", - 'width' => $width, - 'height' => $height)); - - $param = HTML::param(array('name' => "allowfullscreen", - 'value' => "true")); - $object->pushContent($param); - - $param = HTML::param(array('name' => "allowscriptaccess", - 'value' => "false")); - $object->pushContent($param); - - $value = "config={'clip':{'url':'" . $url . "','autoPlay':" . $autoplay . "}}"; - $param = HTML::param(array('name' => "flashvars", - 'value' => $value)); - $object->pushContent($param); - - $html->pushContent($object); - } - return $html; + $params = array("data" => SERVER_URL . $WikiTheme->_findData('flowplayer-3.1.3.swf'), + "type" => "application/x-shockwave-flash", + "width" => $width, + "height" => $height, + "allowfullscreen" => "true", + "allowscriptaccess" => "false", + "flashvars"=> + "config={'clip':{'url':'" . $url . "','autoPlay':" . $autoplay . "}}'"); + return ImgObject(HTML::img(array('src' => $image)), $params); } }; Modified: trunk/lib/stdlib.php =================================================================== --- trunk/lib/stdlib.php 2009-10-13 06:15:17 UTC (rev 7207) +++ trunk/lib/stdlib.php 2009-10-13 06:58:34 UTC (rev 7208) @@ -601,29 +601,58 @@ */ function ImgObject($img, $url) { // get the url args: data="sample.svgz" type="image/svg+xml" width="400" height="300" - $args = split(' ', $url); - $params = array(); - if (count($args) >= 1) { - $url = array_shift($args); - $found = array(); - foreach ($args as $attr) { - foreach (explode(",","data,classid,archive,codebase,name,usemap,type,". - "codetype,standby,tabindex,declare") as $param) - { + $params = explode(",","data,classid,archive,codebase,name,usemap,type,". + "codetype,standby,tabindex,declare"); + if (is_array($url)) { + $args = $url; + $found = array(); + foreach ($args as $attr => $value) { + foreach ($params as $param) { + if ($param == $attr) { + $img->setAttr($param, $value); + if (isset($found[$param])) $found[$param]++; + else $found[$param] = 1; + break; + } + } + } + // now all remaining args are added as <param> to the object + $params = array(); + foreach ($args as $attr => $value) { + if (!isset($found[$attr])) { + $params[] = HTML::param(array('name' => $attr, + 'value' => $value)); + } + } + $url = $img->getAttr('src'); + $force_img = "png|jpg|gif|jpeg|bmp"; + if (!preg_match("/\.(".$force_img.")/i", $url)) { + $img->setAttr('src', false); + } + } else { + $args = split(' ', $url); + if (count($args) >= 1) { + $url = array_shift($args); + $found = array(); + foreach ($args as $attr) { + foreach ($params as $param) { if (preg_match("/^$param=(\S+)$/i",$attr,$m)) { $img->setAttr($param, $m[1]); - $found[$attr]++; + if (isset($found[$param])) $found[$param]++; + else $found[$param] = 1; break; } } } - // now all remaing args are added as <param> to the object + // now all remaining args are added as <param> to the object + $params = array(); foreach ($args as $attr) { - if (!$found[$attr] and preg_match("/^(\S+)=(\S+)$/i",$attr,$m)) { + if (!isset($found[$attr]) and preg_match("/^(\S+)=(\S+)$/i",$attr,$m)) { $params[] = HTML::param(array('name' => $m[1], 'value' => $m[2])); } } + } } $type = $img->getAttr('type'); if (!$type) { @@ -631,13 +660,14 @@ if (function_exists('mime_content_type')) $type = mime_content_type($url); } - $object = HTML::object(array_merge($img->_attr, array('src' => $url, 'type' => $type)), + $object = HTML::object(array_merge($img->_attr, + array('type' => $type)), //'src' => $url $img->_content); $object->setAttr('class', 'inlineobject'); if ($params) { foreach ($params as $param) $object->pushContent($param); } - if (isBrowserSafari()) { + if (isBrowserSafari() and !isBrowserSafari(532)) { // recent chrome can do OBJECT return HTML::embed($object->_attr, $object->_content); } $object->pushContent(HTML::embed($object->_attr)); @@ -1235,7 +1265,7 @@ $RE[] = "/(?<= |${sep}|^)([AI])([[:upper:]][[:lower:]])/"; break; case 'fr': - $RE[] = "/(?<= |${sep}|^)([À])([[:upper:]][[:lower:]])/"; + $RE[] = "/(?<= |${sep}|^)([\xC3])([[:upper:]][[:lower:]])/"; break; } // Split at underscore @@ -2622,7 +2652,7 @@ function strip_accents($text) { $res = utf8_decode($text); $res = strtr($res, - utf8_decode('àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ'), + utf8_decode('\xC3áâãäçèéêëìíîïñòóôõöùúûüýÿ\xC3\xC3?ÂÃÄÇÈÉÊËÌ\xC3?Î\xC3?ÑÒÓÔÕÖÙÚÛÜ\xC3?'), 'aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY'); return utf8_encode($res); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |