From 9bbb7257d6d3da32c4fec2f575f2fd80497e47c7 Mon Sep 17 00:00:00 2001 From: xue <> Date: Fri, 18 Nov 2005 01:06:15 +0000 Subject: --- framework/Web/TAssetManager.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'framework') diff --git a/framework/Web/TAssetManager.php b/framework/Web/TAssetManager.php index 4147ce2d..3b2131a5 100644 --- a/framework/Web/TAssetManager.php +++ b/framework/Web/TAssetManager.php @@ -56,6 +56,7 @@ class TAssetManager extends TComponent implements IModule * @var boolean whether to use timestamp checking to ensure files are published with up-to-date versions. */ private $_checkTimestamp=false; + private $_application; /** * Initializes the module. @@ -65,6 +66,7 @@ class TAssetManager extends TComponent implements IModule */ public function init($application,$config) { + $this->_application=$application; if($this->_basePath===null) $this->_basePath=dirname($application->getRequest()->getPhysicalApplicationPath()).'/'.self::DEFAULT_BASEPATH; if(!is_writable($this->_basePath) || !is_dir($this->_basePath)) @@ -167,18 +169,19 @@ class TAssetManager extends TComponent implements IModule { $dir=md5(dirname($fullpath)); $file=$this->_basePath.'/'.$dir.'/'.basename($fullpath); - - if(!is_file($file) || (($checkTimestamp || $this->_checkTimestamp) && filemtime($file)_application->getMode()!=='Performance') { - @mkdir($this->_basePath.'/'.$dir); - @copy($fullpath,$file); + if(!is_dir($this->_basePath.'/'.$dir)) + @mkdir($this->_basePath.'/'.$dir); + if(!is_file($file) || @filemtime($file)<@filemtime($fullpath)) + @copy($fullpath,$file); } return $this->_baseUrl.'/'.$dir.'/'.basename($fullpath); } else { $dir=md5($fullpath); - if(!is_dir($this->_basePath.'/'.$dir) || $checkTimestamp || $this->_checkTimestamp) + if(!is_dir($this->_basePath.'/'.$dir) || $checkTimestamp || $this->_application->getMode()!=='Performance') $this->copyDirectory($fullpath,$this->_basePath.'/'.$dir); return $this->_baseUrl.'/'.$dir; } @@ -193,7 +196,8 @@ class TAssetManager extends TComponent implements IModule */ protected function copyDirectory($src,$dst) { - @mkdir($dst); + if(!is_dir($dst)) + @mkdir($dst); $folder=@opendir($src); while($file=@readdir($folder)) { -- cgit v1.2.3