From f65a7202bf0c48e487aa8ec21115b709c69d8118 Mon Sep 17 00:00:00 2001 From: xue <> Date: Wed, 29 Nov 2006 13:00:49 +0000 Subject: fixed #471. --- framework/Web/TAssetManager.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'framework/Web/TAssetManager.php') diff --git a/framework/Web/TAssetManager.php b/framework/Web/TAssetManager.php index aa2919a0..190ee5ac 100644 --- a/framework/Web/TAssetManager.php +++ b/framework/Web/TAssetManager.php @@ -178,6 +178,38 @@ class TAssetManager extends TModule } } + /** + * Returns the published path of a file path. + * This method does not perform any publishing. It merely tells you + * if the file path is published, where it will go. + * @param string directory or file path being published + * @return string the published file path + */ + public function getPublishedPath($path) + { + $path=realpath($path); + if(is_file($path)) + return $this->_basePath.'/'.$this->hash(dirname($path)).'/'.basename($path); + else + return $this->_basePath.'/'.$this->hash($path); + } + + /** + * Returns the URL of a published file path. + * This method does not perform any publishing. It merely tells you + * if the file path is published, what the URL will be to access it. + * @param string directory or file path being published + * @return string the published URL for the file path + */ + public function getPublishedUrl($path) + { + $path=realpath($path); + if(is_file($path)) + return $this->_baseUrl.'/'.$this->hash(dirname($path)).'/'.basename($path); + else + return $this->_baseUrl.'/'.$this->hash($path); + } + /** * Generate a CRC32 hash for the directory path. Collisions are higher * than MD5 but generates a much smaller hash string. -- cgit v1.2.3