[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Administrator 5 * @subpackage com_users 6 * 7 * @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 namespace Joomla\Component\Users\Administrator\Helper; 12 13 use Joomla\CMS\Access\Access; 14 use Joomla\CMS\Factory; 15 use Joomla\CMS\HTML\HTMLHelper; 16 use Joomla\CMS\Language\Text; 17 use Joomla\Utilities\ArrayHelper; 18 19 // phpcs:disable PSR1.Files.SideEffects 20 \defined('_JEXEC') or die; 21 // phpcs:enable PSR1.Files.SideEffects 22 23 /** 24 * Users component debugging helper. 25 * 26 * @since 1.6 27 */ 28 class DebugHelper 29 { 30 /** 31 * Get a list of the components. 32 * 33 * @return array 34 * 35 * @since 1.6 36 */ 37 public static function getComponents() 38 { 39 // Initialise variable. 40 $db = Factory::getDbo(); 41 $query = $db->getQuery(true) 42 ->select('name AS text, element AS value') 43 ->from('#__extensions') 44 ->where('enabled >= 1') 45 ->where('type =' . $db->quote('component')); 46 47 $items = $db->setQuery($query)->loadObjectList(); 48 49 if (count($items)) { 50 $lang = Factory::getLanguage(); 51 52 foreach ($items as &$item) { 53 // Load language 54 $extension = $item->value; 55 $source = JPATH_ADMINISTRATOR . '/components/' . $extension; 56 $lang->load("$extension.sys", JPATH_ADMINISTRATOR) 57 || $lang->load("$extension.sys", $source); 58 59 // Translate component name 60 $item->text = Text::_($item->text); 61 } 62 63 // Sort by component name 64 $items = ArrayHelper::sortObjects($items, 'text', 1, true, true); 65 } 66 67 return $items; 68 } 69 70 /** 71 * Get a list of the actions for the component or code actions. 72 * 73 * @param string $component The name of the component. 74 * 75 * @return array 76 * 77 * @since 1.6 78 */ 79 public static function getDebugActions($component = null) 80 { 81 $actions = array(); 82 83 // Try to get actions for the component 84 if (!empty($component)) { 85 $component_actions = Access::getActionsFromFile(JPATH_ADMINISTRATOR . '/components/' . $component . '/access.xml'); 86 87 if (!empty($component_actions)) { 88 foreach ($component_actions as &$action) { 89 $descr = (string) $action->title; 90 91 if (!empty($action->description)) { 92 $descr = (string) $action->description; 93 } 94 95 $actions[$action->title] = array($action->name, $descr); 96 } 97 } 98 } 99 100 // Use default actions from configuration if no component selected or component doesn't have actions 101 if (empty($actions)) { 102 $filename = JPATH_ADMINISTRATOR . '/components/com_config/forms/application.xml'; 103 104 if (is_file($filename)) { 105 $xml = simplexml_load_file($filename); 106 107 foreach ($xml->children()->fieldset as $fieldset) { 108 if ('permissions' == (string) $fieldset['name']) { 109 foreach ($fieldset->children() as $field) { 110 if ('rules' == (string) $field['name']) { 111 foreach ($field->children() as $action) { 112 $descr = (string) $action['title']; 113 114 if (isset($action['description']) && !empty($action['description'])) { 115 $descr = (string) $action['description']; 116 } 117 118 $actions[(string) $action['title']] = array( 119 (string) $action['name'], 120 $descr 121 ); 122 } 123 124 break; 125 } 126 } 127 } 128 } 129 130 // Load language 131 $lang = Factory::getLanguage(); 132 $extension = 'com_config'; 133 $source = JPATH_ADMINISTRATOR . '/components/' . $extension; 134 135 $lang->load($extension, JPATH_ADMINISTRATOR, null, false, false) 136 || $lang->load($extension, $source, null, false, false) 137 || $lang->load($extension, JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) 138 || $lang->load($extension, $source, $lang->getDefault(), false, false); 139 } 140 } 141 142 return $actions; 143 } 144 145 /** 146 * Get a list of filter options for the levels. 147 * 148 * @return array An array of \JHtmlOption elements. 149 */ 150 public static function getLevelsOptions() 151 { 152 // Build the filter options. 153 $options = array(); 154 $options[] = HTMLHelper::_('select.option', '1', Text::sprintf('COM_USERS_OPTION_LEVEL_COMPONENT', 1)); 155 $options[] = HTMLHelper::_('select.option', '2', Text::sprintf('COM_USERS_OPTION_LEVEL_CATEGORY', 2)); 156 $options[] = HTMLHelper::_('select.option', '3', Text::sprintf('COM_USERS_OPTION_LEVEL_DEEPER', 3)); 157 $options[] = HTMLHelper::_('select.option', '4', '4'); 158 $options[] = HTMLHelper::_('select.option', '5', '5'); 159 $options[] = HTMLHelper::_('select.option', '6', '6'); 160 161 return $options; 162 } 163 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |