summaryrefslogtreecommitdiff
path: root/framework/Web/UI/TTemplateControl.php
diff options
context:
space:
mode:
authorxue <>2006-01-29 05:44:51 +0000
committerxue <>2006-01-29 05:44:51 +0000
commit65323da89d6e3b2ecaed04fa45eed35f67c28a11 (patch)
treef0b953e479f95c8aa9efcd837ecfbee57559c445 /framework/Web/UI/TTemplateControl.php
parentf8a6ad7273f2abd3c5c176910b63532b990446ca (diff)
Changed how template controls initialize their properties.
Diffstat (limited to 'framework/Web/UI/TTemplateControl.php')
-rw-r--r--framework/Web/UI/TTemplateControl.php31
1 files changed, 11 insertions, 20 deletions
diff --git a/framework/Web/UI/TTemplateControl.php b/framework/Web/UI/TTemplateControl.php
index 72731ecd..79ada7d4 100644
--- a/framework/Web/UI/TTemplateControl.php
+++ b/framework/Web/UI/TTemplateControl.php
@@ -55,30 +55,17 @@ class TTemplateControl extends TControl implements INamingContainer
private $_placeholders=array();
/**
- * Constructor.
- * Loads template for the control class if not loaded.
- * Applies template directive if any.
- */
- public function __construct()
- {
- if(($tpl=$this->getTemplate(true))!==null)
- {
- foreach($tpl->getDirective() as $name=>$value)
- $this->setSubProperty($name,$value);
- }
- }
-
- /**
- * @param boolean whether to attempt loading template if it is not loaded yet
+ * Returns the template object associated with this control object.
* @return ITemplate|null the parsed template, null if none
*/
- public function getTemplate($load=false)
+ public function getTemplate()
{
if($this->_localTemplate===null)
{
$class=get_class($this);
- $tpl=isset(self::$_template[$class])?self::$_template[$class]:null;
- return ($tpl===null && $load)?$this->loadTemplate():$tpl;
+ if(!isset(self::$_template[$class]))
+ self::$_template[$class]=$this->loadTemplate();
+ return self::$_template[$class];
}
else
return $this->_localTemplate;
@@ -96,7 +83,7 @@ class TTemplateControl extends TControl implements INamingContainer
}
/**
- * Loads and parses the control template
+ * Loads the template associated with this control class.
* @return ITemplate the parsed template structure
*/
protected function loadTemplate()
@@ -114,8 +101,12 @@ class TTemplateControl extends TControl implements INamingContainer
*/
protected function createChildControls()
{
- if($tpl=$this->getTemplate())
+ if($tpl=$this->getTemplate(true))
+ {
+ foreach($tpl->getDirective() as $name=>$value)
+ $this->setSubProperty($name,$value);
$tpl->instantiateIn($this);
+ }
}
/**