/** * 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. }
/** * 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; }
/** * 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; }
/** * 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; }
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; }
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; }
/** * 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; }
/** * 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); }
/** * 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; }
/** * 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; }
/** * 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); } }
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; }
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; }
/** * 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; }
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; }
/** * Method to get a list of options for a list input. * * @return array An array of JHtml options. */ protected function getGroups() { // Remove '.ini' from values if (is_array($this->value)) { foreach ($this->value as $key => $val) { $this->value[$key] = substr($val, 0, -4); } } $package = (string) $this->element['package']; $groups = array('Site' => array(), 'Administrator' => array(), 'Installation' => array()); foreach (array('Site', 'Administrator', 'Installation') as $client) { $path = constant('LOCALISEPATH_' . strtoupper($client)) . '/language'; if (JFolder::exists($path)) { $tags = JFolder::folders($path, '.', false, false, array('overrides', '.svn', 'CVS', '.DS_Store', '__MACOSX')); if ($tags) { foreach ($tags as $tag) { $files = JFolder::files("{$path}/{$tag}", ".ini\$"); foreach ($files as $file) { $basename = substr($file, strlen($tag) + 1); if ($basename == 'ini') { $key = 'joomla'; $value = JText::_('COM_LOCALISE_TEXT_TRANSLATIONS_JOOMLA'); $origin = LocaliseHelper::getOrigin('', strtolower($client)); $disabled = $origin != $package && $origin != '_thirdparty'; } else { $key = substr($basename, 0, strlen($basename) - 4); $value = $key; $origin = LocaliseHelper::getOrigin($key, strtolower($client)); $disabled = $origin != $package && $origin != '_thirdparty'; } $groups[$client][$key] = JHtml::_('select.option', strtolower($client) . '_' . $key, $value, 'value', 'text', false); } } } } } $scans = LocaliseHelper::getScans(); foreach ($scans as $scan) { $prefix = $scan['prefix']; $suffix = $scan['suffix']; $type = $scan['type']; $client = ucfirst($scan['client']); $path = $scan['path']; $folder = $scan['folder']; $extensions = JFolder::folders($path); foreach ($extensions as $extension) { if (JFolder::exists("{$path}{$extension}{$folder}/language")) { // scan extensions folder $tags = JFolder::folders("{$path}{$extension}{$folder}/language"); foreach ($tags as $tag) { $file = "{$path}{$extension}{$folder}/language/{$tag}/{$tag}.{$prefix}{$extension}{$suffix}.ini"; if (JFile::exists($file)) { $origin = LocaliseHelper::getOrigin("{$prefix}{$extension}{$suffix}", strtolower($client)); $disabled = $origin != $package && $origin != '_thirdparty'; $groups[$client]["{$prefix}{$extension}{$suffix}"] = JHtml::_('select.option', strtolower($client) . '_' . "{$prefix}{$extension}{$suffix}", "{$prefix}{$extension}{$suffix}", 'value', 'text', $disabled); } } } } } foreach ($groups as $client => $extensions) { JArrayHelper::sortObjects($groups[$client], 'text'); } // Merge any additional options in the XML definition. $groups = array_merge(parent::getGroups(), $groups); return $groups; }
/** * Method to get the field option groups. * * @return array The field option objects as a nested array in groups. * * @since 1.6 */ protected function getGroups() { $groups = array(); $menuType = $this->menuType; // Get the menu items. $items = MenusHelper::getMenuLinks($menuType, 0, 0, $this->published, $this->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, $this->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, $this->disable)); } } } // Merge any additional groups in the XML definition. $groups = array_merge(parent::getGroups(), $groups); return $groups; }
/** * Method to get the field option groups. * * @return array The field option objects as a nested array in groups. * * @since 1.6 */ protected function getGroups() { $groups = array(); $menuType = $this->menuType; // Get the menu items. $items = MenusHelper::getMenuLinks($menuType, 0, 0, $this->published, $this->language); // Build group for a specific menu type. if ($menuType) { // Initialize the group. $groups[$menuType] = array(); // Build the options array. foreach ($items as $link) { $levelPrefix = str_repeat('- ', max(0, $link->level - 1)); // Displays language code if not set to All if ($link->language !== '*') { $lang = ' (' . $link->language . ')'; } else { $lang = ''; } $groups[$menuType][] = JHtml::_('select.option', $link->value, $levelPrefix . $link->text . $lang, 'value', 'text', in_array($link->type, $this->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) { $levelPrefix = str_repeat('- ', $link->level - 1); // Displays language code if not set to All if ($link->language !== '*') { $lang = ' (' . $link->language . ')'; } else { $lang = ''; } $groups[$menu->menutype][] = JHtml::_('select.option', $link->value, $levelPrefix . $link->text . $lang, 'value', 'text', in_array($link->type, $this->disable)); } } } // Merge any additional groups in the XML definition. $groups = array_merge(parent::getGroups(), $groups); return $groups; }
/** * Method to get the time zone field option groups. * * @return array The field option objects as a nested array in groups. */ protected function getGroups() { $settings = JemHelper::globalattribs(); $globalTz = $settings->get('global_timezone'); $groups = array(); $keyField = !empty($this->keyField) ? $this->keyField : 'id'; $keyValue = $this->form->getValue($keyField); $view = $this->element['view']; // If the timezone is not set use the server setting. if (strlen($this->value) == 0 && empty($keyValue)) { # we didn't select A timezone so we'll take a look at the server setting. # are we in settings-view? if ($view == 'venue') { # check if there is a setting filled if ($globalTz) { $this->value = $globalTz; } else { # there is no global value so check the the server setting $serverTz = JFactory::getConfig()->get('offset'); # UTC is seen as Abidjan and that's not something we want if ($serverTz == 'UTC') { $serverTz = 'Europe/Berlin'; // for the moment it's been set to this } $this->value = $serverTz; } } } // 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 &$location) { sort($location); } // Merge any additional groups in the XML definition. $groups = array_merge(parent::getGroups(), $groups); return $groups; }
protected function getInput() { $register_type = $this->form->getValue('register_type', 'params', null); $notice_display = $register_type == "custom" ? "none" : "block"; $input_display = $register_type == "custom" ? "block" : "none"; $html = '<div id="reglinknotice" style="display:' . $notice_display . '; clear:both;">' . JText::_("MOD_SCLOGIN_LOGIN_CUSTOM_REG_LINK_NOTICE") . '</div>'; return $html . '<div id="registrationlink" style="display:' . $input_display . '">' . parent::getInput() . '</div>'; }
protected function getGroups() { // Initialise variables. $lang = JFactory::getLanguage(); $user = JFactory::getUser(); $db = JFactory::getDbo(); $query = $db->getQuery(true); $groups = array(); $langs = array(); $name = null; // Prepare the query. $query->select('m.id, m.title, m.alias, m.link, m.parent_id, m.img, e.element'); $query->from('#__menu AS m'); // Filter on the enabled states. $query->leftJoin('#__extensions AS e ON m.component_id = e.extension_id'); $query->where('m.client_id = 1'); $query->where('e.enabled = 1'); $query->where('m.id > 1'); // Order by lft. $query->order('m.lft'); $db->setQuery($query); // component list $components = $db->loadObjectList(); // Parse the list of extensions. foreach ($components as &$component) { // Trim the menu link. $component->link = trim($component->link); if ($component->parent_id == 1) { // Only add this top level if it is authorised and enabled. if ($user->authorise('core.manage', $component->element)) { // If the root menu link is empty, add it in. if (empty($component->link)) { $component->link = 'index.php?option=' . $component->element; } if (!empty($component->element)) { // Load the core file then // Load extension-local file. $lang->load($component->element . '.sys', JPATH_BASE, null, false, false) || $lang->load($component->element . '.sys', JPATH_ADMINISTRATOR . '/components/' . $component->element, null, false, false) || $lang->load($component->element . '.sys', JPATH_BASE, $lang->getDefault(), false, false) || $lang->load($component->element . '.sys', JPATH_ADMINISTRATOR . '/components/' . $component->element, $lang->getDefault(), false, false); } $name = $lang->hasKey($component->title) ? JText::_($component->title) : $component->alias; // Root level. if (!isset($groups[$name])) { $groups[$name] = array(); } $groups[$name][] = JHtml::_('select.option', $component->link, $name); } } else { // Sub-menu level. if (isset($groups[$name])) { // Add the submenu link if it is defined. if (isset($groups[$name]) && !empty($component->link)) { $component->name = $lang->hasKey($component->title) ? JText::_($component->title) : $component->alias; if (!in_array(JHtml::_('select.option', $component->link, $component->name), $groups[$name])) { $groups[$name][] = JHtml::_('select.option', $component->link, $component->name); } } } } } $groups = array_merge(parent::getGroups(), $groups); return $groups; }
/** * Method to get the field option groups. * * @return array The field option objects as a nested array in groups. * * @since 1.6 */ protected function getGroups() { $groups = array(); $menuType = $this->menuType; // Get the menu items. $items = MenusHelper::getMenuLinks($menuType, 0, 0, $this->published, $this->language); // Build group for a specific menu type. if ($menuType) { // If the menutype is empty, group the items by menutype. $db = JFactory::getDbo(); $query = $db->getQuery(true)->select($db->quoteName('title'))->from($db->quoteName('#__menu_types'))->where($db->quoteName('menutype') . ' = ' . $db->quote($menuType)); $db->setQuery($query); try { $menuTitle = $db->loadResult(); } catch (RuntimeException $e) { $menuTitle = $menuType; } // Initialize the group. $groups[$menuTitle] = array(); // Build the options array. foreach ($items as $link) { $levelPrefix = str_repeat('- ', max(0, $link->level - 1)); // Displays language code if not set to All if ($link->language !== '*') { $lang = ' (' . $link->language . ')'; } else { $lang = ''; } $groups[$menuTitle][] = JHtml::_('select.option', $link->value, $levelPrefix . $link->text . $lang, 'value', 'text', in_array($link->type, $this->disable)); } } else { // Build the groups arrays. foreach ($items as $menu) { // Initialize the group. $groups[$menu->title] = array(); // Build the options array. foreach ($menu->links as $link) { $levelPrefix = str_repeat('- ', $link->level - 1); // Displays language code if not set to All if ($link->language !== '*') { $lang = ' (' . $link->language . ')'; } else { $lang = ''; } $groups[$menu->title][] = JHtml::_('select.option', $link->value, $levelPrefix . $link->text . $lang, 'value', 'text', in_array($link->type, $this->disable)); } } } // Merge any additional groups in the XML definition. $groups = array_merge(parent::getGroups(), $groups); return $groups; }