mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 17:14:44 +01:00
- Add getElementsByType() function
- Handle ids that end in []
This commit is contained in:
parent
448f256985
commit
3bce9fccc3
@ -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)));
|
||||
|
Loading…
Reference in New Issue
Block a user