InstallerExtension.php
2.84 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<?php
/**
* Joomla! Content Management System
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\CMS\Installer;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Application\ApplicationHelper;
/**
* Extension object
*
* @since 3.1
*/
class InstallerExtension extends \JObject
{
/**
* Filename of the extension
*
* @var string
* @since 3.1
*/
public $filename = '';
/**
* Type of the extension
*
* @var string
* @since 3.1
*/
public $type = '';
/**
* Unique Identifier for the extension
*
* @var string
* @since 3.1
*/
public $id = '';
/**
* The status of the extension
*
* @var boolean
* @since 3.1
*/
public $published = false;
/**
* String representation of client. Valid for modules, templates and languages.
* Set by default to site.
*
* @var string
* @since 3.1
*/
public $client = 'site';
/**
* The group name of the plugin. Not used for other known extension types (only plugins)
*
* @var string
* @since 3.1
*/
public $group = '';
/**
* An object representation of the manifest file stored metadata
*
* @var object
* @since 3.1
*/
public $manifest_cache = null;
/**
* An object representation of the extension params
*
* @var object
* @since 3.1
*/
public $params = null;
/**
* Constructor
*
* @param \SimpleXMLElement $element A SimpleXMLElement from which to load data from
*
* @since 3.1
*/
public function __construct(\SimpleXMLElement $element = null)
{
if ($element)
{
$this->type = (string) $element->attributes()->type;
$this->id = (string) $element->attributes()->id;
switch ($this->type)
{
case 'component':
// By default a component doesn't have anything
break;
case 'module':
case 'template':
case 'language':
$this->client = (string) $element->attributes()->client;
$tmp_client_id = ApplicationHelper::getClientInfo($this->client, 1);
if ($tmp_client_id == null)
{
\JLog::add(\JText::_('JLIB_INSTALLER_ERROR_EXTENSION_INVALID_CLIENT_IDENTIFIER'), \JLog::WARNING, 'jerror');
}
else
{
$this->client_id = $tmp_client_id->id;
}
break;
case 'plugin':
$this->group = (string) $element->attributes()->group;
break;
default:
// Catch all
// Get and set client and group if we don't recognise the extension
if ($element->attributes()->client)
{
$this->client_id = ApplicationHelper::getClientInfo($this->client, 1);
$this->client_id = $this->client_id->id;
}
if ($element->attributes()->group)
{
$this->group = (string) $element->attributes()->group;
}
break;
}
$this->filename = (string) $element;
}
}
}