From 78d4e784c199ffdd0540a1fc96b6b41ff2c8e0ec Mon Sep 17 00:00:00 2001
From: Esther Brunner <esther@kaffeehaus.ch>
Date: Wed, 22 Mar 2006 15:02:00 +0100
Subject: [PATCH] functions for accessing template config variables

darcs-hash:20060322140200-283c4-c544d2dddf39a7d41c106a0d11d64d98fe8e8343.gz
---
 inc/template.php | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/inc/template.php b/inc/template.php
index a74067f8b..c4702af13 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -959,4 +959,48 @@ function tpl_indexerWebBug(){
   print "<img $att />";
 }
 
+// configuration methods
+/**
+ * tpl_getConf($id)
+ * 
+ * use this function to access template configuration variables
+ */
+function tpl_getConf($id){
+  global $conf;
+  global $tpl_configloaded;
+  
+  $tpl = $conf['template'];
+  
+  if (!$tpl_configloaded){
+    $tconf = tpl_loadConfig();
+    if ($tconf !== false){
+      foreach ($tconf as $key => $value){
+        if (isset($conf['tpl'][$tpl][$key])) continue;
+        $conf['tpl'][$tpl][$key] = $value;
+      }
+      $tpl_configloaded = true;
+    }
+  }
+
+  return $conf['tpl'][$tpl][$id];
+}
+
+/**
+ * tpl_loadConfig()
+ * reads all template configuration variables
+ * this function is automatically called by tpl_getConf()
+ */
+function tpl_loadConfig(){
+      
+  $file = DOKU_TPLINC.'/conf/default.php';
+  $conf = array();
+  
+  if (!@file_exists($file)) return false;
+  
+  // load default config file
+  include($file);
+  
+  return $conf;
+}
+
 //Setup VIM: ex: et ts=2 enc=utf-8 :
-- 
GitLab