From f1f771344f46009891de4c83bfff6043da81231b Mon Sep 17 00:00:00 2001 From: Esther Brunner Date: Wed, 22 Mar 2006 12:08:32 +0100 Subject: methods for loading config variables in syntax and amin plugins darcs-hash:20060322110832-283c4-d8e56c241f8a34827f1c188c4db7162ef658e010.gz --- lib/plugins/syntax.php | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'lib/plugins/syntax.php') diff --git a/lib/plugins/syntax.php b/lib/plugins/syntax.php index 027c85c51..9918e552a 100644 --- a/lib/plugins/syntax.php +++ b/lib/plugins/syntax.php @@ -17,8 +17,9 @@ require_once(DOKU_INC.'inc/parser/parser.php'); class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode { var $allowedModesSetup = false; - var $localised = false; // set to true by setupLocale() after loading language dependent strings + var $localised = false; // set to true by setupLocale() after loading language dependent strings var $lang = array(); // array to hold language dependent strings, best accessed via ->getLang() + var $configloaded = false; // set to true by loadConfig() after loading plugin configuration variables /** * General Info @@ -208,6 +209,47 @@ class DokuWiki_Syntax_Plugin extends Doku_Parser_Mode { $this->lang = $lang; $this->localised = true; } + + // configuration methods + /** + * getConf($id) + * + * use this function to access plugin configuration variables + */ + function getConf($id){ + global $conf; + + $plugin = $this->getPluginName(); + + if (!$this->configloaded){ + if ($pconf = $this->loadConfig() !== false){ + foreach ($pconf as $key => $value){ + if (isset($conf['plugin'][$plugin][$key])) continue; + $conf['plugin'][$plugin][$key] = $value; + } + $this->configloaded = true; + } + } + + return $conf['plugin'][$plugin][$id]; + } + + /** + * loadConfig() + * reads all plugin configuration variables into $this->conf + * this function is automatically called by getConf() + */ + function loadConfig(){ + $path = DOKU_PLUGIN.$this->getPluginName().'/conf/'; + $conf = array(); + + if (!@file_exists($path.'default.php')) return false; + + // load default config file + include($path.'default.php'); + + return $conf; + } } //Setup VIM: ex: et ts=4 enc=utf-8 : -- cgit v1.2.3