[dokuwiki] darcs patch: plugin and template config methods
- From: "Esther Brunner" <wikidesign@xxxxxxxxx>
- To: dokuwiki@xxxxxxxxxxxxx
- Date: Wed, 22 Mar 2006 15:29:48 +0100
Hi all
I've just finished the work on methods for accessing and handling
plugin and template config variables. Chris, could you have a look at
these patches, especially the one for the config manager.
Plugins have to call $this->getConf(<key>) to get a config setting.
Similarly, you can call tpl_getConf(<key>) in a template.
The files to store default settings, metadata for the config manager
and localized prompts are always:
* <plugin or template folder>/conf/default.php
* <plugin or template folder>/conf/metadata.php
* <plugin or template folder>/lang/en/settings.php
* <plugin or template folder>/lang/<lang>/settings.php
Wed Mar 22 12:08:32 CET 2006 Esther Brunner <esther@xxxxxxxxxxxxx>
* methods for loading config variables in syntax and amin plugins
Wed Mar 22 15:02:00 CET 2006 Esther Brunner <esther@xxxxxxxxxxxxx>
* functions for accessing template config variables
Wed Mar 22 15:05:25 CET 2006 Esther Brunner <esther@xxxxxxxxxxxxx>
* changes to config plugin needed for template and plugin configuration
-- Esther Brunner
New patches:
[methods for loading config variables in syntax and amin plugins
Esther Brunner <esther@xxxxxxxxxxxxx>**20060322110832] {
hunk ./lib/plugins/admin.php 19
+ var $configloaded = false; // set to true by loadConfig() after loading
plugin configuration variables
hunk ./lib/plugins/admin.php 131
+ }
+
+ // 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;
hunk ./lib/plugins/config/admin.php 97
- $this->setupLocale(true);
+ $this->setupLocale(true);
hunk ./lib/plugins/config/admin.php 193
- $lang = array();
+ $lang = array();
hunk ./lib/plugins/config/admin.php 201
+ $lang = array();
hunk ./lib/plugins/config/admin.php 204
+ foreach ($lang as $key => $value){
+ $this->lang['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.$key] =
$value;
+ }
hunk ./lib/plugins/config/admin.php 210
-
- $this->lang = array_merge($lang, $this->lang);
hunk ./lib/plugins/syntax.php 20
- 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
hunk ./lib/plugins/syntax.php 22
+ var $configloaded = false; // set to true by loadConfig() after
loading plugin configuration variables
hunk ./lib/plugins/syntax.php 211
+ }
+
+ // 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;
}
[functions for accessing template config variables
Esther Brunner <esther@xxxxxxxxxxxxx>**20060322140200] {
hunk ./inc/template.php 962
+// 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;
+}
+
}
[changes to config plugin needed for template and plugin configuration
Esther Brunner <esther@xxxxxxxxxxxxx>**20060322140525] {
hunk ./lib/plugins/config/admin.php 187
- function _setup_localised_plugin_prompts() {
+ function _setup_localised_plugintpl_prompts() {
hunk ./lib/plugins/config/admin.php 193
- $lang = array();
-
hunk ./lib/plugins/config/admin.php 209
-
+
+ // the same for the active template
+ $tpl = $conf['template'];
+
+ if (@file_exists(DOKU_TPLINC.$enlangfile)){
+ $lang = array();
+ @include(DOKU_TPLINC.$enlangfile);
+ if ($conf['lang'] != 'en') @include(DOKU_TPLINC.$langfile);
+ foreach ($lang as $key => $value){
+ $this->lang['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.$key] = $value;
+ }
+ }
+
hunk ./lib/plugins/config/settings/config.class.php 29
+ global $conf;
hunk ./lib/plugins/config/settings/config.class.php 47
- $this->_metadata = array_merge($meta, $this->get_plugin_metadata());
+ $this->_metadata = array_merge($meta,
$this->get_plugintpl_metadata($conf['template']));
hunk ./lib/plugins/config/settings/config.class.php 53
+ global $conf;
hunk ./lib/plugins/config/settings/config.class.php 56
- $default = array_merge($this->_read_config($this->_default_file),
$this->get_plugin_default());
+ $default = array_merge($this->_read_config($this->_default_file),
$this->get_plugintpl_default($conf['template']));
hunk ./lib/plugins/config/settings/config.class.php 211
- * load metadata for plugin settings
+ * load metadata for plugin and template settings
hunk ./lib/plugins/config/settings/config.class.php 213
- function get_plugin_metadata(){
- $file = '/settings/config.metadata.php';
- $meta = array();
+ function get_plugintpl_metadata($tpl){
+ $file = '/conf/metadata.php';
+ $metadata = array();
hunk ./lib/plugins/config/settings/config.class.php 223
+ $meta = array();
hunk ./lib/plugins/config/settings/config.class.php 225
+ foreach ($meta as $key => $value){
+ $metadata['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.$key] =
$value;
+ }
hunk ./lib/plugins/config/settings/config.class.php 232
- return $meta;
+
+ // the same for the active template
+ if (@file_exists(DOKU_TPLINC.$file)){
+ $meta = array();
+ @include(DOKU_TPLINC.$file);
+ foreach ($meta as $key => $value){
+ $metadata['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.$key] = $value;
+ }
+ }
+
+ return $metadata;
hunk ./lib/plugins/config/settings/config.class.php 246
- * load default settings for plugins
+ * load default settings for plugins and templates
hunk ./lib/plugins/config/settings/config.class.php 248
- function get_plugin_default(){
- $file = '/settings/config.default.php';
+ function get_plugintpl_default($tpl){
+ $file = '/conf/default.php';
hunk ./lib/plugins/config/settings/config.class.php 255
- $default = array_merge($default,
$this->_read_config("DOKU_PLUGIN.'".$plugin.$file."'"));
+ $conf = array();
+ @include(DOKU_PLUGIN.$plugin.$file);
+ foreach ($conf as $key => $value){
+ $default['plugin'.CM_KEYMARKER.$plugin.CM_KEYMARKER.$key] =
$value;
+ }
hunk ./lib/plugins/config/settings/config.class.php 264
+
+ // the same for the active template
+ if (@file_exists(DOKU_TPLINC.$file)){
+ $conf = array();
+ @include(DOKU_TPLINC.$file);
+ foreach ($conf as $key => $value){
+ $default['tpl'.CM_KEYMARKER.$tpl.CM_KEYMARKER.$key] = $value;
+ }
+ }
+
}
Context:
[fixes spellchecker problem with apostrophe in links #753
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20060317203643]
[changes order of CSS loading #746
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20060317185142
This changes the order of how Stylesheets are loaded, loading template
styles *after* the plugin styles to allow template authors to simply
override those styles.
]
[make sure the parser works if acronym file is missing #716
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20060317182631
Parser don't longer breaks if no smileys, acronyms or entities are configured
]
[czech lang update
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20060317181744]
[dichotomic search for getRevisionInfo
Yann <yann.hamon@xxxxxxxxx>**20060317175725]
[fixed bug where '304 Not Modified' worked every other time because cache
headers were not sent
Ben Coburn <btcoburn@xxxxxxxxxxxxx>**20060315120248]
[Enable '304 Not Modified' responses for CSS and JS.
Ben Coburn <btcoburn@xxxxxxxxxxxxx>**20060315115745]
[refactored http_conditionalRequest($timestamp) to inc/pageutils.php
Ben Coburn <btcoburn@xxxxxxxxxxxxx>**20060315064506]
[use 389 as standard port in ldap auth
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20060314191118]
[first piece of greek translation
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20060314190620]
[xhtml.php fix for recent <p>..</p> removal regex
chris@xxxxxxxxxxxxx**20060314152807]
[usermanager minor changes: white space & comment improvement
chris@xxxxxxxxxxxxx**20060314122618]
[user manager fix : gracefully handle an attempt to edit a non-existant user
chris@xxxxxxxxxxxxx**20060314104843]
[experimental shadow effect for input controls
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20060313221312
This adds a shadow effect to input fields and buttons for the default
template. It uses alphatransparency PNGs so it will may look bad for IE
in some cases. I think it adds some nice 3D effect making inputs and
buttons easily distictable without any complicated CSS markup.
]
[Danish lang update
larsch8@xxxxxxxxxxxxx**20060312214049]
[plugin manager upate: protect default plugins, add enable/disable functionality
chris@xxxxxxxxxxxxx**20060311192655]
[empty paragraph fixup for XHTML renderer
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20060311201015
as discussed on the mailinglist
]
[small css fix for usermanager
Anika Henke <a.c.henke@xxxxxxxx>**20060311194930]
[Automatic draft saving
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20060311200148
DokuWiki now automatically creates a draft file of the currently edited
page. In case of an editing interuption (eg. Browsercrash) the draftfile
can be continued later.
]
[enhanced clientIP() function
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20060311185752
The function now can optinally return a single IP address and tries
to be clever about which one to choose if multiple were supplied
through X-Forwarded-For headers
]
[Fix toc indentation for toptoclevel > 1
jan@xxxxxxxxxxxxxxx**20060310155752]
[LDAP URI support for parser
'Guy Brand <gb@xxxxxxxxxxxxxxxxx>'**20060311130311
Add parser detection for LDAP URI scheme as specified in RFC 2255
]
[TAG release 2006-03-09
Andreas Gohr <andi@xxxxxxxxxxxxxx>**20060309203051]
Patch bundle hash:
55c21d29d31391536ffe55e54a14fcaba6a5c1f9
Other related posts:
- » [dokuwiki] darcs patch: plugin and template config methods