summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxue <>2006-04-09 17:12:45 +0000
committerxue <>2006-04-09 17:12:45 +0000
commit46dd185faab6a0387face5700c4b69c69f9f933c (patch)
tree70542df9111a8aaae00869081f5f7187c43b9aac
parentbfa60270a735a7a08a545a9bc1c972e8bf0bc590 (diff)
Cache key for TOutputCache now also uses PagePath.
-rw-r--r--framework/Exceptions/messages.txt1
-rw-r--r--framework/Web/UI/TClientScriptManager.php4
-rw-r--r--framework/Web/UI/TTemplateManager.php21
-rw-r--r--framework/Web/UI/WebControls/TOutputCache.php12
4 files changed, 23 insertions, 15 deletions
diff --git a/framework/Exceptions/messages.txt b/framework/Exceptions/messages.txt
index 237145df..a7a5c724 100644
--- a/framework/Exceptions/messages.txt
+++ b/framework/Exceptions/messages.txt
@@ -118,6 +118,7 @@ template_property_duplicated = Property {0} is configured twice or more.
template_eventhandler_invalid = {0}.{1} can only accept a static string.
template_controlid_invalid = {0}.ID can only accept a static text string.
template_controlskinid_invalid = {0}.SkinID can only accept a static text string.
+template_content_unexpected = Unexpected content is encountered when instantiating template: {0}.
xmldocument_file_read_failed = TXmlDocument is unable to read file '{0}'.
xmldocument_file_write_failed = TXmlDocument is unable to write file '{0}'.
diff --git a/framework/Web/UI/TClientScriptManager.php b/framework/Web/UI/TClientScriptManager.php
index cb945fbf..94ef19b6 100644
--- a/framework/Web/UI/TClientScriptManager.php
+++ b/framework/Web/UI/TClientScriptManager.php
@@ -171,8 +171,8 @@ class TClientScriptManager extends TApplicationComponent
*/
public function registerPostBackControl($jsClass,$options)
{
- if(!isset($options['FormID']))
- $options['FormID']=$this->_page->getForm()->getClientID();
+ if(!isset($options['FormID']) && ($form=$this->_page->getForm())!==null)
+ $options['FormID']=$form->getClientID();
$optionString=TJavaScript::encode($options);
$code="new $jsClass($optionString);";
diff --git a/framework/Web/UI/TTemplateManager.php b/framework/Web/UI/TTemplateManager.php
index 07d65fd0..7961a121 100644
--- a/framework/Web/UI/TTemplateManager.php
+++ b/framework/Web/UI/TTemplateManager.php
@@ -289,11 +289,11 @@ class TTemplate extends TApplicationComponent implements ITemplate
if(isset($object[2])) // component
{
$component=Prado::createComponent($object[1]);
- if($component instanceof TOutputCache)
- $component->setCacheKeyPrefix($this->_hashCode.$key);
$properties=&$object[2];
if($component instanceof TControl)
{
+ if($component instanceof TOutputCache)
+ $component->setCacheKeyPrefix($this->_hashCode.$key);
$component->setTemplateControl($tplControl);
if(isset($properties['id']))
{
@@ -332,17 +332,16 @@ class TTemplate extends TApplicationComponent implements ITemplate
$parent->addParsedObject($component);
}
}
- else // string
+ else if(is_string($object[1]))
+ $parent->addParsedObject($object[1]);
+ else if($object[1] instanceof TCompositeLiteral)
{
- if($object[1] instanceof TCompositeLiteral)
- {
- $o=clone $object[1];
- $o->setContainer($tplControl);
- $parent->addParsedObject($o);
- }
- else
- $parent->addParsedObject($object[1]);
+ $o=clone $object[1];
+ $o->setContainer($tplControl);
+ $parent->addParsedObject($o);
}
+ else
+ throw new TConfigurationException('template_content_unexpected',(string)$object[1]);
}
}
diff --git a/framework/Web/UI/WebControls/TOutputCache.php b/framework/Web/UI/WebControls/TOutputCache.php
index a19965b0..76d74b47 100644
--- a/framework/Web/UI/WebControls/TOutputCache.php
+++ b/framework/Web/UI/WebControls/TOutputCache.php
@@ -257,10 +257,18 @@ class TOutputCache extends TControl implements INamingContainer
$name=trim($name);
$params[$name]=$request->itemAt($name);
}
- return self::CACHE_ID_PREFIX.$this->_keyPrefix.$this->getUniqueID().serialize($params);
+ return $this->getBaseCacheKey().serialize($params);
}
else
- return self::CACHE_ID_PREFIX.$this->_keyPrefix.$this->getUniqueID();
+ return $this->getBaseCacheKey();
+ }
+
+ /**
+ * @return string basic cache key without variations
+ */
+ protected function getBaseCacheKey()
+ {
+ return self::CACHE_ID_PREFIX.$this->_keyPrefix.$this->getPage()->getPagePath().$this->getUniqueID();
}
/**