summaryrefslogtreecommitdiff
path: root/framework/Web/UI/WebControls/TClientScript.php
diff options
context:
space:
mode:
authorwei <>2007-04-05 07:46:04 +0000
committerwei <>2007-04-05 07:46:04 +0000
commit791acbbebad01a33cce22209ea561b282ee876e4 (patch)
tree0beb32aa1d311b0c7df66dd0bff835642351e82e /framework/Web/UI/WebControls/TClientScript.php
parentb99fd37ad7a3cae497b5242e5537f508c03f5585 (diff)
adds TClientScriptLoader
Diffstat (limited to 'framework/Web/UI/WebControls/TClientScript.php')
-rw-r--r--framework/Web/UI/WebControls/TClientScript.php77
1 files changed, 0 insertions, 77 deletions
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.
@@ -78,38 +76,6 @@ class TClientScript extends TControl
}
/**
- * @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.
* @param mixed event parameter
@@ -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</script>\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.='&amp;mode=debug';
- $writer->write("<script type=\"text/javascript\" src=\"{$url}\"></script>\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