diff options
author | Esther Brunner <esther@kaffeehaus.ch> | 2006-03-22 12:08:32 +0100 |
---|---|---|
committer | Esther Brunner <esther@kaffeehaus.ch> | 2006-03-22 12:08:32 +0100 |
commit | f1f771344f46009891de4c83bfff6043da81231b (patch) | |
tree | fbdb5c8be1930016f9d1e5ec4e4fc3325b4f577d /lib/plugins/admin.php | |
parent | 902ea3be6fde62c83285a53e7343bae2faa58326 (diff) | |
download | rpg-f1f771344f46009891de4c83bfff6043da81231b.tar.gz rpg-f1f771344f46009891de4c83bfff6043da81231b.tar.bz2 |
methods for loading config variables in syntax and amin plugins
darcs-hash:20060322110832-283c4-d8e56c241f8a34827f1c188c4db7162ef658e010.gz
Diffstat (limited to 'lib/plugins/admin.php')
-rw-r--r-- | lib/plugins/admin.php | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/plugins/admin.php b/lib/plugins/admin.php index 16e2ed72e..113cf60be 100644 --- a/lib/plugins/admin.php +++ b/lib/plugins/admin.php @@ -16,6 +16,7 @@ class DokuWiki_Admin_Plugin { 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 @@ -129,6 +130,48 @@ class DokuWiki_Admin_Plugin { $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; + } + // standard functions for outputing email addresses and links // use these to avoid having to duplicate code to produce links in line with the installation configuration function email($email, $name='', $class='', $more='') { |