diff options
author | Chris Smith <chris.eureka@jalakai.co.uk> | 2009-01-22 12:44:57 +0100 |
---|---|---|
committer | Chris Smith <chris.eureka@jalakai.co.uk> | 2009-01-22 12:44:57 +0100 |
commit | f8121585ae97890245b1969cb62fbef583462b7d (patch) | |
tree | 15936160cdbb9a2e22fd9ac53ecfd682c5f22e81 /inc | |
parent | f0a201c5703333fa2b120cda8e145fb405283908 (diff) | |
download | rpg-f8121585ae97890245b1969cb62fbef583462b7d.tar.gz rpg-f8121585ae97890245b1969cb62fbef583462b7d.tar.bz2 |
further updates to config_cascade patch
- add mediameta and license config files into the cascade
- update the cache validity code in cache.php, css.php & js.php to use config_cascade
- redo inclusion of main config files to avoid suppression of errors in config files
- add getConfigFiles($type) function
- minor updates elsewhere to use config_cascade rather than hardcoded config file names
darcs-hash:20090122114457-f07c6-98ad5627fd5df93edf8dd03289b9cf6d81962afe.gz
Diffstat (limited to 'inc')
-rw-r--r-- | inc/cache.php | 5 | ||||
-rw-r--r-- | inc/confutils.php | 21 | ||||
-rw-r--r-- | inc/init.php | 23 | ||||
-rw-r--r-- | inc/media.php | 12 | ||||
-rw-r--r-- | inc/parserutils.php | 8 | ||||
-rw-r--r-- | inc/template.php | 1 |
6 files changed, 54 insertions, 16 deletions
diff --git a/inc/cache.php b/inc/cache.php index 3eecd8a75..a6979d1c2 100644 --- a/inc/cache.php +++ b/inc/cache.php @@ -181,18 +181,17 @@ class cache_parser extends cache { } function _addDependencies() { - global $conf; + global $conf, $config_cascade; $this->depends['age'] = isset($this->depends['age']) ? min($this->depends['age'],$conf['cachetime']) : $conf['cachetime']; // parser cache file dependencies ... $files = array($this->file, // ... source - DOKU_CONF.'dokuwiki.php', // ... config - DOKU_CONF.'local.php', // ... local config DOKU_INC.'inc/parser/parser.php', // ... parser DOKU_INC.'inc/parser/handler.php', // ... handler ); + $files = array_merge($files, getConfigFiles('main')); // ... wiki settings $this->depends['files'] = !empty($this->depends['files']) ? array_merge($files, $this->depends['files']) : $files; parent::_addDependencies(); diff --git a/inc/confutils.php b/inc/confutils.php index 2099ba949..53db69565 100644 --- a/inc/confutils.php +++ b/inc/confutils.php @@ -182,6 +182,27 @@ function retrieveConfig($type,$fn) { } /** + * Include the requested configuration information + * + * @author Chris Smith <chris@jalakai.co.uk> + * + * @param string $type the configuration settings to be read, must correspond to a key/array in $config_cascade + * @return array list of files, default before local before protected + */ +function getConfigFiles($type) { + global $config_cascade; + $files = array(); + + if (!is_array($config_cascade[$type])) trigger_error('Missing config cascade for "'.$type.'"',E_USER_WARNING); + foreach (array('default','local','protected') as $config_group) { + if (empty($config_cascade[$type][$config_group])) continue; + $files = array_merge($files, $config_cascade[$type][$config_group]); + } + + return $files; +} + +/** * check if the given action was disabled in config * * @author Andreas Gohr <andi@splitbrain.org> diff --git a/inc/init.php b/inc/init.php index 3df769ce8..1d651812f 100644 --- a/inc/init.php +++ b/inc/init.php @@ -62,6 +62,14 @@ 'default' => array(DOKU_CONF.'interwiki.conf'), 'local' => array(DOKU_CONF.'interwiki.local.conf'), ), + 'license' => array( + 'default' => array(DOKU_CONF.'license.php'), + 'local' => array(DOKU_CONF.'license.local.php'), + ), + 'mediameta' => array( + 'default' => array(DOKU_CONF.'mediameta.php'), + 'local' => array(DOKU_CONF.'mediameta.local.php'), + ), 'mime' => array( 'default' => array(DOKU_CONF.'mime.conf'), 'local' => array(DOKU_CONF.'mime.local.conf'), @@ -87,8 +95,11 @@ // load the global config file(s) foreach (array('default','local','protected') as $config_group) { + if (empty($config_cascade['main'][$config_group])) continue; foreach ($config_cascade['main'][$config_group] as $config_file) { - @include($config_file); + if (@file_exists($config_file)) { + include($config_file); + } } } @@ -107,9 +118,13 @@ $license = array(); // load the license file(s) - require_once(DOKU_CONF.'license.php'); - if(@file_exists(DOKU_CONF.'license.php')){ - require_once(DOKU_CONF.'license.php'); + foreach (array('default','local') as $config_group) { + if (empty($config_cascade['license'][$config_group])) continue; + foreach ($config_cascade['license'][$config_group] as $config_file) { + if(@file_exists($config_file)){ + include($config_file); + } + } } // define baseURL diff --git a/inc/media.php b/inc/media.php index 2d3ca3556..515fa0826 100644 --- a/inc/media.php +++ b/inc/media.php @@ -80,15 +80,19 @@ function media_metasave($id,$auth,$data){ */ function media_metaform($id,$auth){ if($auth < AUTH_UPLOAD) return false; - global $lang; + global $lang, $config_cascade; // load the field descriptions static $fields = null; if(is_null($fields)){ - include(DOKU_CONF.'mediameta.php'); - if(@file_exists(DOKU_CONF.'mediameta.local.php')){ - include(DOKU_CONF.'mediameta.local.php'); + + foreach (array('default','local') as $config_group) { + if (empty($config_cascade['mediameta'][$config_group])) continue; + foreach ($config_cascade['mediameta'][$config_group] as $config_file) { + if(@file_exists($config_file)){ + include($config_file); } + } } $src = mediaFN($id); diff --git a/inc/parserutils.php b/inc/parserutils.php index 7a023b159..e1f9922f0 100644 --- a/inc/parserutils.php +++ b/inc/parserutils.php @@ -631,7 +631,7 @@ function p_get_first_heading($id, $render=true){ * @author Andreas Gohr <andi@splitbrain.org> */ function p_xhtml_cached_geshi($code, $language, $wrapper='pre') { - global $conf; + global $conf, $config_cascade; $language = strtolower($language); // remove any leading or trailing blank lines @@ -640,9 +640,9 @@ function p_xhtml_cached_geshi($code, $language, $wrapper='pre') { $cache = getCacheName($language.$code,".code"); $ctime = @filemtime($cache); if($ctime && !$_REQUEST['purge'] && - $ctime > filemtime(DOKU_INC.'inc/geshi.php') && - $ctime > @filemtime(DOKU_INC.'inc/geshi/'.$language.'.php') && - $ctime > filemtime(DOKU_CONF.'dokuwiki.php')){ + $ctime > filemtime(DOKU_INC.'inc/geshi.php') && // geshi changed + $ctime > @filemtime(DOKU_INC.'inc/geshi/'.$language.'.php') && // language syntax definition changed + $ctime > filemtime(reset($config_cascade['main']['default']))){ // dokuwiki changed $highlighted_code = io_readFile($cache, false); } else { diff --git a/inc/template.php b/inc/template.php index 909de999c..71eec0e6a 100644 --- a/inc/template.php +++ b/inc/template.php @@ -7,7 +7,6 @@ */ if(!defined('DOKU_INC')) die('meh.'); -require_once(DOKU_CONF.'dokuwiki.php'); /** * Returns the path to the given template, uses |