protected function getGroups() { // Initialize variables. $groups = array(); // Initialize some field attributes. $menuType = (string) $this->element['menu_type']; $published = $this->element['published'] ? explode(',', (string) $this->element['published']) : array(); $disable = $this->element['disable'] ? explode(',', (string) $this->element['disable']) : array(); $language = $this->element['language'] ? explode(',', (string) $this->element['language']) : array(); // Get the menu items. $items = MenusHelper::getMenuLinks($menuType, 0, 0, $published, $language); // Build group for a specific menu type. if ($menuType) { // Initialize the group. $groups[$menuType] = array(); // Build the options array. foreach ($items as $link) { $groups[$menuType][] = MHtml::_('select.option', $link->value, $link->text, 'value', 'text', in_array($link->type, $disable)); } } else { // Build the groups arrays. foreach ($items as $menu) { // Initialize the group. $groups[$menu->menutype] = array(); // Build the options array. foreach ($menu->links as $link) { $groups[$menu->menutype][] = MHtml::_('select.option', $link->value, $link->text, 'value', 'text', in_array($link->type, $disable)); } } } // Merge any additional groups in the XML definition. $groups = array_merge(parent::getGroups(), $groups); return $groups; }
protected function getGroups() { // Initialize variables. $groups = array(); $keyField = $this->element['key_field'] ? (string) $this->element['key_field'] : 'id'; $keyValue = $this->form->getValue($keyField); // If the timezone is not set use the server setting. if (strlen($this->value) == 0 && empty($keyValue)) { $this->value = MFactory::getConfig()->get('offset'); } // Get the list of time zones from the server. $zones = DateTimeZone::listIdentifiers(); // Build the group lists. foreach ($zones as $zone) { // Time zones not in a group we will ignore. if (strpos($zone, '/') === false) { continue; } // Get the group/locale from the timezone. list($group, $locale) = explode('/', $zone, 2); // Only use known groups. if (in_array($group, self::$zones)) { // Initialize the group if necessary. if (!isset($groups[$group])) { $groups[$group] = array(); } // Only add options where a locale exists. if (!empty($locale)) { $groups[$group][$zone] = MHtml::_('select.option', $zone, str_replace('_', ' ', $locale), 'value', 'text', false); } } } // Sort the group lists. ksort($groups); foreach ($groups as $zone => &$location) { sort($location); } // Merge any additional groups in the XML definition. $groups = array_merge(parent::getGroups(), $groups); return $groups; }