From 0e6f9f08b1c948f45d1867346a4502021afa55bc Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Sun, 7 Oct 2012 15:30:38 +0100 Subject: added support for local style.ini files --- lib/exe/css.php | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'lib/exe/css.php') diff --git a/lib/exe/css.php b/lib/exe/css.php index 8899ff193..dd69c94cf 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -49,14 +49,17 @@ function css_out(){ $tpldir = tpl_basedir(); } + // used style.ini file + $styleini = css_styleini($tplinc); + // The generated script depends on some dynamic options $cache = new cache('styles'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'].DOKU_BASE.$tplinc.$type,'.css'); // load template styles $tplstyles = array(); - if(@file_exists($tplinc.'style.ini')){ - $ini = parse_ini_file($tplinc.'style.ini',true); - foreach($ini['stylesheets'] as $file => $mode){ + if ($styleini) { + $ini = parse_ini_file($styleini, true); + foreach($ini['stylesheets'] as $file => $mode) { $tplstyles[$mode][$tplinc.$file] = $tpldir; } } @@ -71,7 +74,8 @@ function css_out(){ $files = array(); $cache_files = getConfigFiles('main'); - $cache_files[] = $tplinc.'style.ini'; + if ($styleini) + $cache_files[] = $styleini; $cache_files[] = __FILE__; foreach($mediatypes as $mediatype) { @@ -173,13 +177,26 @@ function css_out(){ * @author Andreas Gohr */ function css_applystyle($css,$tplinc){ - if(@file_exists($tplinc.'style.ini')){ - $ini = parse_ini_file($tplinc.'style.ini',true); + $styleini = css_styleini($tplinc); + + if($styleini){ + $ini = parse_ini_file($styleini,true); $css = strtr($css,$ini['replacements']); } return $css; } +/** + * If either exist, get the template's style.local.ini or style.ini file. + */ +function css_styleini($tplinc) { + if(@file_exists($tplinc.'style.local.ini')) + return $tplinc.'style.local.ini'; + if(@file_exists($tplinc.'style.ini')) + return $tplinc.'style.ini'; + return ''; +} + /** * Prints classes for interwikilinks * -- cgit v1.2.3 From 0ac69508958a06e566a51fb6a74802401ebe5eb5 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Thu, 11 Oct 2012 13:26:47 +0100 Subject: changed local style.ini to be merged with standard one --- lib/exe/css.php | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'lib/exe/css.php') diff --git a/lib/exe/css.php b/lib/exe/css.php index dd69c94cf..ae160558a 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -58,8 +58,7 @@ function css_out(){ // load template styles $tplstyles = array(); if ($styleini) { - $ini = parse_ini_file($styleini, true); - foreach($ini['stylesheets'] as $file => $mode) { + foreach($styleini['stylesheets'] as $file => $mode) { $tplstyles[$mode][$tplinc.$file] = $tpldir; } } @@ -74,8 +73,8 @@ function css_out(){ $files = array(); $cache_files = getConfigFiles('main'); - if ($styleini) - $cache_files[] = $styleini; + $cache_files[] = $tplinc.'style.ini'; + $cache_files[] = $tplinc.'style.local.ini'; $cache_files[] = __FILE__; foreach($mediatypes as $mediatype) { @@ -180,21 +179,31 @@ function css_applystyle($css,$tplinc){ $styleini = css_styleini($tplinc); if($styleini){ - $ini = parse_ini_file($styleini,true); - $css = strtr($css,$ini['replacements']); + $css = strtr($css,$styleini['replacements']); } return $css; } /** - * If either exist, get the template's style.local.ini or style.ini file. + * Get contents of merged style.ini and style.local.ini as an array. + * + * @author Anika Henke */ function css_styleini($tplinc) { - if(@file_exists($tplinc.'style.local.ini')) - return $tplinc.'style.local.ini'; - if(@file_exists($tplinc.'style.ini')) - return $tplinc.'style.ini'; - return ''; + $styleini = array(); + + foreach (array($tplinc.'style.ini', $tplinc.'style.local.ini') as $ini) { + $tmp = (@file_exists($ini)) ? parse_ini_file($ini, true) : array(); + + foreach($tmp as $key => $value) { + if(array_key_exists($key, $styleini) && is_array($value)) { + $styleini[$key] = array_merge($styleini[$key], $tmp[$key]); + } else { + $styleini[$key] = $value; + } + } + } + return $styleini; } /** -- cgit v1.2.3