From 1c9aa17d682ae92e2e8687ab40916075470830f7 Mon Sep 17 00:00:00 2001 From: xue <> Date: Wed, 4 Jan 2006 02:53:33 +0000 Subject: Added findControlsByType(). --- framework/Web/UI/TControl.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php index 1663b783..34e9b92f 100644 --- a/framework/Web/UI/TControl.php +++ b/framework/Web/UI/TControl.php @@ -808,6 +808,27 @@ class TControl extends TComponent } } + /** + * Finds all child and grand-child controls that are of the specified type. + * @param string the class name + * @return array list of controls found + */ + public function findControlsByType($type) + { + $controls=array(); + if($this->getHasControls()) + { + foreach($this->_rf[self::RF_CONTROLS] as $control) + { + if($control instanceof $type) + $controls[]=$control; + if(($control instanceof TControl) && $control->getHasControls()) + $controls=array_merge($controls,$control->findControlsByType($type)); + } + } + return $controls; + } + /** * Resets the control as a naming container. * Only framework developers should use this method. -- cgit v1.2.3