diff --git a/etemplate/inc/class.etemplate_widget.inc.php b/etemplate/inc/class.etemplate_widget.inc.php index 668f105131..578e082e6b 100644 --- a/etemplate/inc/class.etemplate_widget.inc.php +++ b/etemplate/inc/class.etemplate_widget.inc.php @@ -300,6 +300,26 @@ class etemplate_widget return null; } + /** + * Iterate over children to find the one with the given id and optional type + * + * @param string $type + * @return etemplate_widget or NULL + */ + public function getElementsByType($type) + { + $elements = array(); + foreach($this->children as $child) + { + if ($child->type === $type) + { + $elements[] = $child; + } + $elements += $child->getElementsByType($type, $subclass_ok); + } + return $elements; + } + /** * Run a given method on all children * @@ -566,6 +586,12 @@ class etemplate_widget // Make sure none of these are left $idx = str_replace(array('[',']'),array('[',']'),$idx); + // Handle things expecting arrays - ends in [] + if(substr($idx,-2) == "[]") + { + $idx = substr($idx,0,-2); + } + if (count($idxs = explode('[', $idx, 2)) > 1) { $idxs = array_merge(array($idxs[0]), explode('][', substr($idxs[1],0,-1)));