/**
* Gets the active option's label given an array of JHtml options
*
* @param array $data The JHtml options to parse
* @param mixed $selected The currently selected value
* @param string $groupKey Group name
* @param string $optKey Key name
* @param string $optText Value name
*
* @return mixed The label of the currently selected option
*/
public static function getOptionName($data, $selected = null, $groupKey = 'items', $optKey = 'value', $optText = 'text')
{
if ($groupKey) {
}
// Keeps phpStorm from freaking out
$ret = null;
foreach ($data as $dataKey => $group) {
if (is_array($group)) {
$label = $group[$optText];
$noGroup = false;
} elseif (is_object($group)) {
// Sub-list is in a property of an object
$label = $group->{$optText};
$noGroup = false;
} else {
throw new InvalidGroupContents(get_called_class());
}
if ($noGroup) {
$label = '';
}
$match = GenericList::getOptionName($data, $selected, $optKey, $optText);
if (!is_null($match)) {
$ret = array('group' => $label, 'item' => $match);
break;
}
}
return $ret;
}