summaryrefslogtreecommitdiff
path: root/framework/Web
diff options
context:
space:
mode:
authorxue <>2006-02-17 21:14:12 +0000
committerxue <>2006-02-17 21:14:12 +0000
commitcba0c1b472cec22e4ffed2b3b084bea27cd26582 (patch)
tree9a8f8383a93ebb011757423bfc8b39066cb017ea /framework/Web
parent35836e45fab30dc4c31a4f51e32b551181e7ec86 (diff)
Fixed #54.
Diffstat (limited to 'framework/Web')
-rw-r--r--framework/Web/UI/TControl.php2
-rw-r--r--framework/Web/UI/TTemplateControl.php44
-rw-r--r--framework/Web/UI/WebControls/TContent.php2
-rw-r--r--framework/Web/UI/WebControls/TContentPlaceHolder.php5
4 files changed, 32 insertions, 21 deletions
diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php
index d1ae189a..dbe4a233 100644
--- a/framework/Web/UI/TControl.php
+++ b/framework/Web/UI/TControl.php
@@ -1053,6 +1053,8 @@ class TControl extends TApplicationComponent
$control->_stage=self::CS_CONSTRUCTED;
if(!($control->_flags & self::IS_ID_SET))
$control->_id='';
+ else
+ unset($this->_rf[self::RF_NAMED_OBJECTS][$control->_id]);
$control->clearCachedUniqueID(true);
}
diff --git a/framework/Web/UI/TTemplateControl.php b/framework/Web/UI/TTemplateControl.php
index d6ccb825..2d6829ee 100644
--- a/framework/Web/UI/TTemplateControl.php
+++ b/framework/Web/UI/TTemplateControl.php
@@ -135,11 +135,29 @@ class TTemplateControl extends TControl implements INamingContainer
/**
* Registers a content control.
+ * @param string ID of the content
* @param TContent
*/
- public function registerContent(TContent $object)
+ public function registerContent($id,TContent $object)
{
- $this->_contents[$object->getID()]=$object;
+ if(isset($this->_contents[$id]))
+ throw new TConfigurationException('templatecontrol_contentid_duplicated',$id);
+ else
+ $this->_contents[$id]=$object;
+ }
+
+ /**
+ * Registers a content placeholder to this template control.
+ * This method should only be used by framework and control developers.
+ * @param string placeholder ID
+ * @param TContentPlaceHolder placeholder control
+ */
+ public function registerContentPlaceHolder($id,TContentPlaceHolder $object)
+ {
+ if(isset($this->_contents[$id]))
+ throw new TConfigurationException('templatecontrol_placeholderid_duplicated',$id);
+ else
+ $this->_placeholders[$id]=$object;
}
/**
@@ -167,18 +185,6 @@ class TTemplateControl extends TControl implements INamingContainer
}
/**
- * Registers a content placeholder to this template control.
- * This method should only be used by framework and control developers.
- * @param string ID of the placeholder
- * @param TControl control that directly enloses the placeholder
- * @param integer the index in the control list of the parent control that the placeholder is at
- */
- public function registerContentPlaceHolder($id,$parent,$loc)
- {
- $this->_placeholders[$id]=array($parent,$loc);
- }
-
- /**
* Injects all content controls (and their children) to the corresponding content placeholders.
* This method should only be used by framework and control developers.
* @param string ID of the content control
@@ -188,8 +194,12 @@ class TTemplateControl extends TControl implements INamingContainer
{
if(isset($this->_placeholders[$id]))
{
- list($parent,$loc)=$this->_placeholders[$id];
- $parent->getControls()->insertAt($loc,$content);
+ $placeholder=$this->_placeholders[$id];
+ $controls=$placeholder->getParent()->getControls();
+ $loc=$controls->remove($placeholder);
+ $controls->insertAt($loc,$content);
+ //list($parent,$loc)=$this->_placeholders[$id];
+ //$parent->getControls()->insertAt($loc,$content);
}
}
@@ -208,7 +218,7 @@ class TTemplateControl extends TControl implements INamingContainer
{
$master=Prado::createComponent($this->_masterClass);
if(!($master instanceof TTemplateControl))
- throw new TInvalidDataValueException('tplcontrol_required',get_class($master));
+ throw new TInvalidDataValueException('templatecontrol_mastercontrol_invalid');
$this->_master=$master;
$this->getControls()->clear();
$this->getControls()->add($master);
diff --git a/framework/Web/UI/WebControls/TContent.php b/framework/Web/UI/WebControls/TContent.php
index f2c6f0ac..0ccc57f8 100644
--- a/framework/Web/UI/WebControls/TContent.php
+++ b/framework/Web/UI/WebControls/TContent.php
@@ -41,7 +41,7 @@ class TContent extends TControl implements INamingContainer
{
if(($id=$this->getID())==='')
throw new TConfigurationException('content_id_required');
- $this->getTemplateControl()->registerContent($this);
+ $this->getTemplateControl()->registerContent($id,$this);
}
}
diff --git a/framework/Web/UI/WebControls/TContentPlaceHolder.php b/framework/Web/UI/WebControls/TContentPlaceHolder.php
index a13e85bc..9cf5068c 100644
--- a/framework/Web/UI/WebControls/TContentPlaceHolder.php
+++ b/framework/Web/UI/WebControls/TContentPlaceHolder.php
@@ -41,9 +41,8 @@ class TContentPlaceHolder extends TControl
{
if(($id=$this->getID())==='')
throw new TConfigurationException('contentplaceholder_id_required');
- $loc=$parent->getHasControls()?$parent->getControls()->getCount():0;
- $this->getTemplateControl()->registerContentPlaceHolder($id,$parent,$loc);
- $parent->unregisterObject($id);
+ $this->getTemplateControl()->registerContentPlaceHolder($id,$this);
+ $parent->getControls()->add($this);
}
}