From cba0c1b472cec22e4ffed2b3b084bea27cd26582 Mon Sep 17 00:00:00 2001 From: xue <> Date: Fri, 17 Feb 2006 21:14:12 +0000 Subject: Fixed #54. --- framework/Web/UI/TTemplateControl.php | 44 +++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 17 deletions(-) (limited to 'framework/Web/UI/TTemplateControl.php') 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; } /** @@ -166,18 +184,6 @@ class TTemplateControl extends TControl implements INamingContainer return $this->_master; } - /** - * 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. @@ -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); -- cgit v1.2.3