summaryrefslogtreecommitdiff
path: root/framework/Web/UI/TControl.php
diff options
context:
space:
mode:
authorxue <>2006-02-14 21:01:40 +0000
committerxue <>2006-02-14 21:01:40 +0000
commitcd1ffb47a6c07deda47052eff80452e78a52495d (patch)
tree9343fb60d1d24972ef8bd520f82c4462815ade4f /framework/Web/UI/TControl.php
parent30c5e1627a4e94af98866911af98ddfe9316042b (diff)
Added TControl::traverseChildControls().
Diffstat (limited to 'framework/Web/UI/TControl.php')
-rw-r--r--framework/Web/UI/TControl.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php
index 660b1c4c..50648d93 100644
--- a/framework/Web/UI/TControl.php
+++ b/framework/Web/UI/TControl.php
@@ -1239,6 +1239,41 @@ class TControl extends TComponent
}
/**
+ * Traverse the whole control hierarchy rooted at this control.
+ * Callback function may be invoked for each control being visited.
+ * A pre-callback is invoked before traversing child controls;
+ * A post-callback is invoked after traversing child controls.
+ * Callback functions can be global functions or class methods.
+ * They must be of the following signature:
+ * <code>
+ * function callback_func($control,$param) {...}
+ * </code>
+ * where $control refers to the control being visited and $param
+ * is the parameter that is passed originally when calling this traverse function.
+ *
+ * @param mixed parameter to be passed to callbacks for each control
+ * @param callback callback invoked before traversing child controls. If null, it is ignored.
+ * @param callback callback invoked after traversing child controls. If null, it is ignored.
+ */
+ protected function traverseChildControls($param,$preCallback=null,$postCallback=null)
+ {
+ if($preCallback!==null)
+ call_user_func($preCallback,$this,$param);
+ if($this->getHasControls())
+ {
+ foreach($this->_rf[self::RF_CONTROLS] as $control)
+ {
+ if($control instanceof TControl)
+ {
+ $control->traverseChildControls($param,$preCallback,$postCallback);
+ }
+ }
+ }
+ if($postCallback!==null)
+ call_user_func($postCallback,$this,$param);
+ }
+
+ /**
* Renders the control.
* Only when the control is visible will the control be rendered.
* @param THtmlWriter the writer used for the rendering purpose