From c51f90d7a072929e2b636e986b8ea2121bc5a630 Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Tue, 24 Jan 2012 11:12:44 +0100 Subject: let js.php use multiple caches --- lib/exe/js.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/exe/js.php b/lib/exe/js.php index b7f2fd222..c929c9ba5 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -31,8 +31,14 @@ function js_out(){ global $lang; global $config_cascade; + if (isset($_GET['cacheKey'])) { + $cacheKey = strval($_GET['cacheKey']); + } else { + $cacheKey = ''; + } + // The generated script depends on some dynamic options - $cache = new cache('scripts'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'], + $cache = new cache('scripts'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'].$cacheKey, '.js'); // load minified version for some files -- cgit v1.2.3 From 6d06b26afab712379b6d070a816f0c71cc76753b Mon Sep 17 00:00:00 2001 From: Dominik Eckelmann Date: Tue, 24 Jan 2012 14:30:34 +0100 Subject: added INIT_LANG_LOAD event --- inc/init.php | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/inc/init.php b/inc/init.php index 14660b8d0..130746f20 100644 --- a/inc/init.php +++ b/inc/init.php @@ -69,16 +69,6 @@ foreach (array('default','local','protected') as $config_group) { } } -//prepare language array -global $lang; -$lang = array(); - -//load the language files -require_once(DOKU_INC.'inc/lang/en/lang.php'); -if ( $conf['lang'] && $conf['lang'] != 'en' ) { - require_once(DOKU_INC.'inc/lang/'.$conf['lang'].'/lang.php'); -} - //prepare license array() global $license; $license = array(); @@ -214,6 +204,10 @@ $plugin_controller = new $plugin_controller_class(); global $EVENT_HANDLER; $EVENT_HANDLER = new Doku_Event_Handler(); +$local = $conf['lang']; +trigger_event('INIT_LANG_LOAD', $local, 'init_lang', true); + + // setup authentication system if (!defined('NOSESSION')) { auth_setup(); @@ -256,6 +250,20 @@ function init_paths(){ $conf['media_changelog'] = $conf['metadir'].'/_media.changes'; } +function init_lang($langCode) { + //prepare language array + global $lang; + $lang = array(); + + //load the language files + require_once(DOKU_INC.'inc/lang/en/lang.php'); + if ($langCode && $langCode != 'en') { + if (file_exists(DOKU_INC."inc/lang/$langCode/lang.php")) { + require_once(DOKU_INC."inc/lang/$langCode/lang.php"); + } + } +} + /** * Checks the existance of certain files and creates them if missing. */ -- cgit v1.2.3 From e67004f5b686076af0dbf00cf574ac643d003cae Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 7 Feb 2012 19:41:09 +0100 Subject: trigger JS_CACHE_USE in lib/exe/js.php This removes the cachekey parameter again and instead follows @michitux's suggestion to trigger an event for the cache usage --- lib/exe/js.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/exe/js.php b/lib/exe/js.php index c929c9ba5..95ca10e87 100644 --- a/lib/exe/js.php +++ b/lib/exe/js.php @@ -31,15 +31,9 @@ function js_out(){ global $lang; global $config_cascade; - if (isset($_GET['cacheKey'])) { - $cacheKey = strval($_GET['cacheKey']); - } else { - $cacheKey = ''; - } - // The generated script depends on some dynamic options - $cache = new cache('scripts'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'].$cacheKey, - '.js'); + $cache = new cache('scripts'.$_SERVER['HTTP_HOST'].$_SERVER['SERVER_PORT'],'.js'); + $cache->_event = 'JS_CACHE_USE'; // load minified version for some files $min = $conf['compress'] ? '.min' : ''; @@ -85,8 +79,8 @@ function js_out(){ // check cache age & handle conditional request // This may exit if a cache can be used - http_cached($cache->cache, - $cache->useCache(array('files' => $cache_files))); + $cache_ok = $cache->useCache(array('files' => $cache_files)); + http_cached($cache->cache, $cache_ok); // start output buffering and build the script ob_start(); -- cgit v1.2.3