[ 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_config 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\Config\Administrator\Field; 12 13 use Joomla\CMS\Factory; 14 use Joomla\CMS\Filesystem\File; 15 use Joomla\CMS\Form\Field\ListField; 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 * Text Filters form field. 25 * 26 * @since 3.7.0 27 */ 28 class ConfigComponentsField extends ListField 29 { 30 /** 31 * The form field type. 32 * 33 * @var string 34 * @since 3.7.0 35 */ 36 public $type = 'ConfigComponents'; 37 38 /** 39 * Method to get a list of options for a list input. 40 * 41 * @return array An array of JHtml options. 42 * 43 * @since 3.7.0 44 */ 45 protected function getOptions() 46 { 47 $db = $this->getDatabase(); 48 $query = $db->getQuery(true) 49 ->select('name AS text, element AS value') 50 ->from('#__extensions') 51 ->where('enabled >= 1') 52 ->where('type =' . $db->quote('component')); 53 54 $items = $db->setQuery($query)->loadObjectList(); 55 56 if ($items) { 57 $lang = Factory::getLanguage(); 58 59 foreach ($items as &$item) { 60 // Load language 61 $extension = $item->value; 62 63 if (File::exists(JPATH_ADMINISTRATOR . '/components/' . $extension . '/config.xml')) { 64 $source = JPATH_ADMINISTRATOR . '/components/' . $extension; 65 $lang->load("$extension.sys", JPATH_ADMINISTRATOR) 66 || $lang->load("$extension.sys", $source); 67 68 // Translate component name 69 $item->text = Text::_($item->text); 70 } else { 71 $item = null; 72 } 73 } 74 75 // Sort by component name 76 $items = ArrayHelper::sortObjects(array_filter($items), 'text', 1, true, true); 77 } 78 79 // Merge any additional options in the XML definition. 80 $options = array_merge(parent::getOptions(), $items); 81 82 return $options; 83 } 84 }
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 |