checkextension.php
1.57 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
<?php
/* ======================================================
# Web357 Framework - Joomla! System Plugin v1.5.1
# -------------------------------------------------------
# For Joomla! 3.x
# Author: Yiannis Christodoulou (yiannis@web357.eu)
# Copyright (©) 2009-2018 Web357. All rights reserved.
# License: GNU/GPLv3, http://www.gnu.org/licenses/gpl-3.0.html
# Website: https://www.web357.eu/
# Support: support@web357.eu
# Last modified: 09 Feb 2018, 13:55:18
========================================================= */
defined('JPATH_BASE') or die;
require_once('elements_helper.php');
jimport('joomla.form.formfield');
jimport( 'joomla.form.form' );
class JFormFieldcheckextension extends JFormField {
protected $type = 'checkextension';
protected function getLabel()
{
$option = (string) $this->element["option"];
if (!empty($option) && !$this->isActive($option))
{
return '<div style="color:red">'.sprintf(JText::_('W357FRM_EXTENSION_IS_NOT_ACTIVE'), $option).'</div>';
}
else
{
return '<div style="color:darkgreen">'.sprintf(JText::_('W357FRM_EXTENSION_IS_ACTIVE'), $option).'</div>';
}
}
// Check if the component is installed and is enabled
public function isActive($option) // e.g. $option = com_k2
{
if (!empty($option))
{
jimport('joomla.component.helper');
if(!JComponentHelper::isInstalled($option) || !JComponentHelper::isEnabled($option))
{
return false;
}
else
{
return true;
}
}
else
{
die('The extension name is not detected.');
}
}
protected function getInput()
{
return '';
}
}