public function ensureTemplateDecoration($sender = null, $param = null)
{
$control = $this->_control;
$outercontrol = $this->_outercontrol;
if ($outercontrol === null) {
$outercontrol = $control;
}
if ($this->_addedTemplateDecoration) {
return $this->_addedTemplateDecoration;
}
$this->_addedTemplateDecoration = true;
if ($this->getPreContentsTemplate()) {
$precontents = new TCompositeControl();
$this->getPreContentsTemplate()->instantiateIn($precontents);
$control->getControls()->insertAt(0, $precontents);
}
if ($this->getPostContentsTemplate()) {
$postcontents = new TCompositeControl();
$this->getPostContentsTemplate()->instantiateIn($postcontents);
$control->getControls()->add($postcontents);
}
if (!$outercontrol->getParent()) {
return $this->_addedTemplateDecoration;
}
if ($this->getPreTagTemplate()) {
$pretag = new TCompositeControl();
$this->getPreTagTemplate()->instantiateIn($pretag);
$outercontrol->getParent()->getControls()->insertBefore($outercontrol, $pretag);
}
if ($this->getPostTagTemplate()) {
$posttag = new TCompositeControl();
$this->getPostTagTemplate()->instantiateIn($posttag);
$outercontrol->getParent()->getControls()->insertAfter($outercontrol, $posttag);
}
return true;
}