diff options
author | Christophe.Boulain <> | 2009-02-23 15:46:26 +0000 |
---|---|---|
committer | Christophe.Boulain <> | 2009-02-23 15:46:26 +0000 |
commit | 1d2260ea228fc98dce3c5fc088bd4b5ad8a9ebb4 (patch) | |
tree | 751cc0d8888b2de1562137862bc3060774bb9bb5 /framework | |
parent | 8fcfadf79ebc05d43bf15e130a4fad04a3bbd6cf (diff) |
Fixed Issue#7 - Client side javascripts are not combined anymore in debug mode
Diffstat (limited to 'framework')
-rw-r--r-- | framework/Web/UI/TClientScriptManager.php | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/framework/Web/UI/TClientScriptManager.php b/framework/Web/UI/TClientScriptManager.php index f0eb6157..09e240c2 100644 --- a/framework/Web/UI/TClientScriptManager.php +++ b/framework/Web/UI/TClientScriptManager.php @@ -76,7 +76,12 @@ class TClientScriptManager extends TApplicationComponent * @var array */ private static $_pradoScripts; - + /** + * Client-side javascript library packages, loads from SCRIPT_PATH.'/packages.php'; + * @var array + */ + private static $_pradoPackages; + /** * Constructor. * @param TPage page that owns this client script manager @@ -120,6 +125,7 @@ class TClientScriptManager extends TApplicationComponent $packageFile = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH.'/packages.php'; list($packages,$deps)= include($packageFile); self::$_pradoScripts = $deps; + self::$_pradoPackages = $packages; } if(isset(self::$_pradoScripts[$name])) @@ -147,9 +153,30 @@ class TClientScriptManager extends TApplicationComponent { if(($packages=array_keys($this->_registeredPradoScripts))!==array()) { - $base = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH; - $url = $this->registerJavascriptPackages($base, $packages); - $writer->write(TJavaScript::renderScriptFile($url)); + if (Prado::getApplication()->getMode()!==TApplicationMode::Debug) + { + $base = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH; + $url = $this->registerJavascriptPackages($base, $packages); + $writer->write(TJavaScript::renderScriptFile($url)); + } + else + { + // In debug mode, we add 1 <script> line by file + $baseUrl=$this->getPradoScriptAssetUrl(); + $packagesUrl=array(); + foreach ($packages as $p) + { + foreach (self::$_pradoScripts[$p] as $dep) + { + foreach (self::$_pradoPackages[$dep] as $script) + { + if (!in_array($url=$baseUrl.'/'.$script,$packagesUrl)) + $packagesUrl[]=$url; + } + } + } + $writer->write(TJavaScript::renderScriptFiles($packagesUrl)); + } } } |