diff options
author | xue <> | 2006-05-04 02:36:22 +0000 |
---|---|---|
committer | xue <> | 2006-05-04 02:36:22 +0000 |
commit | a14913019919d7b6c2d13769b151a645b5226e02 (patch) | |
tree | 6a52d262a2d400cf1097ddc23e912d7e32f8715d /framework/Web/UI/TTemplateManager.php | |
parent | 57284b8cfbd15a04d8a23f324e76f694d6bd3dfe (diff) |
Fixed an issue about instantiating a template: direct child controls are added to page hierarchy at the last.
Diffstat (limited to 'framework/Web/UI/TTemplateManager.php')
-rw-r--r-- | framework/Web/UI/TTemplateManager.php | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/framework/Web/UI/TTemplateManager.php b/framework/Web/UI/TTemplateManager.php index 86567243..ee38405b 100644 --- a/framework/Web/UI/TTemplateManager.php +++ b/framework/Web/UI/TTemplateManager.php @@ -259,6 +259,7 @@ class TTemplate extends TApplicationComponent implements ITemplate if(($page=$tplControl->getPage())===null)
$page=$this->getService()->getRequestedPage();
$controls=array();
+ $directChildren=array();
foreach($this->_tpl as $key=>$object)
{
$parent=isset($controls[$object[0]])?$controls[$object[0]]:$tplControl;
@@ -290,7 +291,10 @@ class TTemplate extends TApplicationComponent implements ITemplate // apply attributes
foreach($properties as $name=>$value)
$this->configureControl($component,$name,$value);
- $component->createdOnTemplate($parent);
+ if($parent===$tplControl)
+ $directChildren[]=$component;
+ else
+ $component->createdOnTemplate($parent);
}
else if($component instanceof TComponent)
{
@@ -304,7 +308,10 @@ class TTemplate extends TApplicationComponent implements ITemplate }
foreach($properties as $name=>$value)
$this->configureComponent($component,$name,$value);
- $parent->addParsedObject($component);
+ if($parent===$tplControl)
+ $directChildren[]=$component;
+ else
+ $parent->addParsedObject($component);
}
}
else // string
@@ -314,12 +321,30 @@ class TTemplate extends TApplicationComponent implements ITemplate // need to clone a new object because the one in template is reused
$o=clone $object[1];
$o->setContainer($tplControl);
- $parent->addParsedObject($o);
+ if($parent===$tplControl)
+ $directChildren[]=$o;
+ else
+ $parent->addParsedObject($o);
}
else
- $parent->addParsedObject($object[1]);
+ {
+ if($parent===$tplControl)
+ $directChildren[]=$object[1];
+ else
+ $parent->addParsedObject($object[1]);
+ }
}
}
+ // delay setting parent till now because the parent may cause
+ // the child to do lifecycle catchup which may cause problem
+ // if the child needs its own child controls.
+ foreach($directChildren as $control)
+ {
+ if($control instanceof TControl)
+ $control->createdOnTemplate($tplControl);
+ else
+ $tplControl->addParsedObject($control);
+ }
}
/**
|