summaryrefslogtreecommitdiff
path: root/framework/Web/UI
diff options
context:
space:
mode:
authorwei <>2006-01-15 11:04:00 +0000
committerwei <>2006-01-15 11:04:00 +0000
commitabc5bbd9c771dcecfa41ba3590cce1c1ef190cdd (patch)
tree45884a9f15efb190144165d50f79bab6fa914494 /framework/Web/UI
parent5af330b442f15be0f0535a9e3c053b8e6eb5a202 (diff)
Diffstat (limited to 'framework/Web/UI')
-rw-r--r--framework/Web/UI/TClientScriptManager.php61
-rw-r--r--framework/Web/UI/WebControls/TLabel.php10
2 files changed, 70 insertions, 1 deletions
diff --git a/framework/Web/UI/TClientScriptManager.php b/framework/Web/UI/TClientScriptManager.php
index 9537859d..f7778de9 100644
--- a/framework/Web/UI/TClientScriptManager.php
+++ b/framework/Web/UI/TClientScriptManager.php
@@ -163,7 +163,7 @@ class TClientScriptManager extends TComponent
return $javascriptPrefix?'javascript:'.$postback:$postback;
}
- public function registerPradoScript($script)
+ /*public function registerPradoScript($script)
{
foreach(TPradoClientScript::getScripts($script) as $scriptFile)
{
@@ -181,8 +181,67 @@ class TClientScriptManager extends TComponent
}
}
//return $url;
+ }*/
+
+ /**
+ * Register Prado client scripts.
+ */
+ public function registerPradoScript($script)
+ {
+ static $scripts = array();
+ $scripts = array_unique(array_merge($scripts,
+ TPradoClientScript::getScripts($script)));
+
+ $this->publishClientScriptAssets($scripts);
+
+ //create the client script url
+ $url = $this->publishClientScriptCompressorAsset();
+ $url .= '?js='.implode(',', $scripts);
+ if(Prado::getApplication()->getMode() == TApplication::STATE_DEBUG)
+ $url .= '&nocache';
+ $this->registerScriptFile('prado:gzipscripts', $url);
}
+ /**
+ * Publish each individual javascript file.
+ */
+ private function publishClientScriptAssets($scripts)
+ {
+ foreach($scripts as $lib)
+ {
+ if(!isset($this->_publishedScriptFiles[$lib]))
+ {
+ $base = Prado::getFrameworkPath();
+ $clientScripts = self::SCRIPT_DIR;
+ $assetManager = $this->_page->getService()->getAssetManager();
+ $file = "{$base}/{$clientScripts}/{$lib}.js";
+ $assetManager->publishFilePath($file);
+ $this->_publishedScriptFiles[$lib] = true;
+ }
+ }
+ }
+
+ /**
+ * @return string URL of the compressor asset script.
+ */
+ private function publishClientScriptCompressorAsset()
+ {
+ $scriptFile = 'clientscripts.php';
+ if(isset($this->_publishedScriptFiles[$scriptFile]))
+ return $this->_publishedScriptFiles[$scriptFile];
+ else
+ {
+ $base = Prado::getFrameworkPath();
+ $clientScripts = self::SCRIPT_DIR;
+ $assetManager = $this->_page->getService()->getAssetManager();
+ $file = "{$base}/{$clientScripts}/{$scriptFile}";
+ $url= $assetManager->publishFilePath($file);
+ $this->_publishedScriptFiles[$scriptFile] = $url;
+ return $url;
+ }
+ }
+
+
protected function registerPostBackScript()
{
if(!$this->_postBackScriptRegistered)
diff --git a/framework/Web/UI/WebControls/TLabel.php b/framework/Web/UI/WebControls/TLabel.php
index 5a53def4..51e990d2 100644
--- a/framework/Web/UI/WebControls/TLabel.php
+++ b/framework/Web/UI/WebControls/TLabel.php
@@ -101,6 +101,16 @@ class TLabel extends TWebControl
{
$this->setViewState('AssociatedControlID',$value,'');
}
+
+ public function setFor($value)
+ {
+ $this->setAssociatedControlID($value);
+ }
+
+ public function getFor()
+ {
+ return $this->getAssociatedControlID();
+ }
}
?> \ No newline at end of file