Server IP : 195.201.23.43 / Your IP : 18.116.14.133 Web Server : Apache System : Linux webserver2.vercom.be 5.4.0-192-generic #212-Ubuntu SMP Fri Jul 5 09:47:39 UTC 2024 x86_64 User : kdecoratie ( 1041) PHP Version : 7.1.33-63+ubuntu20.04.1+deb.sury.org+1 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /proc/thread-self/cwd/libraries/src/Form/Field/ |
Upload File : |
<?php /** * Joomla! Content Management System * * @copyright (C) 2010 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ namespace Joomla\CMS\Form\Field; defined('JPATH_PLATFORM') or die; use Joomla\CMS\Factory; use Joomla\CMS\Form\FormHelper; // Import the com_menus helper. require_once realpath(JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php'); FormHelper::loadFieldClass('GroupedList'); /** * Supports an HTML select list of menus * * @since 1.6 */ class MenuField extends \JFormFieldGroupedList { /** * The form field type. * * @var string * @since 1.6 */ public $type = 'Menu'; /** * Method to get the field option groups. * * @return array The field option objects as a nested array in groups. * * @since 1.7.0 * @throws \UnexpectedValueException */ protected function getGroups() { $clientId = (string) $this->element['clientid']; $accessType = (string) $this->element['accesstype']; $showAll = (string) $this->element['showAll'] == 'true'; $db = Factory::getDbo(); $query = $db->getQuery(true) ->select($db->qn(array('id', 'menutype', 'title', 'client_id'), array('id', 'value', 'text', 'client_id'))) ->from($db->quoteName('#__menu_types')) ->order('client_id, title'); if (strlen($clientId)) { $query->where('client_id = ' . (int) $clientId); } $menus = $db->setQuery($query)->loadObjectList(); if ($accessType) { $user = Factory::getUser(); foreach ($menus as $key => $menu) { switch ($accessType) { case 'create': case 'manage': if (!$user->authorise('core.' . $accessType, 'com_menus.menu.' . (int) $menu->id)) { unset($menus[$key]); } break; // Editing a menu item is a bit tricky, we have to check the current menutype for core.edit and all others for core.create case 'edit': $check = $this->value == $menu->value ? 'edit' : 'create'; if (!$user->authorise('core.' . $check, 'com_menus.menu.' . (int) $menu->id)) { unset($menus[$key]); } break; } } } $opts = array(); // Protected menutypes can be shown if requested if ($clientId == 1 && $showAll) { $opts[] = (object) array( 'value' => 'main', 'text' => \JText::_('COM_MENUS_MENU_TYPE_PROTECTED_MAIN_LABEL'), 'client_id' => 1, ); } $options = array_merge($opts, $menus); $groups = array(); if (strlen($clientId)) { $groups[0] = $options; } else { foreach ($options as $option) { // If client id is not specified we group the items. $label = ($option->client_id == 1 ? \JText::_('JADMINISTRATOR') : \JText::_('JSITE')); $groups[$label][] = $option; } } // Merge any additional options in the XML definition. return array_merge(parent::getGroups(), $groups); } }Private