本文整理汇总了PHP中JFormFieldGroupedList::_getGroups方法的典型用法代码示例。如果您正苦于以下问题:PHP JFormFieldGroupedList::_getGroups方法的具体用法?PHP JFormFieldGroupedList::_getGroups怎么用?PHP JFormFieldGroupedList::_getGroups使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFormFieldGroupedList
的用法示例。
在下文中一共展示了JFormFieldGroupedList::_getGroups方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getGroups
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function _getGroups()
{
// Get the attributes
$menuType = (string) $this->_element->attributes()->menu_type;
$published = (string) $this->_element->attributes()->published ? explode(',', (string) $this->_element->attributes()->published) : array();
$disable = (string) $this->_element->attributes()->disable ? explode(',', (string) $this->_element->attributes()->disable) : array();
// Get the com_menus helper
require_once realpath(JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php');
// Get the items
$items = MenusHelper::getMenuLinks($menuType, 0, 0, $published);
// Prepare return value
$groups = array();
// If a menu type was set
if ($menuType) {
$groups[$menuType] = array();
// Loop over links
foreach ($items as $link) {
// Generate an option disabling it if it's the case
$groups[$menuType][] = JHtml::_('select.option', $link->value, $link->text, 'value', 'text', in_array($link->type, $disable));
}
} else {
// Loop over types
foreach ($items as $menu) {
$groups[$menu->menutype] = array();
// Loop over links
foreach ($menu->links as $link) {
// Generate an option disabling it if it's the case
$groups[$menu->menutype][] = JHtml::_('select.option', $link->value, $link->text, 'value', 'text', in_array($link->type, $disable));
}
}
}
// Merge any additional options in the XML definition.
$groups = array_merge(parent::_getGroups(), $groups);
return $groups;
}
示例2: _getGroups
/**
* Method to get the field input.
*
* @return string The field input.
*/
protected function _getGroups()
{
$client = $this->_element->attributes('client');
$client_id = $client == 'administrator' ? 1 : 0;
$db = JFactory::getDBO();
$query = new JQuery();
$query->select($db->nameQuote('id'));
$query->select($db->nameQuote('title'));
$query->select($db->nameQuote('template'));
$query->from($db->nameQuote('#__template_styles'));
$query->where($db->nameQuote('client_id') . '=' . (int) $client_id);
$query->order($db->nameQuote('template'));
$query->order($db->nameQuote('title'));
$db->setQuery($query);
$styles = $db->loadObjectList();
// Pre-process into groups.
$last = null;
$groups = array();
foreach ($styles as $style) {
if ($style->template != $last) {
$last = $style->template;
$groups[$last] = array();
}
$groups[$last][] = JHtml::_('select.option', $style->id, $style->title);
}
// Merge any additional options in the XML definition.
$groups = array_merge(parent::_getGroups(), $groups);
return $groups;
}
示例3: _getGroups
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function _getGroups()
{
if (strlen($this->value) == 0) {
$conf =& JFactory::getConfig();
$value = $conf->getValue('config.offset');
}
$zones = DateTimeZone::listIdentifiers();
foreach ($zones as $zone) {
// 0 => Continent, 1 => City
$zone = explode('/', $zone);
// Only use "friendly" continent names
if ($zone[0] == 'Africa' || $zone[0] == 'America' || $zone[0] == 'Antarctica' || $zone[0] == 'Arctic' || $zone[0] == 'Asia' || $zone[0] == 'Atlantic' || $zone[0] == 'Australia' || $zone[0] == 'Europe' || $zone[0] == 'Indian' || $zone[0] == 'Pacific') {
if (isset($zone[1]) != '') {
// Creates array(DateTimeZone => 'Friendly name')
$groups[$zone[0]][$zone[0] . '/' . $zone[1]] = str_replace('_', ' ', $zone[1]);
}
}
}
// Sort the arrays
ksort($groups);
foreach ($groups as $zone => $location) {
sort($location);
}
// Merge any additional options in the XML definition.
$groups = array_merge(parent::_getGroups(), $groups);
return $groups;
}