Adding fix for Ticket #2239

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4658 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2007-03-23 09:20:14 +00:00
parent 3b90fdbe2e
commit 7cc6185076

View file

@ -32,10 +32,7 @@ if (!defined('CAKE_CORE_INCLUDE_PATH')) {
/** /**
* Enter description here... * Enter description here...
*/ */
require(CONFIGS . 'paths.php'); uses('file');
require(CAKE . 'basics.php');
require(LIBS . 'folder.php');
require(LIBS . 'file.php');
/** /**
* Enter description here... * Enter description here...
* *
@ -45,11 +42,11 @@ if (!defined('CAKE_CORE_INCLUDE_PATH')) {
*/ */
function make_clean_css($path, $name) { function make_clean_css($path, $name) {
require(VENDORS . 'csspp' . DS . 'csspp.php'); require(VENDORS . 'csspp' . DS . 'csspp.php');
$data =file_get_contents($path); $data = file_get_contents($path);
$csspp =new csspp(); $csspp = new csspp();
$output=$csspp->compress($data); $output = $csspp->compress($data);
$ratio =100 - (round(strlen($output) / strlen($data), 3) * 100); $ratio = 100 - (round(strlen($output) / strlen($data), 3) * 100);
$output=" /* file: $name, ratio: $ratio% */ " . $output; $output = " /* file: $name, ratio: $ratio% */ " . $output;
return $output; return $output;
} }
/** /**
@ -63,7 +60,7 @@ if (!defined('CAKE_CORE_INCLUDE_PATH')) {
if (!is_dir(dirname($path))) { if (!is_dir(dirname($path))) {
mkdir(dirname($path)); mkdir(dirname($path));
} }
$cache=new File($path); $cache = new File($path);
return $cache->write($content); return $cache->write($content);
} }
@ -80,18 +77,19 @@ if (!defined('CAKE_CORE_INCLUDE_PATH')) {
} }
if (file_exists($cachepath)) { if (file_exists($cachepath)) {
$templateModified=filemtime($filepath); $templateModified = filemtime($filepath);
$cacheModified =filemtime($cachepath); $cacheModified = filemtime($cachepath);
if ($templateModified > $cacheModified) { if ($templateModified > $cacheModified) {
$output=make_clean_css($filepath, $filename); $output = make_clean_css($filepath, $filename);
write_css_cache($cachepath, $output); write_css_cache($cachepath, $output);
} else { } else {
$output = file_get_contents($cachepath); $output = file_get_contents($cachepath);
} }
} else { } else {
$output=make_clean_css($filepath, $filename); $output = make_clean_css($filepath, $filename);
write_css_cache($cachepath, $output); write_css_cache($cachepath, $output);
$templateModified = time();
} }
header("Date: " . date("D, j M Y G:i:s ", $templateModified) . 'GMT'); header("Date: " . date("D, j M Y G:i:s ", $templateModified) . 'GMT');