本文整理汇总了PHP中JFormFieldGroupedList类的典型用法代码示例。如果您正苦于以下问题:PHP JFormFieldGroupedList类的具体用法?PHP JFormFieldGroupedList怎么用?PHP JFormFieldGroupedList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JFormFieldGroupedList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetInput
/**
* Test the getInput method.
*
* @return void
*
* @since 12.1
*/
public function testGetInput()
{
$form = new JFormInspector('form1');
$this->assertThat(
$form->load('<form><field name="groupedlist" type="groupedlist" /></form>'),
$this->isTrue(),
'Line:' . __LINE__ . ' XML string should load successfully.'
);
$field = new JFormFieldGroupedList($form);
$this->assertThat(
$field->setup($form->getXml()->field, 'value'),
$this->isTrue(),
'Line:' . __LINE__ . ' The setup method should return true.'
);
$this->assertThat(
strlen($field->input),
$this->greaterThan(0),
'Line:' . __LINE__ . ' The getInput method should return something without error.'
);
// TODO: Should check all the attributes have come in properly.
}
示例2: _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;
}
示例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;
}
示例4: _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;
}
示例5: getGroups
protected function getGroups()
{
// @task: Since most of the modules uses this element, we inject the beautifier codes here.
JFactory::getDocument()->addStyleSheet(JURI::root() . 'administrator/components/com_easyblog/assets/css/module.css');
// 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();
// Get the menu items.
$items = $this->getMenuLinks($menuType, 0, 0, $published);
// 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][] = JHtml::_('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][] = JHtml::_('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;
}
示例6: getGroups
protected function getGroups()
{
// Include engine
require_once JPATH_ADMINISTRATOR . '/components/com_easyblog/includes/easyblog.php';
// 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();
// Get the menu items.
$items = $this->getMenuLinks($menuType, 0, 0, $published);
// 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][] = JHtml::_('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][] = JHtml::_('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;
}
示例7: getGroups
/**
* Method to get the field option groups.
*
* @return array The field option objects as a nested array in groups.
*
* @since 11.1
*/
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][] = JHtml::_('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][] = JHtml::_('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;
}
示例8: getGroups
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 11.1
*/
protected function getGroups()
{
// Two dimension array (1st dimension is group, 2nd dimension is option)
$groups = array();
$groups["default"] = array();
// get components
if ($this->getAttribute("components", "true") == "true") {
$groups[JText::_("COM_JDEVELOPER_COMPONENTS")] = array();
$components = array();
foreach (JFolder::folders(JPATH_ROOT . "/administrator/components", "com_[a-z0-9_]*") as $component) {
$groups[JText::_("COM_JDEVELOPER_COMPONENTS")][] = JHtml::_('select.option', "admin." . strtolower($component), ucfirst(str_replace("com_", "", $component)));
$components[$component] = 1;
}
foreach (JFolder::folders(JPATH_ROOT . "/components", "com_[a-z0-9_]*") as $component) {
if (!array_key_exists($component, $components)) {
$groups[JText::_("COM_JDEVELOPER_COMPONENTS")][] = JHtml::_('select.option', "admin." . strtolower($component), ucfirst(str_replace("com_", "", $component)));
}
}
}
// get modules
if ($this->getAttribute("modules", "true") == "true") {
$groups[JText::_("COM_JDEVELOPER_MODULES")] = array();
foreach (JFolder::folders(JPATH_ROOT . "/administrator/modules", "mod_[a-z0-9_]*") as $module) {
$groups[JText::_("COM_JDEVELOPER_MODULES")][] = JHtml::_('select.option', "admin." . strtolower($module), ucfirst(str_replace("mod_", "", $module)) . $this->styleClient("Backend"));
}
foreach (JFolder::folders(JPATH_ROOT . "/modules", "mod_[a-z0-9_]*") as $module) {
$groups[JText::_("COM_JDEVELOPER_MODULES")][] = JHtml::_('select.option', "site." . strtolower($module), ucfirst(str_replace("mod_", "", $module)) . $this->styleClient("Frontend"));
}
}
// get plugins
if ($this->getAttribute("plugins", "true") == "true") {
foreach (JFolder::folders(JPATH_ROOT . "/plugins") as $folder) {
$groups[JText::_("COM_JDEVELOPER_PLUGINS") . " - " . $folder] = array();
foreach (JFolder::folders(JPATH_ROOT . "/plugins/" . $folder) as $plugin) {
$groups[JText::_("COM_JDEVELOPER_PLUGINS") . " - " . $folder][] = JHtml::_('select.option', "site.plg_" . strtolower($folder) . "_" . strtolower($plugin), $plugin);
}
}
}
// get plugins
if ($this->getAttribute("templates", "true") == "true") {
$groups[JText::_("COM_JDEVELOPER_TEMPLATES")] = array();
foreach (JFolder::folders(JPATH_ROOT . "/administrator/templates") as $template) {
$groups[JText::_("COM_JDEVELOPER_TEMPLATES")][] = JHtml::_('select.option', "admin.tpl_" . strtolower($template), ucfirst($template) . $this->styleClient("Backend"));
}
foreach (JFolder::folders(JPATH_ROOT . "/templates") as $template) {
$groups[JText::_("COM_JDEVELOPER_TEMPLATES")][] = JHtml::_('select.option', "site.tpl_" . strtolower($template), ucfirst($template) . $this->styleClient("Frontend"));
}
}
return array_merge(parent::getGroups(), $groups);
}
示例9: getGroups
/**
* Method to get the list of content map options grouped by first level.
*
* @return array The field option objects as a nested array in groups.
*
* @since 3.6.0
*/
protected function getGroups()
{
$groups = array();
// Get the database object and a new query object.
$db = JFactory::getDbo();
// Levels subquery.
$levelQuery = $db->getQuery(true);
$levelQuery->select('title AS branch_title, 1 as level')->select($db->quoteName('id'))->from($db->quoteName('#__finder_taxonomy'))->where($db->quoteName('parent_id') . ' = 1');
$levelQuery2 = $db->getQuery(true);
$levelQuery2->select('b.title AS branch_title, 2 as level')->select($db->quoteName('a.id'))->from($db->quoteName('#__finder_taxonomy', 'a'))->join('LEFT', $db->quoteName('#__finder_taxonomy', 'b') . ' ON ' . $db->qn('a.parent_id') . ' = ' . $db->qn('b.id'))->where($db->quoteName('a.parent_id') . ' NOT IN (0, 1)');
$levelQuery->union($levelQuery2);
// Main query.
$query = $db->getQuery(true)->select($db->quoteName('a.title', 'text'))->select($db->quoteName('a.id', 'value'))->select($db->quoteName('d.level'))->from($db->quoteName('#__finder_taxonomy', 'a'))->join('LEFT', '(' . $levelQuery . ') AS d ON ' . $db->qn('d.id') . ' = ' . $db->qn('a.id'))->where($db->quoteName('a.parent_id') . ' <> 0')->order('d.branch_title ASC, d.level ASC, a.title ASC');
$db->setQuery($query);
try {
$contentMap = $db->loadObjectList();
} catch (RuntimeException $e) {
return;
}
// Build the grouped list array.
if ($contentMap) {
$lang = JFactory::getLanguage();
foreach ($contentMap as $branch) {
if ((int) $branch->level === 1) {
$name = $branch->text;
} else {
$levelPrefix = str_repeat('- ', max(0, $branch->level - 1));
if (trim($name, '**') == 'Language') {
$text = FinderHelperLanguage::branchLanguageTitle($branch->text);
} else {
$key = FinderHelperLanguage::branchSingular($branch->text);
$text = $lang->hasKey($key) ? JText::_($key) : $branch->text;
}
// Initialize the group if necessary.
if (!isset($groups[$name])) {
$groups[$name] = array();
}
$groups[$name][] = JHtml::_('select.option', $branch->value, $levelPrefix . $text);
}
}
}
// Merge any additional groups in the XML definition.
$groups = array_merge(parent::getGroups(), $groups);
return $groups;
}
示例10: getGroups
/**
* Method to get the list of template style options
* grouped by template.
* Use the client attribute to specify a specific client.
* Use the template attribute to specify a specific template
*
* @return array The field option objects as a nested array in groups.
*
* @since 1.6
*/
protected function getGroups()
{
// Initialize variables.
$groups = array();
$lang = JFactory::getLanguage();
// Get the client and client_id.
$clientName = $this->element['client'] ? (string) $this->element['client'] : 'site';
$client = JApplicationHelper::getClientInfo($clientName, true);
// Get the template.
$template = (string) $this->element['template'];
// Get the database object and a new query object.
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Build the query.
$query->select('s.id, s.title, e.name as name, s.template');
$query->from('#__template_styles as s');
$query->where('s.client_id = ' . (int) $client->id);
$query->order('template');
$query->order('title');
if ($template) {
$query->where('s.template = ' . $db->quote($template));
}
$query->join('LEFT', '#__extensions as e on e.element=s.template');
$query->where('e.enabled=1');
$query->where($db->quoteName('e.type') . '=' . $db->quote('template'));
// Set the query and load the styles.
$db->setQuery($query);
$styles = $db->loadObjectList();
// Build the grouped list array.
if ($styles) {
foreach ($styles as $style) {
$template = $style->template;
$lang->load('tpl_' . $template . '.sys', $client->path, null, false, true) || $lang->load('tpl_' . $template . '.sys', $client->path . '/templates/' . $template, null, false, true);
$name = JText::_($style->name);
// Initialize the group if necessary.
if (!isset($groups[$name])) {
$groups[$name] = array();
}
$groups[$name][] = JHtml::_('select.option', $style->id, $style->title);
}
}
// Merge any additional groups in the XML definition.
$groups = array_merge(parent::getGroups(), $groups);
return $groups;
}
示例11: __get
/**
* Method to get certain otherwise inaccessible properties from the form field object.
*
* @param string $name The property name for which to the the value.
*
* @return mixed The property value or null.
*
* @since 2.0
*/
public function __get($name)
{
switch ($name) {
case 'static':
if (empty($this->static)) {
$this->static = $this->getStatic();
}
return $this->static;
break;
case 'repeatable':
if (empty($this->repeatable)) {
$this->repeatable = $this->getRepeatable();
}
return $this->repeatable;
break;
default:
return parent::__get($name);
}
}
示例12: getGroups
protected function getGroups()
{
// Initialize variables.
$options = array();
$groups = array();
$joomlaImageFolder = JComponentHelper::getParams('com_media')->get('image_path', 'images');
$groups["SmartIcons"] = array();
$groups["SmartIcons"][] = JHtml::_('select.option', JPATH_ROOT . '/media/com_smarticons', 'SmartIcons media folder');
$groups["Images"] = array();
$groups["Images"][] = JHtml::_('select.option', JPATH_ROOT . $joomlaImageFolder, 'Joomla image folder');
$groups["Images"] = array_merge($groups["Images"], $this->getFolders('images', '', 3));
$rootFolders = $this->getFolders('', 'administrator|cache|cli|components|images|includes|language|libraries|logs|media|modules|plugins|templates|tmp');
if (is_array($rootFolders) && 0 < count($rootFolders)) {
$groups["Root folder"] = array();
$groups["Root folder"] = $rootFolders;
}
$groups = array_merge(parent::getGroups(), $groups);
return $groups;
}
示例13: getGroups
protected function getGroups()
{
$groups = parent::getGroups();
if (!self::isPluginEnabled()) {
// this groupedlist is defined in config XML as two top-level
// options ("no" and "count up from session start") and
// a group with several countdown mode options. We have to
// remove all options in this group if comanion plugin is
// not enabled
foreach ($groups as $label => $group) {
if (!is_integer($label)) {
// non-integer label means a group title, so this is the
// group to remove. All options are elements of the group
// array, so unsetting the group will delete the options
unset($groups[$label]);
}
}
}
return $groups;
}
示例14: getGroups
/**
* Method to get the time zone field option groups.
*
* @return array The field option objects as a nested array in groups.
*
* @since 11.1
*/
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 = JFactory::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] = JHtml::_('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;
}
示例15: getGroups
protected function getGroups()
{
static $groups = array();
static $nums = 0;
if (empty($groups)) {
$db = JFactory::getDBO();
$query = "SELECT sp.id AS value,\n\t\t\t\t\t\t sp.name AS text,\n\t\t\t\t\t\t sp.group_id,\n\t\t\t\t\t\t g.name AS cat_title\n\t\t\t\t FROM #__jcs_plans AS sp\n\t\t\t LEFT JOIN #__jcs_groups AS g ON g.id = sp.group_id\n\t\t\t \t WHERE sp.published = 1\n\t\t\t\tORDER BY g.id, sp.name";
$db->setQuery($query);
$plans = $db->loadObjectList();
ArrayHelper::clean_r($plans);
foreach ($plans as $plan) {
$groups[$plan->cat_title][] = JHtml::_('select.option', $plan->value, $plan->text, 'value', 'text');
$nums++;
}
$nums += count($groups);
$groups = array_merge(parent::getGroups(), $groups);
}
$this->num = $nums;
ArrayHelper::clean_r($groups);
return $groups;
}