summaryrefslogtreecommitdiff
path: root/framework/Web
diff options
context:
space:
mode:
authorxue <>2006-02-26 16:40:43 +0000
committerxue <>2006-02-26 16:40:43 +0000
commit479683ba68d0b179105afd7e1f1d97b17730f7d3 (patch)
tree17763388f7242c5729b7bb17b8627da255a228ab /framework/Web
parentce75cf0aacdcf4e06c2c40fd2a15490ae7ad7c3e (diff)
Fixed a bug in rendering script files.
Diffstat (limited to 'framework/Web')
-rw-r--r--framework/Web/UI/TClientScriptManager.php49
-rw-r--r--framework/Web/UI/TPage.php1
-rw-r--r--framework/Web/UI/WebControls/THead.php7
-rw-r--r--framework/Web/UI/WebControls/TWizard.php6
4 files changed, 47 insertions, 16 deletions
diff --git a/framework/Web/UI/TClientScriptManager.php b/framework/Web/UI/TClientScriptManager.php
index eb7571ff..35ba224d 100644
--- a/framework/Web/UI/TClientScriptManager.php
+++ b/framework/Web/UI/TClientScriptManager.php
@@ -125,14 +125,30 @@ class TClientScriptManager extends TApplicationComponent
foreach(self::$_pradoScripts[$name] as $script)
{
$this->publishFilePath($basePath.'/'.$script.'.js');
- $this->_registeredPradoFiles[$script]=true;
+ $this->_registeredPradoFiles[$script]=false;
}
+ }
+ }
+
+ protected function renderPradoScripts($writer)
+ {
+ $files='';
+ foreach($this->_registeredPradoFiles as $file=>$rendered)
+ {
+ if(!$rendered)
+ {
+ $files.=','.$file;
+ $this->_registeredPradoFiles[$file]=true;
+ }
+ }
+ if($files!=='')
+ {
+ $basePath=Prado::getFrameworkPath().'/'.self::SCRIPT_PATH;
$scriptLoader=$basePath.'/'.self::SCRIPT_LOADER;
- $url=$this->publishFilePath($scriptLoader);
- $url.='?js='.implode(',',array_keys($this->_registeredPradoFiles));
+ $url=$this->publishFilePath($scriptLoader).'?js='.trim($files,',');
if($this->getApplication()->getMode()===TApplication::STATE_DEBUG)
$url.='&__nocache';
- $this->registerScriptFile('prado:pradoscripts',$url);
+ $writer->write(TJavaScript::renderScriptFile($url));
}
}
@@ -252,7 +268,8 @@ class TClientScriptManager extends TApplicationComponent
*/
public function registerScriptFile($key,$url)
{
- $this->_scriptFiles[$key]=$url;
+ if(!isset($this->_scriptFiles[$key]))
+ $this->_scriptFiles[$key]=$url;
}
/**
@@ -282,8 +299,7 @@ class TClientScriptManager extends TApplicationComponent
*/
public function registerHiddenField($name,$value)
{
- // if the named hidden field exists and has a value null, it means the hidden field is rendered already
- if(!isset($this->_hiddenFields[$name]) || $this->_hiddenFields[$name]!==null)
+ if(!isset($this->_hiddenFields[$name]))
$this->_hiddenFields[$name]=$value;
}
@@ -400,7 +416,18 @@ class TClientScriptManager extends TApplicationComponent
*/
public function renderScriptFiles($writer)
{
- $writer->write(TJavaScript::renderScriptFiles($this->_scriptFiles));
+ $this->renderPradoScripts($writer);
+ $files=array();
+ foreach($this->_scriptFiles as $key=>$file)
+ {
+ if($file!==true)
+ {
+ $files[]=$file;
+ $this->_scriptFiles[$key]=true;
+ }
+ }
+ if(!empty($files))
+ $writer->write(TJavaScript::renderScriptFiles($files));
}
/**
@@ -427,13 +454,13 @@ class TClientScriptManager extends TApplicationComponent
$str='';
foreach($this->_hiddenFields as $name=>$value)
{
- if($value!==null)
+ if($value!==true)
{
$value=THttpUtility::htmlEncode($value);
$str.="<input type=\"hidden\" name=\"$name\" id=\"$name\" value=\"$value\" />\n";
- // set hidden field value to null to indicate this field is rendered
+ // set hidden field value to true to indicate this field is rendered
// Note, hidden field rendering is invoked twice (at the beginning and ending of TForm)
- $this->_hiddenFields[$name]=null;
+ $this->_hiddenFields[$name]=true;
}
}
if($str!=='')
diff --git a/framework/Web/UI/TPage.php b/framework/Web/UI/TPage.php
index f0525e76..60397260 100644
--- a/framework/Web/UI/TPage.php
+++ b/framework/Web/UI/TPage.php
@@ -677,6 +677,7 @@ class TPage extends TTemplateControl
$this->_inFormRender=true;
$cs=$this->getClientScript();
$cs->renderHiddenFields($writer);
+ $cs->renderScriptFiles($writer);
$cs->renderBeginScripts($writer);
}
diff --git a/framework/Web/UI/WebControls/THead.php b/framework/Web/UI/WebControls/THead.php
index 48f436a3..ee2effeb 100644
--- a/framework/Web/UI/WebControls/THead.php
+++ b/framework/Web/UI/WebControls/THead.php
@@ -130,8 +130,11 @@ class THead extends TControl
$cs=$page->getClientScript();
$cs->renderStyleSheetFiles($writer);
$cs->renderStyleSheets($writer);
- $cs->renderHeadScriptFiles($writer);
- $cs->renderHeadScripts($writer);
+ if($page->getClientSupportsJavaScript())
+ {
+ $cs->renderHeadScriptFiles($writer);
+ $cs->renderHeadScripts($writer);
+ }
parent::render($writer);
$writer->write("</head>\n");
}
diff --git a/framework/Web/UI/WebControls/TWizard.php b/framework/Web/UI/WebControls/TWizard.php
index a8ed806f..eaf82e07 100644
--- a/framework/Web/UI/WebControls/TWizard.php
+++ b/framework/Web/UI/WebControls/TWizard.php
@@ -101,7 +101,7 @@
* @version v1.0, last update on Sat Dec 11 15:25:11 EST 2004
* @package System.Web.UI.WebControls
*/
-class TWizard extends TPanel implements INamingContainer
+class TWizard extends TWebControl implements INamingContainer
{
/**
* The command name for the OnNextCommand.
@@ -261,7 +261,7 @@ class TWizard extends TPanel implements INamingContainer
*/
public function setActiveStepIndex($index)
{
- $this->setViewState('ActiveStepIndex',$index,0);
+ $this->setViewState('ActiveStepIndex',TPropertyValue::ensureInteger($index),0);
}
/**
@@ -281,7 +281,7 @@ class TWizard extends TPanel implements INamingContainer
* is the TWizard.
* @param object a component object.
*/
- public function addParsedObject($object,$context)
+ public function addParsedObject($object)
{
if($object instanceof TWizardStep)
{