diff options
author | Andreas Gohr <andi@splitbrain.org> | 2008-03-10 21:16:30 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2008-03-10 21:16:30 +0100 |
commit | 124af657c8d7563757e72334573c08aec6457680 (patch) | |
tree | 826655330bbc3d403f89594875aa1b2d0aac5d35 /lib/exe/css.php | |
parent | b65e3b9fe4b5cfcf50be37ec6f33146579ee4e3c (diff) | |
download | rpg-124af657c8d7563757e72334573c08aec6457680.tar.gz rpg-124af657c8d7563757e72334573c08aec6457680.tar.bz2 |
allow dynamic passing of template to use for css.php
This patch makes it possible to pass the template name to use to the
lib/exe/css.php dispatcher. When passed the $conf['template'] option is
ignored by the disaptcher and the given template is used instead.
This makes it possible to switch templates dynamically without loosing the
CSS dispatcher functionality. This might be useful for things like the
multitemplate template or for loading a template based on the user agent.
darcs-hash:20080310201630-7ad00-2062fa939b1f868540031ea42a42e948dd82bbb4.gz
Diffstat (limited to 'lib/exe/css.php')
-rw-r--r-- | lib/exe/css.php | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/lib/exe/css.php b/lib/exe/css.php index e550ab206..11ae2e828 100644 --- a/lib/exe/css.php +++ b/lib/exe/css.php @@ -41,15 +41,24 @@ function css_out(){ break; } + $tpl = trim(preg_replace('/[^\w]+/','',$_REQUEST['t'])); + if($tpl){ + $tplinc = DOKU_INC.'lib/tpl/'.$tpl.'/'; + $tpldir = DOKU_BASE.'lib/tpl/'.$tpl.'/'; + }else{ + $tplinc = DOKU_TPLINC; + $tpldir = DOKU_TPL; + } + // The generated script depends on some dynamic options - $cache = getCacheName('styles'.DOKU_BASE.$conf['template'].$style,'.css'); + $cache = getCacheName('styles'.DOKU_BASE.$tplinc.$style,'.css'); // load template styles $tplstyles = array(); - if(@file_exists(DOKU_TPLINC.'style.ini')){ - $ini = parse_ini_file(DOKU_TPLINC.'style.ini',true); + if(@file_exists($tplinc.'style.ini')){ + $ini = parse_ini_file($tplinc.'style.ini',true); foreach($ini['stylesheets'] as $file => $mode){ - $tplstyles[$mode][DOKU_TPLINC.$file] = DOKU_TPL; + $tplstyles[$mode][$tplinc.$file] = $tpldir; } } @@ -80,7 +89,7 @@ function css_out(){ // check cache age & handle conditional request header('Cache-Control: public, max-age=3600'); header('Pragma: public'); - if(css_cacheok($cache,array_keys($files))){ + if(css_cacheok($cache,array_keys($files),$tplinc)){ http_conditionalRequest(filemtime($cache)); if($conf['allowdebug']) header("X-CacheUsed: $cache"); readfile($cache); @@ -106,7 +115,7 @@ function css_out(){ ob_end_clean(); // apply style replacements - $css = css_applystyle($css); + $css = css_applystyle($css,$tplinc); // compress whitespace and comments if($conf['compress']){ @@ -125,7 +134,7 @@ function css_out(){ * * @author Andreas Gohr <andi@splitbrain.org> */ -function css_cacheok($cache,$files){ +function css_cacheok($cache,$files,$tplinc){ if($_REQUEST['purge']) return false; //support purge request $ctime = @filemtime($cache); @@ -134,7 +143,7 @@ function css_cacheok($cache,$files){ // some additional files to check $files[] = DOKU_CONF.'dokuwiki.php'; $files[] = DOKU_CONF.'local.php'; - $files[] = DOKU_TPLINC.'style.ini'; + $files[] = $tplinc.'style.ini'; $files[] = __FILE__; // now walk the files @@ -152,9 +161,9 @@ function css_cacheok($cache,$files){ * * @author Andreas Gohr <andi@splitbrain.org> */ -function css_applystyle($css){ - if(@file_exists(DOKU_TPLINC.'style.ini')){ - $ini = parse_ini_file(DOKU_TPLINC.'style.ini',true); +function css_applystyle($css,$tplinc){ + if(@file_exists($tplinc.'style.ini')){ + $ini = parse_ini_file($tplinc.'style.ini',true); $css = strtr($css,$ini['replacements']); } return $css; |