components.php
2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
/**
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('list');
/**
* Form Field class for the Joomla Framework.
*
* @since 11.4
*/
class JFormFieldComponents extends JFormFieldList
{
/**
* The field type.
*
* @var string
*
* @since 11.4
*/
protected $type = 'Components';
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options
*
* @since 11.4
*/
protected function getOptions()
{
$language = JFactory::getLanguage();
$exclude = array(
'com_admin',
'com_cache',
'com_checkin',
'com_config',
'com_cpanel',
'com_finder',
'com_installer',
'com_languages',
'com_login',
'com_mailto',
'com_menus',
'com_media',
'com_messages',
'com_newsfeeds',
'com_plugins',
'com_redirect',
'com_templates',
'com_users',
'com_wrapper',
'com_search',
'com_user',
'com_updates',
);
// Get list of plugins
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('element AS value, name AS text')
->from('#__extensions')
->where('type = '.$db->quote('component'))
->where('enabled = 1')
->order('ordering, name');
$db->setQuery($query);
$components = $db->loadObjectList();
$options = array();
// load component languages
for ($i = 0; $i < count($components); ++$i) {
if (!in_array($components[$i]->value, $exclude)) {
// load system language file
$language->load($components[$i]->value.'.sys', JPATH_ADMINISTRATOR);
$language->load($components[$i]->value, JPATH_ADMINISTRATOR);
if ($components[$i]->text === "COM_JCE") {
$components[$i]->text = "WF_CPANEL_BROWSER";
}
// translate name
$components[$i]->text = JText::_($components[$i]->text, true);
$components[$i]->disable = '';
$options[] = $components[$i];
}
}
// Merge any additional options in the XML definition.
return array_merge(parent::getOptions(), $options);
}
}