diff options
author | xue <> | 2005-11-15 15:34:38 +0000 |
---|---|---|
committer | xue <> | 2005-11-15 15:34:38 +0000 |
commit | 4c9067bf7ae89b446bb0e236ab20c5b4fa3ee3e3 (patch) | |
tree | be5b2366fdedd2d2789955deb18ef7e072ca4e6e /framework/Web/TAssetManager.php | |
parent | fdce469afc80e6cf922c07500f9b7bfd5b302c35 (diff) |
Added a new template/theme syntax for URL support.
Diffstat (limited to 'framework/Web/TAssetManager.php')
-rw-r--r-- | framework/Web/TAssetManager.php | 50 |
1 files changed, 18 insertions, 32 deletions
diff --git a/framework/Web/TAssetManager.php b/framework/Web/TAssetManager.php index 4bc52eed..b12bc4df 100644 --- a/framework/Web/TAssetManager.php +++ b/framework/Web/TAssetManager.php @@ -25,7 +25,7 @@ * By default, TAssetManager will not publish a file or directory if it already
* exists in the publishing directory. You may require a timestamp checking by
* setting CheckTimestamp to true (which is false by default). You may also require
- * so when calling {@link publishFile} or {@link publishDirectory). This is usually
+ * so when calling {@link publishFilePath}. This is usually
* very useful during development. In production sites, the timestamp checking
* should be turned off to improve performance.
*
@@ -151,24 +151,36 @@ class TAssetManager extends TComponent implements IModule }
/**
- * Publishes a directory (recursively).
+ * Publishes a file or a directory (recursively).
* This method will copy the content in a directory (recursively) to
* a web accessible directory and returns the URL for the directory.
* @param string the path to be published
* @param boolean whether to use file modify time to ensure every published file is latest
* @return string an absolute URL to the published directory
*/
- public function publishDirectory($path,$checkTimestamp=false)
+ public function publishFilePath($path,$checkTimestamp=false)
{
- if(($fullpath=realpath($path))!==false && is_dir($fullpath))
+ if(($fullpath=realpath($path))===false)
+ throw new TInvalidDataValueException('assetmanager_filepath_invalid',$path);
+ else if(is_file($fullpath))
+ {
+ $dir=md5(dirname($fullpath));
+ $file=$this->_basePath.'/'.$dir.'/'.basename($fullpath);
+
+ if(!is_file($file) || (($checkTimestamp || $this->_checkTimestamp) && filemtime($file)<filemtime($path)))
+ {
+ @mkdir($this->_basePath.'/'.$dir);
+ copy($fullpath,$file);
+ }
+ return $this->_baseUrl.'/'.$dir.'/'.basename($fullpath);
+ }
+ else
{
$dir=md5($fullpath);
if(!is_dir($this->_basePath.'/'.$dir) || $checkTimestamp || $this->_checkTimestamp)
$this->copyDirectory($fullpath,$this->_basePath.'/'.$dir);
return $this->_baseUrl.'/'.$dir;
}
- else
- throw new TInvalidDataValueException('assetmanager_directory_invalid',$path);
}
/**
@@ -196,32 +208,6 @@ class TAssetManager extends TComponent implements IModule }
closedir($folder);
}
-
- /**
- * Publishes a file.
- * This method will copy a file to a web accessible directory and
- * returns the URL for the file.
- * @param string the file to be published
- * @param boolean whether to use file modify time to ensure the published file is latest
- * @return string an absolute URL to the published file
- */
- public function publishFile($path,$checkTimestamp=false)
- {
- if(($fullpath=realpath($path))!==false && is_file($fullpath))
- {
- $dir=md5(dirname($fullpath));
- $file=$this->_basePath.'/'.$dir.'/'.basename($fullpath);
-
- if(!is_file($file) || (($checkTimestamp || $this->_checkTimestamp) && filemtime($file)<filemtime($path)))
- {
- @mkdir($this->_basePath.'/'.$dir);
- copy($fullpath,$file);
- }
- return $this->_baseUrl.'/'.$dir.'/'.basename($fullpath);
- }
- else
- throw new TInvalidDataValueException('assetmanager_file_invalid',$path);
- }
}
?>
\ No newline at end of file |