| [ Index ] |
PHP Cross Reference of Joomla 2.5.4 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @package Joomla.Administrator 4 * @subpackage com_users 5 * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved. 6 * @license GNU General Public License version 2 or later; see LICENSE.txt 7 */ 8 9 // No direct access. 10 defined('_JEXEC') or die; 11 12 /** 13 * Users component debugging helper. 14 * 15 * @package Joomla.Administrator 16 * @subpackage com_users 17 * @since 1.6 18 */ 19 class UsersHelperDebug 20 { 21 /** 22 * Get a list of the components. 23 * 24 * @return array 25 * @since 1.6 26 */ 27 static function getComponents() 28 { 29 // Initialise variable. 30 $db = JFactory::getDbo(); 31 $query = $db->getQuery(true); 32 33 $query->select('name AS text, element AS value') 34 ->from('#__extensions') 35 ->where('enabled >= 1') 36 ->where('type ='.$db->Quote('component')); 37 38 $items = $db->setQuery($query)->loadObjectList(); 39 40 if (count($items)) { 41 $lang = JFactory::getLanguage(); 42 43 foreach ($items as &$item) 44 { 45 // Load language 46 $extension = $item->value; 47 $source = JPATH_ADMINISTRATOR . '/components/' . $extension; 48 $lang->load("$extension.sys", JPATH_ADMINISTRATOR, null, false, false) 49 || $lang->load("$extension.sys", $source, null, false, false) 50 || $lang->load("$extension.sys", JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) 51 || $lang->load("$extension.sys", $source, $lang->getDefault(), false, false); 52 53 // Translate component name 54 $item->text = JText::_($item->text); 55 } 56 57 // Sort by component name 58 JArrayHelper::sortObjects($items, 'text', 1, true, $lang->getLocale()); 59 } 60 61 return $items; 62 } 63 64 /** 65 * Get a list of the actions for the component or code actions. 66 * 67 * @param string The name of the component. 68 * 69 * @return array 70 * @since 1.6 71 */ 72 public static function getDebugActions($component = null) 73 { 74 $actions = array(); 75 76 // Try to get actions for the component 77 if (!empty($component)) { 78 $component_actions = JAccess::getActions($component); 79 80 if (!empty($component_actions)) { 81 foreach($component_actions as &$action) 82 { 83 $actions[$action->title] = array($action->name, $action->description); 84 } 85 } 86 } 87 88 // Use default actions from configuration if no component selected or component doesn't have actions 89 if (empty($actions)) { 90 $filename = JPATH_ADMINISTRATOR.'/components/com_config/models/forms/application.xml'; 91 92 if (is_file($filename)) { 93 $xml = simplexml_load_file($filename); 94 95 foreach($xml->children()->fieldset as $fieldset) 96 { 97 if ('permissions' == (string) $fieldset['name']) { 98 foreach ($fieldset->children() as $field) 99 { 100 if ('rules' == (string) $field['name']) { 101 foreach ($field->children() as $action) 102 { 103 $actions[(string) $action['title']] = array( 104 (string) $action['name'], 105 (string) $action['description'] 106 ); 107 } 108 break; 109 break; 110 break; 111 } 112 } 113 } 114 } 115 116 // Load language 117 $lang = JFactory::getLanguage(); 118 $extension = 'com_config'; 119 $source = JPATH_ADMINISTRATOR . '/components/' . $extension; 120 121 $lang->load($extension, JPATH_ADMINISTRATOR, null, false, false) 122 || $lang->load($extension, $source, null, false, false) 123 || $lang->load($extension, JPATH_ADMINISTRATOR, $lang->getDefault(), false, false) 124 || $lang->load($extension, $source, $lang->getDefault(), false, false); 125 } 126 } 127 128 return $actions; 129 } 130 131 /** 132 * Get a list of filter options for the levels. 133 * 134 * @return array An array of JHtmlOption elements. 135 */ 136 static function getLevelsOptions() 137 { 138 // Build the filter options. 139 $options = array(); 140 $options[] = JHtml::_('select.option', '1', JText::sprintf('COM_USERS_OPTION_LEVEL_COMPONENT', 1)); 141 $options[] = JHtml::_('select.option', '2', JText::sprintf('COM_USERS_OPTION_LEVEL_CATEGORY', 2)); 142 $options[] = JHtml::_('select.option', '3', JText::sprintf('COM_USERS_OPTION_LEVEL_DEEPER', 3)); 143 $options[] = JHtml::_('select.option', '4', '4'); 144 $options[] = JHtml::_('select.option', '5', '5'); 145 $options[] = JHtml::_('select.option', '6', '6'); 146 147 return $options; 148 } 149 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Apr 3 11:40:28 2012 | Cross-referenced by PHPXref 0.7.1 |