protected function &findHeadersByGroup($group = null, $nested = false)
{
$false = false;
$fields = array();
// Make sure there is a valid JForm XML document.
if (!$this->xml instanceof \SimpleXMLElement) {
return $false;
}
// Get only fields in a specific group?
if ($group) {
// Get the fields elements for a given group.
$elements =& $this->findHeader($group);
// Get all of the field elements for the fields elements.
/** @var \SimpleXMLElement $element */
foreach ($elements as $element) {
// If there are field elements add them to the return result.
if ($tmp = $element->xpath('descendant::header')) {
// If we also want fields in nested groups then just merge the arrays.
if ($nested) {
$fields = array_merge($fields, $tmp);
} else {
$groupNames = explode('.', $group);
foreach ($tmp as $field) {
// Get the names of the groups that the field is in.
$attrs = $field->xpath('ancestor::headers[@name]/@name');
$names = array_map('strval', $attrs ? $attrs : array());
// If the field is in the specific group then add it to the return list.
if ($names == (array) $groupNames) {
$fields = array_merge($fields, array($field));
}
}
}
}
}
} elseif ($group === false) {
// Get only field elements not in a group.
$fields = $this->xml->xpath('descendant::headers[not(@name)]/header | descendant::headers[not(@name)]/headerset/header ');
} else {
// Get an array of all the <header /> elements.
$fields = $this->xml->xpath('//header');
}
return $fields;
}