1 <?php
2 /**
3 * @package Joomla.Libraries
4 * @subpackage Installer
5 *
6 * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE.txt
8 */
9
10 defined('JPATH_PLATFORM') or die;
11
12 /**
13 * Extension object
14 *
15 * @since 3.1
16 */
17 class JInstallerExtension extends JObject
18 {
19 /**
20 * Filename of the extension
21 *
22 * @var string
23 * @since 3.1
24 */
25 public $filename = '';
26
27 /**
28 * Type of the extension
29 *
30 * @var string
31 * @since 3.1
32 */
33 public $type = '';
34
35 /**
36 * Unique Identifier for the extension
37 *
38 * @var string
39 * @since 3.1
40 */
41 public $id = '';
42
43 /**
44 * The status of the extension
45 *
46 * @var boolean
47 * @since 3.1
48 */
49 public $published = false;
50
51 /**
52 * String representation of client. Valid for modules, templates and languages.
53 * Set by default to site.
54 *
55 * @var string
56 * @since 3.1
57 */
58 public $client = 'site';
59
60 /**
61 * The group name of the plugin. Not used for other known extension types (only plugins)
62 *
63 * @var string
64 * @since 3.1
65 */
66 public $group = '';
67
68 /**
69 * An object representation of the manifest file stored metadata
70 *
71 * @var object
72 * @since 3.1
73 */
74 public $manifest_cache = null;
75
76 /**
77 * An object representation of the extension params
78 *
79 * @var object
80 * @since 3.1
81 */
82 public $params = null;
83
84 /**
85 * Constructor
86 *
87 * @param SimpleXMLElement $element A SimpleXMLElement from which to load data from
88 *
89 * @since 3.1
90 */
91 public function __construct(SimpleXMLElement $element = null)
92 {
93 if ($element)
94 {
95 $this->type = (string) $element->attributes()->type;
96 $this->id = (string) $element->attributes()->id;
97
98 switch ($this->type)
99 {
100 case 'component':
101 // By default a component doesn't have anything
102 break;
103
104 case 'module':
105 case 'template':
106 case 'language':
107 $this->client = (string) $element->attributes()->client;
108 $tmp_client_id = JApplicationHelper::getClientInfo($this->client, 1);
109
110 if ($tmp_client_id == null)
111 {
112 JLog::add(JText::_('JLIB_INSTALLER_ERROR_EXTENSION_INVALID_CLIENT_IDENTIFIER'), JLog::WARNING, 'jerror');
113 }
114 else
115 {
116 $this->client_id = $tmp_client_id->id;
117 }
118 break;
119
120 case 'plugin':
121 $this->group = (string) $element->attributes()->group;
122 break;
123
124 default:
125 // Catch all
126 // Get and set client and group if we don't recognise the extension
127 if ($element->attributes()->client)
128 {
129 $this->client_id = JApplicationHelper::getClientInfo($this->client, 1);
130 $this->client_id = $this->client_id->id;
131 }
132
133 if ($element->attributes()->group)
134 {
135 $this->group = (string) $element->attributes()->group;
136 }
137 break;
138 }
139
140 $this->filename = (string) $element;
141 }
142 }
143 }
144
145 /**
146 * Deprecated class placeholder. You should use JInstallerExtension instead.
147 *
148 * @since 3.1
149 * @deprecated 4.0
150 * @codeCoverageIgnore
151 */
152 class JExtension extends JInstallerExtension
153 {
154 }
155