summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxue <>2006-08-28 02:21:48 +0000
committerxue <>2006-08-28 02:21:48 +0000
commit5a55bca3e31f4cefa2b3fa6e854431db91528837 (patch)
tree5e3ac35cce2397059e9165cc1edcc7faf8988ba5
parent304427074ddf629fd2708b23a3fe0cd0122c05a8 (diff)
Moved createdOnTemplate() and addParsedObject() from TControl to TComponent so that template instantiation is more consistent among non-control components and controls.
-rw-r--r--HISTORY1
-rw-r--r--framework/TComponent.php26
-rw-r--r--framework/Web/UI/TControl.php22
-rw-r--r--framework/Web/UI/TTemplateManager.php7
4 files changed, 33 insertions, 23 deletions
diff --git a/HISTORY b/HISTORY
index 3de56f39..aadb3ee6 100644
--- a/HISTORY
+++ b/HISTORY
@@ -10,6 +10,7 @@ ENH: Input controls in some datagrid columns can now be accessed in a named fash
CHG: Unify all client-side javascript event handler syntax. (Wei)
CHG: Added more conditions in the requirement checker (Qiang)
CHG: TControl::findControlsByType() now only returns objects of the specified type (Qiang)
+CHG: Moved createdOnTemplate() and addParsedObject() from TControl to TComponent (Qiang)
Version 3.0.3 August 6, 2006
============================
diff --git a/framework/TComponent.php b/framework/TComponent.php
index 7564edff..21a62abd 100644
--- a/framework/TComponent.php
+++ b/framework/TComponent.php
@@ -415,6 +415,32 @@ class TComponent
throw new TInvalidOperationException('component_statements_invalid',get_class($this),$statements,$e->getMessage());
}
}
+
+ /**
+ * This method is invoked after the component is instantiated by a template.
+ * When this method is invoked, the component's properties have been initialized.
+ * The default implementation of this method will invoke
+ * the potential parent component's {@link addParsedObject}.
+ * This method can be overriden.
+ * @param TComponent potential parent of this control
+ * @see addParsedObject
+ */
+ public function createdOnTemplate($parent)
+ {
+ $parent->addParsedObject($this);
+ }
+
+ /**
+ * Processes an object that is created during parsing template.
+ * The object can be either a component or a static text string.
+ * This method can be overriden to customize the handling of newly created objects in template.
+ * Only framework developers and control developers should use this method.
+ * @param string|TComponent text string or component parsed and instantiated in template
+ * @see createdOnTemplate
+ */
+ public function addParsedObject($object)
+ {
+ }
}
/**
diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php
index d13b94cf..ecaf300c 100644
--- a/framework/Web/UI/TControl.php
+++ b/framework/Web/UI/TControl.php
@@ -1041,26 +1041,8 @@ class TControl extends TApplicationComponent implements IRenderable, IBindable
}
/**
- * This method is invoked after the control is instantiated by a template.
- * When this method is invoked, the control should have a valid TemplateControl
- * and has its properties initialized according to template configurations.
- * The control, however, has not been added to the page hierarchy yet.
- * The default implementation of this method will invoke
- * the potential parent control's {@link addParsedObject} to add the control as a child.
- * This method can be overriden.
- * @param TControl potential parent of this control
- * @see addParsedObject
- */
- public function createdOnTemplate($parent)
- {
- $parent->addParsedObject($this);
- }
-
- /**
- * Processes an object that is created during parsing template.
- * The object can be either a component or a static text string.
- * By default, the object will be added into the child control collection.
- * This method can be overriden to customize the handling of newly created objects in template.
+ * Adds the object instantiated on a template to the child control collection.
+ * This method overrides the parent implementation.
* Only framework developers and control developers should use this method.
* @param string|TComponent text string or component parsed and instantiated in template
* @see createdOnTemplate
diff --git a/framework/Web/UI/TTemplateManager.php b/framework/Web/UI/TTemplateManager.php
index 1fde4acc..79c163fb 100644
--- a/framework/Web/UI/TTemplateManager.php
+++ b/framework/Web/UI/TTemplateManager.php
@@ -266,7 +266,7 @@ class TTemplate extends TApplicationComponent implements ITemplate
foreach($this->_tpl as $key=>$object)
{
$parent=isset($controls[$object[0]])?$controls[$object[0]]:$tplControl;
- if(!$parent->getAllowChildControls())
+ if(($parent instanceof TControl) && !$parent->getAllowChildControls())
continue;
if(isset($object[2])) // component
{
@@ -301,6 +301,7 @@ class TTemplate extends TApplicationComponent implements ITemplate
}
else if($component instanceof TComponent)
{
+ $controls[$key]=$component;
if(isset($properties['id']))
{
if(is_array($properties['id']))
@@ -314,7 +315,7 @@ class TTemplate extends TApplicationComponent implements ITemplate
if($parent===$tplControl)
$directChildren[]=$component;
else
- $parent->addParsedObject($component);
+ $component->createdOnTemplate($parent);
}
}
else // string
@@ -343,7 +344,7 @@ class TTemplate extends TApplicationComponent implements ITemplate
// if the child needs its own child controls.
foreach($directChildren as $control)
{
- if($control instanceof TControl)
+ if($control instanceof TComponent)
$control->createdOnTemplate($tplControl);
else
$tplControl->addParsedObject($control);