Source for file config.php

Documentation is available at config.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_config
  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.  * Components helper for com_config
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_config
  17.  * @since       3.0
  18.  */
  19. {
  20.     /**
  21.      * Get an array of all enabled components.
  22.      *
  23.      * @return  array 
  24.      *
  25.      * @since   3.0
  26.      */
  27.     public static function getAllComponents()
  28.     {
  29.         $db JFactory::getDbo();
  30.         $query $db->getQuery(true)
  31.             ->select('element')
  32.             ->from('#__extensions')
  33.             ->where('type = ' $db->quote('component'))
  34.             ->where('enabled = 1');
  35.         $db->setQuery($query);
  36.         $result $db->loadColumn();
  37.  
  38.         return $result;
  39.     }
  40.  
  41.     /**
  42.      * Returns true if the component has configuration options.
  43.      *
  44.      * @param   string  $component  Component name
  45.      *
  46.      * @return  boolean 
  47.      *
  48.      * @since   3.0
  49.      */
  50.     public static function hasComponentConfig($component)
  51.     {
  52.         return is_file(JPATH_ADMINISTRATOR '/components/' $component '/config.xml');
  53.     }
  54.  
  55.     /**
  56.      * Returns an array of all components with configuration options. By only
  57.      * components for which the current user has 'core.manage' rights are returned.
  58.      *
  59.      * @param   boolean  $authCheck 
  60.      *
  61.      * @return  array 
  62.      *
  63.      * @since   3.0
  64.      */
  65.     public static function getComponentsWithConfig($authCheck true)
  66.     {
  67.         $result array();
  68.         $components self::getAllComponents();
  69.         $user JFactory::getUser();
  70.  
  71.         // Remove com_config from the array as that may have weird side effects
  72.         $components array_diff($componentsarray('com_config'));
  73.  
  74.         foreach ($components as $component)
  75.         {
  76.             if (self::hasComponentConfig($component&& (!$authCheck || $user->authorise('core.manage'$component)))
  77.             {
  78.                 $result[$component;
  79.             }
  80.         }
  81.  
  82.         return $result;
  83.     }
  84.  
  85.     /**
  86.      * Load the sys language for the given component.
  87.      *
  88.      * @param   string  $components 
  89.      *
  90.      * @return  void 
  91.      *
  92.      * @since   3.0
  93.      */
  94.     public static function loadLanguageForComponents($components)
  95.     {
  96.         $lang JFactory::getLanguage();
  97.  
  98.         foreach ($components as $component)
  99.         {
  100.             if (!empty($component))
  101.             {
  102.                 // Load the core file then
  103.                 // Load extension-local file.
  104.                 $lang->load($component '.sys'JPATH_BASEnullfalsetrue)
  105.                 || $lang->load($component '.sys'JPATH_ADMINISTRATOR '/components/' $componentnullfalsetrue);
  106.             }
  107.         }
  108.     }
  109. }

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