From 8dcab11beafb1a04b514a3beacc6113f29450d3c Mon Sep 17 00:00:00 2001 From: "ctrlaltca@gmail.com" <> Date: Tue, 20 Sep 2011 09:35:40 +0000 Subject: patch for #363: dropping clientscripts.php --- framework/Web/UI/TClientScriptManager.php | 135 ++++++++++-------------------- 1 file changed, 43 insertions(+), 92 deletions(-) (limited to 'framework/Web/UI') diff --git a/framework/Web/UI/TClientScriptManager.php b/framework/Web/UI/TClientScriptManager.php index 19a8090c..0a673b5b 100644 --- a/framework/Web/UI/TClientScriptManager.php +++ b/framework/Web/UI/TClientScriptManager.php @@ -29,10 +29,9 @@ class TClientScriptManager extends TApplicationComponent */ const SCRIPT_PATH='Web/Javascripts/source'; /** - * the PHP script for loading Prado javascript files + * file containing javascript packages and their cross dependencies */ - const SCRIPT_LOADER='Web/Javascripts/clientscripts.php'; - + const PACKAGES_FILE='Web/Javascripts/packages.php'; /** * @var TPage page who owns this manager */ @@ -74,12 +73,12 @@ class TClientScriptManager extends TApplicationComponent */ private $_registeredPradoScripts=array(); /** - * Client-side javascript library dependencies, loads from SCRIPT_PATH.'/packages.php'; + * Client-side javascript library dependencies, loads from PACKAGES_FILE; * @var array */ private static $_pradoScripts; /** - * Client-side javascript library packages, loads from SCRIPT_PATH.'/packages.php'; + * Client-side javascript library packages, loads from PACKAGES_FILE; * @var array */ private static $_pradoPackages; @@ -120,7 +119,7 @@ class TClientScriptManager extends TApplicationComponent } /** - * Registers Prado javascript by library name. See "Web/Javascripts/source/packages.php" + * Registers Prado javascript by library name. See "Web/Javascripts/packages.php" * for library names. * @param string script library name. */ @@ -141,7 +140,7 @@ class TClientScriptManager extends TApplicationComponent { if(self::$_pradoScripts === null) { - $packageFile = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH.'/packages.php'; + $packageFile = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::PACKAGES_FILE; list($packages,$deps)= include($packageFile); self::$_pradoScripts = $deps; self::$_pradoPackages = $packages; @@ -174,31 +173,38 @@ class TClientScriptManager extends TApplicationComponent $addedScripts = array_diff($this->_registeredPradoScripts,$this->_renderedPradoScripts); if(($packages=array_keys($addedScripts))!==array()) { - 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 + $base = Prado::getFrameworkPath().DIRECTORY_SEPARATOR.self::SCRIPT_PATH; + list($path,$baseUrl)=$this->getPackagePathUrl($base); + $packagesUrl=array(); + $isDebug=$this->getApplication()->getMode()===TApplicationMode::Debug; + foreach ($packages as $p) { - // In debug mode, we add 1