diff options
author | Andreas Gohr <andi@splitbrain.org> | 2012-01-30 20:38:41 +0100 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2012-01-30 20:38:41 +0100 |
commit | c4766956646b53ab644ec6ddbd17d9cba07cf872 (patch) | |
tree | 9162023353305dc55770c05b0e3d094e1b4a2eaf /inc | |
parent | 378325f948e677b0253c6dc5e268aa753d3a10f1 (diff) | |
download | rpg-c4766956646b53ab644ec6ddbd17d9cba07cf872.tar.gz rpg-c4766956646b53ab644ec6ddbd17d9cba07cf872.tar.bz2 |
DOKU_TPL* considered harmful
Some plugins want to dynamically switch the template based on users,
namspaces or the phase of the moon. Having fixed paths in a unchangable
constant prevents this.
This changes deprecates the DOKU_TPL* constants in favor of two new
tpl_* functions that return the correct paths based on the $conf
variables which can be changed from the DOKUWIKI_STARTED event.
Diffstat (limited to 'inc')
-rw-r--r-- | inc/init.php | 4 | ||||
-rw-r--r-- | inc/template.php | 31 |
2 files changed, 29 insertions, 6 deletions
diff --git a/inc/init.php b/inc/init.php index 14660b8d0..3aab0587b 100644 --- a/inc/init.php +++ b/inc/init.php @@ -118,11 +118,11 @@ if (!defined('DOKU_COOKIE')) define('DOKU_COOKIE', 'DW'.md5(DOKU_REL.(($conf['se // define main script if(!defined('DOKU_SCRIPT')) define('DOKU_SCRIPT','doku.php'); -// define Template baseURL +// DEPRECATED, use tpl_basedir() instead if(!defined('DOKU_TPL')) define('DOKU_TPL', DOKU_BASE.'lib/tpl/'.$conf['template'].'/'); -// define real Template directory +// DEPRECATED, use tpl_incdir() instead if(!defined('DOKU_TPLINC')) define('DOKU_TPLINC', DOKU_INC.'lib/tpl/'.$conf['template'].'/'); diff --git a/inc/template.php b/inc/template.php index b338d2ce9..28a6a387e 100644 --- a/inc/template.php +++ b/inc/template.php @@ -23,6 +23,29 @@ function template($tpl){ return DOKU_INC.'lib/tpl/default/'.$tpl; } + +/** + * Convenience function to access template dir from local FS + * + * This replaces the deprecated DOKU_TPLINC constant + * + * @author Andreas Gohr <andi@splitbrain.org> + */ +function tpl_incdir(){ + return DOKU_INC.'lib/tpl/'.$conf['template'].'/'; +} + +/** + * Convenience function to access template dir from web + * + * This replaces the deprecated DOKU_TPL constant + * + * @author Andreas Gohr <andi@splitbrain.org> + */ +function tpl_basedir(){ + return DOKU_BASE.'lib/tpl/'.$conf['template'].'/'; +} + /** * Print the content * @@ -1034,7 +1057,7 @@ function tpl_getConf($id){ */ function tpl_loadConfig(){ - $file = DOKU_TPLINC.'/conf/default.php'; + $file = tpl_incdir().'/conf/default.php'; $conf = array(); if (!@file_exists($file)) return false; @@ -1055,7 +1078,7 @@ function tpl_getLang($id){ static $lang = array(); if (count($lang) === 0){ - $path = DOKU_TPLINC.'lang/'; + $path = tpl_incdir().'lang/'; $lang = array(); @@ -1476,7 +1499,7 @@ function tpl_getMediaFile($search, $abs=false, &$imginfo=null){ $file = mediaFN($img); $ismedia = true; }else{ - $file = DOKU_TPLINC.$img; + $file = tpl_incdir().$img; $ismedia = false; } @@ -1492,7 +1515,7 @@ function tpl_getMediaFile($search, $abs=false, &$imginfo=null){ if($ismedia){ $url = ml($img, '', true, '', $abs); }else{ - $url = DOKU_TPL.$img; + $url = tpl_basedir().$img; if($abs) $url = DOKU_URL.substr($url, strlen(DOKU_REL)); } |