summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Smith <chris.eureka@jalakai.co.uk>2009-01-22 12:44:57 +0100
committerChris Smith <chris.eureka@jalakai.co.uk>2009-01-22 12:44:57 +0100
commitf8121585ae97890245b1969cb62fbef583462b7d (patch)
tree15936160cdbb9a2e22fd9ac53ecfd682c5f22e81
parentf0a201c5703333fa2b120cda8e145fb405283908 (diff)
downloadrpg-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
-rw-r--r--inc/cache.php5
-rw-r--r--inc/confutils.php21
-rw-r--r--inc/init.php23
-rw-r--r--inc/media.php12
-rw-r--r--inc/parserutils.php8
-rw-r--r--inc/template.php1
-rw-r--r--lib/exe/css.php5
-rw-r--r--lib/exe/js.php3
-rw-r--r--lib/plugins/plugin/admin.php4
9 files changed, 60 insertions, 22 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
diff --git a/lib/exe/css.php b/lib/exe/css.php
index 90f0109ef..9fb247496 100644
--- a/lib/exe/css.php
+++ b/lib/exe/css.php
@@ -159,14 +159,15 @@ function css_out(){
* @author Andreas Gohr <andi@splitbrain.org>
*/
function css_cacheok($cache,$files,$tplinc){
+ global $config_cascade;
+
if($_REQUEST['purge']) return false; //support purge request
$ctime = @filemtime($cache);
if(!$ctime) return false; //There is no cache
// some additional files to check
- $files[] = DOKU_CONF.'dokuwiki.php';
- $files[] = DOKU_CONF.'local.php';
+ $files = array_merge($files, getConfigFiles('main'));
$files[] = $tplinc.'style.ini';
$files[] = __FILE__;
diff --git a/lib/exe/js.php b/lib/exe/js.php
index 1caa22b8d..f3acc7491 100644
--- a/lib/exe/js.php
+++ b/lib/exe/js.php
@@ -220,8 +220,7 @@ function js_cacheok($cache,$files){
if(!$ctime) return false; //There is no cache
// some additional files to check
- $files[] = DOKU_CONF.'dokuwiki.php';
- $files[] = DOKU_CONF.'local.php';
+ $files = array_merge($files, getConfigFiles('main'));
$files[] = DOKU_CONF.'userscript.js';
$files[] = __FILE__;
diff --git a/lib/plugins/plugin/admin.php b/lib/plugins/plugin/admin.php
index 237fe11b8..ddd4081a5 100644
--- a/lib/plugins/plugin/admin.php
+++ b/lib/plugins/plugin/admin.php
@@ -273,7 +273,7 @@ class ap_manage {
* Refresh plugin list
*/
function refresh() {
- global $MSG;
+ global $MSG,$config_cascade;
//are there any undisplayed messages? keep them in session for display
if (isset($MSG) && count($MSG)){
@@ -285,7 +285,7 @@ class ap_manage {
// expire dokuwiki caches
// touching local.php expires wiki page, JS and CSS caches
- @touch(DOKU_CONF.'local.php');
+ @touch(reset($config_cascade['main']['local']));
// update latest plugin date - FIXME
header('Location: '.wl($ID).'?do=admin&page=plugin');