diff --git a/pixelegg/less/svg.css b/pixelegg/less/svg.css new file mode 100644 index 0000000000..b6e7d1f987 --- /dev/null +++ b/pixelegg/less/svg.css @@ -0,0 +1,7 @@ +* { + fill: #ff0000; +} + +svg#etemplate_navbar * { + fill: #0000ff; +} \ No newline at end of file diff --git a/pixelegg/stylesheet2svg.php b/pixelegg/stylesheet2svg.php new file mode 100755 index 0000000000..45856f406b --- /dev/null +++ b/pixelegg/stylesheet2svg.php @@ -0,0 +1,72 @@ +#!/usr/bin/php + + * @copyright (c) 2014 by Ralf Becker + * @version $Id$ + */ + +if (php_sapi_name() !== 'cli') die("This is a commandline ONLY tool!\n"); + +$args = $_SERVER['argv']; +$prog = array_shift($args); + +if ($_SERVER['argc'] <= 1 || $prog != 'pixelegg/stylesheet2svg.php') die(" +Usage: pixelegg/stylesheet2svg [-s stylesheet] svg-image(s) +Add an external stylesheet to an svg image and sets id of svg tag to app_image +Examples: +- pixelegg/stylesheet2svg -s pixelegg/less/svg.css */templates/pixelegg/images/*.svg pixelegg/images/*.svg +\n"); + +$stylesheet = 'pixelegg/less/svg.css'; +if ($args[0] == '-s') +{ + $stylesheet = $args[1]; + array_shift($args); + array_shift($args); +} + +foreach($args as $path) +{ + if (!preg_match('|^([^/]+)/.*/(.*).svg$|', $path, $matches) || !($svg = file_get_contents($path))) + { + die("SVG image $path NOT found!\n"); + } + // remove evtl. existing old stylesheet + $svg = preg_replace("|\n|", '', $svg); + // add stylesheet + $style_url = rel_path($stylesheet, $path); + $svg = preg_replace('|'."\n".' $i_part) + { + if (isset($s_parts[$n]) && $s_parts[$n] === $i_part) + { + array_shift($rel_parts); + } + else + { + array_unshift($rel_parts, '..'); + } + } + $rel_path = implode('/', $rel_parts); + //error_log(__FUNCTION__."($stylesheet, $image) returned $rel_path"); + return $rel_path; +} \ No newline at end of file