Source for file debug.php

Documentation is available at debug.php

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

Documentation generated on Tue, 19 Nov 2013 14:57:56 +0100 by phpDocumentor 1.4.3