From 791acbbebad01a33cce22209ea561b282ee876e4 Mon Sep 17 00:00:00 2001 From: wei <> Date: Thu, 5 Apr 2007 07:46:04 +0000 Subject: adds TClientScriptLoader --- framework/Web/UI/WebControls/TClientScript.php | 77 -------------------------- 1 file changed, 77 deletions(-) (limited to 'framework/Web/UI/WebControls/TClientScript.php') diff --git a/framework/Web/UI/WebControls/TClientScript.php b/framework/Web/UI/WebControls/TClientScript.php index 8b80eb69..2021a933 100644 --- a/framework/Web/UI/WebControls/TClientScript.php +++ b/framework/Web/UI/WebControls/TClientScript.php @@ -38,8 +38,6 @@ */ class TClientScript extends TControl { - const SCRIPT_LOADER = 'Web/Javascripts/clientscripts.php'; - /** * @return string comma delimited list of javascript libraries to included * on the page. @@ -77,38 +75,6 @@ class TClientScript extends TControl $this->setViewState('ScriptUrl', $value, ''); } - /** - * @param string custom javascript library directory. - */ - public function setPackagePath($value) - { - $this->setViewState('PackagePath', $value); - } - - /** - * @return string custom javascript library directory. - */ - public function getPackagePath() - { - return $this->getViewState('PackagePath'); - } - - /** - * @param string load specific packages from the javascript library in the PackagePath, comma delimited package names - */ - public function setPackageScripts($value) - { - $this->setViewState('PackageScripts', $value,''); - } - - /** - * @return string comma delimited list of javascript library packages to load. - */ - public function getPackageScripts() - { - return $this->getViewState('PackageScripts',''); - } - /** * Calls the client script manager to add each of the requested client * script libraries. @@ -135,7 +101,6 @@ class TClientScript extends TControl public function render($writer) { $this->renderCustomScriptFile($writer); - $this->renderPackageScriptFile($writer); $this->renderCustomScript($writer); } @@ -162,48 +127,6 @@ class TClientScript extends TControl $writer->write("\n/*]]>*/\n\n"); } } - - protected function renderPackageScriptFile($writer) - { - $baseUrl = $this->publishScriptLoader(); - $scripts = split('/\s*[, ]+\s*/', $this->getPackageScripts()); - $url = $baseUrl . '?js=' . implode(',', $scripts); - if($this->getApplication()->getMode()===TApplicationMode::Debug) - $url.='&mode=debug'; - $writer->write("\n"); - } - - protected function publishScriptLoader() - { - list($path, $url) = $this->getPublishedPackagePath(); - if(is_dir($path)) - { - $scriptLoader = Prado::getFrameworkPath().'/'.self::SCRIPT_LOADER; - $scriptLoaderFile = basename($scriptLoader); - $dest = $path.'/'.$scriptLoaderFile; - if(!is_file($dest)) - copy($scriptLoader,$dest); - return $url.'/'.$scriptLoaderFile; - } - else - throw new TConfigurationException('clientscript_invalid_package_path', - $this->getPackagePath(), $this->getUniqueID()); - } - - protected function getPublishedPackagePath() - { - $assets = $this->getApplication()->getAssetManager(); - //assumes dot path first - $dir = Prado::getPathOfNameSpace($packageDir); - if(!is_null($dir)) - { - $url = $assets->publishFilePath($dir); //show throw an excemption if invalid - return array($dir, $url); - } - $url = $this->getPackagePath(); - $packageDir = str_replace($assets->getBaseUrl(), '', $url); - return array($assets->getBasePath().$packageDir,$url); - } } ?> \ No newline at end of file -- cgit v1.2.3