summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxue <>2006-01-29 05:44:51 +0000
committerxue <>2006-01-29 05:44:51 +0000
commit65323da89d6e3b2ecaed04fa45eed35f67c28a11 (patch)
treef0b953e479f95c8aa9efcd837ecfbee57559c445
parentf8a6ad7273f2abd3c5c176910b63532b990446ca (diff)
Changed how template controls initialize their properties.
-rw-r--r--framework/Web/UI/TPage.php9
-rw-r--r--framework/Web/UI/TTemplateControl.php31
2 files changed, 15 insertions, 25 deletions
diff --git a/framework/Web/UI/TPage.php b/framework/Web/UI/TPage.php
index 28f1b036..a5e4fa52 100644
--- a/framework/Web/UI/TPage.php
+++ b/framework/Web/UI/TPage.php
@@ -111,11 +111,13 @@ class TPage extends TTemplateControl
private $_previousPagePath='';
/**
- * Constructor, overrides parent implementation. Parent constructor called in initializeProperties.
+ * Constructor.
+ * Sets the page object to itself.
*/
public function __construct()
{
-
+ parent::__construct();
+ $this->setPage($this);
}
/**
@@ -125,15 +127,12 @@ class TPage extends TTemplateControl
public function initializeProperties($initProperties=null)
{
Prado::trace('Constructing page','System.Web.UI.TPage');
- $this->setPage($this);
if(is_array($initProperties))
{
Prado::trace('Initializing page properties specified in configurations','System.Web.UI.TPage');
foreach($initProperties as $name=>$value)
$this->setSubProperty($name,$value);
}
- //ask template control to initialize
- parent::__construct();
}
/**
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);
+ }
}
/**