From: Reini U. <ru...@us...> - 2004-09-26 17:09:33
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3866 Modified Files: WikiPluginCached.php HtmlElement.php Log Message: add SVG support for Ploticus (and hopefully all WikiPluginCached types) SWF not yet. Index: WikiPluginCached.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/WikiPluginCached.php,v retrieving revision 1.14 retrieving revision 1.15 diff -u -2 -b -p -d -r1.14 -r1.15 --- WikiPluginCached.php 25 Sep 2004 16:26:08 -0000 1.14 +++ WikiPluginCached.php 26 Sep 2004 17:09:23 -0000 1.15 @@ -33,9 +33,16 @@ require_once "lib/WikiPlugin.php"; @require_once('Cache.php'); +// types: define('PLUGIN_CACHED_HTML', 0); // cached html (extensive calculation) define('PLUGIN_CACHED_IMG_INLINE', 1); // gd images -define('PLUGIN_CACHED_IMG_ONDEMAND', 2); // don't cache -define('PLUGIN_CACHED_MAP', 4); // area maps -define('PLUGIN_CACHED_STATIC', 8); // make it available via /uploads/, not via /getimg.php?id= +define('PLUGIN_CACHED_MAP', 2); // area maps +define('PLUGIN_CACHED_SVG', 3); // special SVG/SVGZ object +define('PLUGIN_CACHED_SVG_PNG', 4); // special SVG/SVGZ object with PNG fallback +define('PLUGIN_CACHED_SWF', 5); // special SWF (flash) object +define('PLUGIN_CACHED_PDF', 6); // special PDF object (inlinable?) +define('PLUGIN_CACHED_PS', 7); // special PS object (inlinable?) +// boolean tests: +define('PLUGIN_CACHED_IMG_ONDEMAND', 64); // don't cache +define('PLUGIN_CACHED_STATIC', 128); // make it available via /uploads/, not via /getimg.php?id= /** @@ -204,4 +211,36 @@ class WikiPluginCached extends WikiPlugi } break; + case PLUGIN_CACHED_SVG: + if (!$content || !$content['html'] ) { + $do_save = $this->produceImage($content, $this, $dbi, $sortedargs, $request, 'html'); + if ($this->_static) $url = $content['url']; + $args = array(); //width+height => object args + if (!empty($sortedargs['width'])) $args['width'] = $sortedargs['width']; + if (!empty($sortedargs['height'])) $args['height'] = $sortedargs['height']; + $content['html'] = $do_save + ? $this->embedObject($url, 'image/svg+xml', $args, + HTML::embed(array_merge( + array('src'=>$url, 'type'=>'image/svg+xml'), + $args))) + : false; + } + break; + case PLUGIN_CACHED_SVG_PNG: + if (!$content || !$content['html'] ) { + $do_save_svg = $this->produceImage($content, $this, $dbi, $sortedargs, $request, 'html'); + if ($this->_static) $url = $content['url']; + // hack alert! somehow we should know which argument will produce the secondary image (PNG) + $args = $sortedargs; + $args[$this->pngArg()] = $content['imagetype']; // default type: PNG or GIF + $do_save = $this->produceImage($pngcontent, $this, $dbi, $args, $request, $content['imagetype']); + $args = array(); //width+height => object args + if (!empty($sortedargs['width'])) $args['width'] = $sortedargs['width']; + if (!empty($sortedargs['height'])) $args['height'] = $sortedargs['height']; + $content['html'] = $do_save_svg + ? $this->embedObject($url, 'image/svg+xml', $args, + $this->embedImg($pngcontent['url'], $dbi, $sortedargs, $request)) + : false; + } + break; } if ($do_save) { @@ -407,4 +446,29 @@ class WikiPluginCached extends WikiPlugi } + /** + * svg?, swf, ... + <object type="audio/x-wav" standby="Loading Audio" data="example.wav"> + <param name="src" value="example.wav" valuetype="data"></param> + <param name="autostart" value="false" valuetype="data"></param> + <param name="controls" value="ControlPanel" valuetype="data"></param> + <a href="example.wav">Example Audio File</a> + </object> + * See http://www.protocol7.com/svg-wiki/?EmbedingSvgInHTML + <object data="sample.svgz" type="image/svg+xml" + width="400" height="300"> + <embed src="sample.svgz" type="image/svg+xml" + width="400" height="300" /> + <p>Alternate Content like <img src="" /></p> + </object> + */ + // how to handle alternate images? always provide alternate static images? + function embedObject($url, $type, $args = false, $params = false) { + if (!$args) $args = array(); + $object = HTML::object(array_merge($args, array('src' => $url, 'type' => $type))); + if ($params) + $object->pushContent($params); + return $object; + } + // -------------------------------------------------------------------------- @@ -644,5 +708,5 @@ class WikiPluginCached extends WikiPlugi $plugin->resetError(); $content['html'] = $imagehandle = false; - if ($plugin->getPluginType() & PLUGIN_CACHED_MAP ) { + if ($plugin->getPluginType() == PLUGIN_CACHED_MAP ) { list($imagehandle,$content['html']) = $plugin->getMap($dbi, $argarray, $request); } else { @@ -667,4 +731,9 @@ class WikiPluginCached extends WikiPlugi if ($this->_static) { $ext = "." . $content['imagetype']; + if (is_string($imagehandle) and file_exists($imagehandle)) { + if (preg_match("/.(\w+)$/",$imagehandle,$m)) { + $ext = "." . $m[1]; + } + } $tmpfile = tempnam(getUploadFilePath(), PLUGIN_CACHED_FILENAME_PREFIX . $ext); if (!strstr(basename($tmpfile), $ext)) { @@ -673,10 +742,19 @@ class WikiPluginCached extends WikiPlugi } $tmpfile = getUploadFilePath() . basename($tmpfile); + if (is_string($imagehandle) and file_exists($imagehandle)) { + rename($imagehandle, $tmpfile); + } } else { $tmpfile = $this->tempnam(); } + if (is_resource($imagehandle)) { $this->writeImage($content['imagetype'], $imagehandle, $tmpfile); ImageDestroy($imagehandle); - sleep(1); + sleep(0.2); + } elseif (is_string($imagehandle)) { + $content['file'] = getUploadFilePath() . basename($tmpfile); + $content['url'] = getUploadDataPath() . basename($tmpfile); + return true; + } if (file_exists($tmpfile)) { $fp = fopen($tmpfile,'rb'); @@ -694,5 +772,11 @@ class WikiPluginCached extends WikiPlugi } return false; - } // produceImage + } + + function staticUrl ($tmpfile) { + $content['file'] = $tmpfile; + $content['url'] = getUploadDataPath() . basename($tmpfile); + return $content; + } function tempnam($prefix = false) { @@ -1006,4 +1090,8 @@ class WikiPluginCached extends WikiPlugi // $Log$ +// Revision 1.15 2004/09/26 17:09:23 rurban +// add SVG support for Ploticus (and hopefully all WikiPluginCached types) +// SWF not yet. +// // Revision 1.14 2004/09/25 16:26:08 rurban // some plugins use HTML Index: HtmlElement.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/HtmlElement.php,v retrieving revision 1.41 retrieving revision 1.42 diff -u -2 -b -p -d -r1.41 -r1.42 --- HtmlElement.php 5 Aug 2004 17:31:50 -0000 1.41 +++ HtmlElement.php 26 Sep 2004 17:09:23 -0000 1.42 @@ -391,4 +391,12 @@ class HTML extends HtmlElement { return $el->_init2(func_get_args()); } + function object (/*...*/) { + $el = new HtmlElement('object'); + return $el->_init2(func_get_args()); + } + function embed (/*...*/) { + $el = new HtmlElement('embed'); + return $el->_init2(func_get_args()); + } } @@ -405,5 +413,5 @@ HTML::_setTagProperty(HTMLTAG_ACCEPTS_IN . 's strike u ' // (deprecated) . 'abbr acronym cite code dfn em kbd samp strong var ' //%phrase - . 'a img object br script map q sub sup span bdo '//%special + . 'a img object embed br script map q sub sup span bdo '//%special . 'button input label option select textarea ' //%formctl @@ -522,4 +530,8 @@ function IfJavaScript($if_content = fals /** $Log$ + Revision 1.42 2004/09/26 17:09:23 rurban + add SVG support for Ploticus (and hopefully all WikiPluginCached types) + SWF not yet. + Revision 1.41 2004/08/05 17:31:50 rurban more xhtml conformance fixes |