diff options
author | wei <> | 2005-12-13 07:08:30 +0000 |
---|---|---|
committer | wei <> | 2005-12-13 07:08:30 +0000 |
commit | 35c7ff28cbc311fba5e394b11fb756a4dc1edcb9 (patch) | |
tree | 1ee39944b4cdba1ecc6aeb2a952139b5a3165f67 /framework/Web/UI/TAssetManager.php | |
parent | 2c383b6050b3d8cc6ac7a9442c999cb903af43ab (diff) |
Removed inline javascript from components. Adding TJavascriptLogger and logger.js
Diffstat (limited to 'framework/Web/UI/TAssetManager.php')
-rw-r--r-- | framework/Web/UI/TAssetManager.php | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/framework/Web/UI/TAssetManager.php b/framework/Web/UI/TAssetManager.php index df189b58..dfc1fa53 100644 --- a/framework/Web/UI/TAssetManager.php +++ b/framework/Web/UI/TAssetManager.php @@ -150,7 +150,7 @@ class TAssetManager extends TModule return '';
else if(is_file($fullpath))
{
- $dir=md5(dirname($fullpath));
+ $dir=$this->hash(dirname($fullpath));
$file=$this->_basePath.'/'.$dir.'/'.basename($fullpath);
if(!is_file($file) || $checkTimestamp || $this->_application->getMode()!=='Performance')
{
@@ -164,7 +164,7 @@ class TAssetManager extends TModule }
else
{
- $dir=md5($fullpath);
+ $dir=$this->hash($fullpath);
if(!is_dir($this->_basePath.'/'.$dir) || $checkTimestamp || $this->_application->getMode()!=='Performance')
$this->copyDirectory($fullpath,$this->_basePath.'/'.$dir);
$this->_published[$path]=$this->_baseUrl.'/'.$dir;
@@ -173,6 +173,27 @@ class TAssetManager extends TModule }
/**
+ * Generate a CRC32 hash for the directory path. Collisions are higher
+ * than MD5 but generates a much smaller hash string.
+ * @param string string to be hashed.
+ * @return string hashed string.
+ */
+ private function hash($dir)
+ {
+ $num = sprintf('%u', crc32($dir));
+ $base = 62;
+ $index = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+ $out = '';
+ for ( $t = floor( log10( $num ) / log10( $base ) ); $t >= 0; $t-- )
+ {
+ $a = floor( $num / pow( $base, $t ) );
+ $out = $out . substr( $index, $a, 1 );
+ $num = $num - ( $a * pow( $base, $t ) );
+ }
+ return $out;
+ }
+
+ /**
* Copies a directory recursively as another.
* If the destination directory does not exist, it will be created.
* File modification time is used to ensure the copied files are latest.
|