fix problems with ini handling in svg dispatch

This commit is contained in:
Andreas Gohr 2017-02-21 13:03:41 +01:00
commit e988c1764f

17
svg.php
View file

@ -125,11 +125,12 @@ class SVG {
* Generate and output * Generate and output
*/ */
public function out() { public function out() {
global $conf;
$file = $this->file; $file = $this->file;
$params = $this->getParameters(); $params = $this->getParameters();
header('Content-Type: image/svg+xml'); header('Content-Type: image/svg+xml');
$cachekey = md5($file . serialize($params) . filemtime(__FILE__)); $cachekey = md5($file . serialize($params) . $conf['template'] . filemtime(__FILE__));
$cache = new \cache($cachekey, '.svg'); $cache = new \cache($cachekey, '.svg');
$cache->_event = 'SVG_CACHE'; $cache->_event = 'SVG_CACHE';
@ -250,8 +251,8 @@ class SVG {
* @param string $color * @param string $color
* @return string * @return string
*/ */
protected function fixColor($color, $ini = true) { protected function fixColor($color) {
if($color === '') return '';
if(preg_match('/^([0-9a-f])([0-9a-f])([0-9a-f])$/i', $color, $m)) { if(preg_match('/^([0-9a-f])([0-9a-f])([0-9a-f])$/i', $color, $m)) {
$r = hexdec($m[1] . $m[1]); $r = hexdec($m[1] . $m[1]);
$g = hexdec($m[2] . $m[2]); $g = hexdec($m[2] . $m[2]);
@ -267,11 +268,9 @@ class SVG {
$a = hexdec('ff'); $a = hexdec('ff');
} }
} else { } else {
if($ini) { if(is_null($this->replacements)) $this->initReplacements();
if(!$this->replacements) $this->initReplacements(); if(isset($this->replacements[$color])) {
if(isset($this->replacements[$color])) { return $this->replacements[$color];
return $this->replacements[$color];
}
} }
return ''; return '';
} }
@ -316,7 +315,7 @@ class SVG {
global $conf; global $conf;
define('SIMPLE_TEST', 1); // hacky shit define('SIMPLE_TEST', 1); // hacky shit
include DOKU_INC . 'lib/exe/css.php'; include DOKU_INC . 'lib/exe/css.php';
$ini = css_styleini($conf['tpl']); $ini = css_styleini($conf['template']);
$this->replacements = $ini['replacements']; $this->replacements = $ini['replacements'];
} }
} }