I use the svgapureinsert plugin on my Dokuwiki. I had to go searching for it last time because the link was broken as well.
This plugin appears to work in Dokuwiki "Angua" 2012.01.25 quite well for my purposes. (Displaying SVG images / diagrams / Logo.)
I have the original .zip file but I don't see how to attach it to this post on the forum for you.
The zip archive consists of :
- a directory : svgpureInsert
- 3 files in the directory : README.txt, svgpureInsert.php and syntax.php
- the README.txt file indicate it was last modified on January 25, 2009
- the svgpureInsert.php and syntax.php files indicate they were last modified on March 27, 2009
- the last modified date would have been the date when they were put into the .zip archive.
- the code blocks below are from the .zip archive with the same content that I received when I downloaded the plugin.
I will have to post this in two parts as there are more than 10,000 characters in the files.
Contents of syntax.php file to follow...
I hope this helps...
--Brock
README.txt File Contents :
====== svg pureinsert plugin ======
---- plugin ----
description: Inserts a non png or otherwise modified svg file, just its clean version.
author : Leszek Piątek
email : leszek_piatek@poczta.onet.pl
type : syntax
lastupdate : 2008-03-21
compatible : dokuwiki-2007-06-26b
depends :
conflicts :
similar :
tags : svg insert not
----
====== Instalation ======
After downloading plugin extract it and copy all the files to your dokuwiki root folder.
To enable the "media" support edit conf/mime.local.conf and add at the bottom entry:
svg image/svg+xml
If you want to disable cache for SVG files edit lib/plugins/svgpureInsert/svgpureInsert.php:
- define('SVG_CACHE', false); to define('SVG_CACHE', false);
- delete folder: lib/plugins/svgpureInsert/cache
Caching is enabled by default:
- folder lib/plugins/svgpureInsert/cache should have permissions to write
====== Overview ======
My intention was to create plugin which enables using built-in SVG images visualization engine in Firefox, Opera browsers. I just didn't want to have png's or jpg's - I love vector graphics ;)
== Benefits: ==
* image like syntax, so it supports uploading and inserting svg as a media files
* supports dokuwiki align syntax
* **supports resizing !!** - and this is what SVG is about :)
* caching enabled by default
* xhtml 1.0 valid
== Drawbacks ==
* embedded as a iframe - no links available
* tooltip caption is not working (syntax is available) but Firefox is not displaying it
* SVG is supported by FireFox and Opera, NO IE support (haven't checked on IE 7.0)
====== How does it work? ======
- I've created syntax plugin which search for { {file_or_url.svg|description} } it's getSort is lower than media files, so it catch up everything nicely.
- Next step is search the base size of SVG
- When we got base size, we can count the size we want to display, and insert iframe tag to dokuwiki renderer
- We point it to svgpureInsert.php?url={url}&width={w}&height={h} which is used to change, and insert some SVG tags needed to resize the file
- After that when - CACHING is enabled in svgpureInsert.php - we save image in cache and display it as a svg/image+xml mime, when there is no CACHE (default) we just display resized image
svgpureInsert.php File Contents :
<?php
/* LICENSE:
svgpureInsert.php, read and cache svg file, scaling to proper dimension, part of svgpureInsert plugin to dokuWiki
Copyright (C) 2008 Leszek Piątek, leszek_piatek@poczta.onet.pl
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License.
DESCRIPTION:
Read svg $_GET['url'] file and display it as a svg/image+xml mime type, if needed we can cache the result to speed up things a bit.
$_GET MODIFIERS:
url: url of svg to read
width: specified width of svg file
height: specified height of svg file
USAGE:
just point <img scr="svgpureInsert.php?url=encoded_url_or_path&width=200" alt="" />
if only one argument of dimension (width or height) is specified,
we scale image to have specified dimension (second dimension is calculated propotionally)
we can set SVG_CACHE, and SVG_CACHE_DIR if we want to create cache locally (faster loading, no problems with dead links)
*/
// *********** CONFIGURATION: ************* //
define('SVG_ROOT_PATH', '../../../');
define('SVG_CACHE', true); //if you want tu turn on caching set to true
define('SVG_CACHE_DIR', SVG_ROOT_PATH.'lib/plugins/svgpureInsert/cache/'); //relatively to svgpureInsert.php, need to be writable by php (set chmod 755)
// *********** CODE, be sure what you are doing while editing stuff below ************* //
//URL check and other stuff check
if(isset($_GET['url']))
$URL = $_GET['url'];
else
{
echo "There is no file to draw!!!";
exit;
}
$exp = explode('.', $URL);
$exp = end($exp);
if($exp!='svg')
{
echo('You want to read file with non svg extension...');
exit;
}
if(isset($_GET['width']))
$width = $_GET['width'];
else
$width = 0;
if(isset($_GET['height']))
$height = $_GET['height'];
else
$height = 0;
if(!is_numeric($width) || !is_numeric($height))
{
echo('You want to set non numeric width or height...');
exit;
}
//
//did we cache anything?
$cache_file = SVG_CACHE_DIR.md5($URL . '?' . $width . 'x' . $height) . '.svg';
if (!file_exists($cache_file) or !SVG_CACHE)
{
$URL = urldecode($URL);
if (strpos($URL, "http://")===false && strpos($URL, "ftp://")===false)
$URL = SVG_ROOT_PATH . $URL;
$fp = @fopen($URL, 'r');
if ($fp)
{
//PRINT HEADER
header('Content-type: image/svg+xml');
//GET CONTENT
$buff = '';
while (!feof($fp))
{
$buff .= fread($fp, 4096);
}
fclose($fp);
//MODIFY TO PROPER WIDTH AND HEIGHT
if ($width>0 || $height>0)
{
#find main tag
preg_match('#<svg(.*?)>#ism', $buff, $buff_match);
$buff_svg = $buff_match[0];
#remove width attribute
if (preg_match('#[\s]width=[\"]([0-9]++)(\.[0-9]++)??(.*)??[\"][\s]*#iU', $buff_svg, $match))
{
if (!$match[2])
$real_width = $match[1];
else
$real_width = $match[1]+1;
#change mm to pixels
if ($match[3]==='mm')
$real_width = round($real_width*3);
$buff_svg = str_replace($match[0], '', $buff_svg);
}
#remove height attribute
if (preg_match('#[\s]height=[\"]([0-9]++)(\.[0-9]++)??([^\"]*)??[\"][\s]*#iU', $buff_svg, $match))
{
if (!$match[2])
$real_height = $match[1];
else
$real_height = $match[1]+1;
#change mm to pixels
if ($match[3]==='mm')
$real_height = round($real_height*3);
$buff_svg = str_replace($match[0], '', $buff_svg);
}
#remove viewBox attribute
if (preg_match("#viewBox\=\"([^\"]*)\"#i", $buff_svg, $match))
{
if ($match[1])
{
if (strpos($match[1], ',')!==false)
$exp = explode(",", $match[1]);
else
$exp = explode(" ", $match[1]);
$real_width = $exp[2];
$real_height = $exp[3];
}
$buff_svg = str_replace($match[0], '', $buff_svg);
}
#remove preserveAspectRatio=".*"
if (preg_match("#preserveAspectRatio\=[\"]?.*[\"]?#iU", $buff, $match))
$buff = str_replace($match[0], '', $buff);
if ($width==0)
$width = $real_width;
if ($height==0)
$height = $real_height;
$buff_svg = str_replace("<svg", '<svg preserveAspectRatio="none" width="'
. $width . '" height="' . $height . '" viewBox="0 0 '
. $real_width . ' ' . $real_height . '"', $buff_svg);
$buff = str_replace($buff_match[0], $buff_svg, $buff);
exit($buff);
}
//SAVE THE BUFFER TO CACHE
if (SVG_CACHE)
{
$fp = fopen($cache_file, "w");
fwrite($fp, $buff);
fclose($fp);
}
//PRINT BUFFER
echo($buff);
}
else
{
echo('Sorry, but <b>' . $URL . '</b> doesn\'t exist...');
}
}
else
{ //yes we got the cache, so print it immediately
//PRINT HEADER
header('Content-type: image/svg+xml');
$fp = fopen($cache_file, "r");
$buff = fread($fp, filesize($cache_file));
fclose($fp);
//PRINT CACHE
echo($buff);
}
//
?>