diff options
author | xue <> | 2006-05-18 18:09:36 +0000 |
---|---|---|
committer | xue <> | 2006-05-18 18:09:36 +0000 |
commit | 6fd850ae344959dff4e417d9ce8384ce209c3900 (patch) | |
tree | 9eea785a0e024d653faeb966d1289e7d072a56d4 /framework/Web/Javascripts | |
parent | c39b7e37262b22ff2641e840fa22fc139ab2368b (diff) |
Fixed #179.
Diffstat (limited to 'framework/Web/Javascripts')
-rw-r--r-- | framework/Web/Javascripts/js/clientscripts.php | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/framework/Web/Javascripts/js/clientscripts.php b/framework/Web/Javascripts/js/clientscripts.php index 1fb14003..3ac3b062 100644 --- a/framework/Web/Javascripts/js/clientscripts.php +++ b/framework/Web/Javascripts/js/clientscripts.php @@ -1,15 +1,15 @@ <?php
/**
- * This file compresses the javascript files using GZip
+ * This file compresses the javascript files using GZip
*
* Todo:
* - Add local file cache for the GZip:ed version.
*/
-if(is_int(strpos($_SERVER['REQUEST_URI'], '__nocache')))
- $expiresOffset = -10000; //no cache
-else
- $expiresOffset = 3600 * 24 * 10; // 10 days util client cache expires
+$debugMode=(isset($_GET['mode']) && $_GET['mode']==='debug');
+
+// if debug mode, js is not cached; otherwise cached for 10 days.
+$expiresOffset = $debugMode ? -10000 : 3600 * 24 * 10; //no cache
//allowed libraries
$library = array('prado', 'effects', 'ajax', 'validator', 'logger', 'datepicker', 'rico', 'colorpicker');
@@ -18,7 +18,7 @@ $param = isset($_GET['js']) ? $_GET['js'] : ''; //check for proper matching parameters, otherwise exit;
if(preg_match('/(\w)+(,\w+)*/', $param)) $js = explode(',', $param); else exit();
-foreach($js as $lib) if(!in_array($lib, $library)) exit();
+foreach($js as $lib) if(!in_array($lib, $library)) exit();
// Only gzip the contents if clients and server support it
if (isset($_SERVER['HTTP_ACCEPT_ENCODING']))
@@ -27,8 +27,8 @@ else $encodings = array();
// Check for gzip header or northon internet securities
-if ((in_array('gzip', $encodings) || isset($_SERVER['---------------']))
- && function_exists('ob_gzhandler') && !ini_get('zlib.output_compression')
+if ((in_array('gzip', $encodings) || isset($_SERVER['---------------']))
+ && function_exists('ob_gzhandler') && !ini_get('zlib.output_compression')
&& ini_get('output_handler') != 'ob_gzhandler')
ob_start("ob_gzhandler");
@@ -38,16 +38,24 @@ header('Content-type: text/javascript; charset: UTF-8'); header('Vary: Accept-Encoding'); // Handle proxies
header('Expires: ' . @gmdate('D, d M Y H:i:s', @time() + $expiresOffset) . ' GMT');
-foreach($js as $lib)
+if ($debugMode)
{
- $file = realpath($lib.'.js');
- if(is_file($file))
- echo file_get_contents($file);
- else //log missings files to console logger
+ foreach($js as $lib)
{
- echo 'setTimeout(function(){ if(Logger) Logger.error("Missing file", "'.$lib.'.js"); }, 1000);';
- error_log("Unable to find asset file {$lib}.js");
+ $file = realpath($lib.'.js');
+ if(is_file($file))
+ echo file_get_contents($file);
+ else //log missings files to console logger
+ {
+ echo 'setTimeout(function(){ if(Logger) Logger.error("Missing file", "'.$lib.'.js"); }, 1000);';
+ error_log("Unable to find asset file {$lib}.js");
+ }
}
}
+else
+{
+ foreach($js as $lib)
+ echo file_get_contents($lib.'.js');
+}
?>
\ No newline at end of file |