summaryrefslogtreecommitdiff
path: root/inc/template.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2012-01-30 20:38:41 +0100
committerAndreas Gohr <andi@splitbrain.org>2012-01-30 20:38:41 +0100
commitc4766956646b53ab644ec6ddbd17d9cba07cf872 (patch)
tree9162023353305dc55770c05b0e3d094e1b4a2eaf /inc/template.php
parent378325f948e677b0253c6dc5e268aa753d3a10f1 (diff)
downloadrpg-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/template.php')
-rw-r--r--inc/template.php31
1 files changed, 27 insertions, 4 deletions
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));
}