Version.php
7.79 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
<?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;
defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Helper\LibraryHelper;
/**
* Version information class for the Joomla CMS.
*
* @since 1.0
*/
final class Version
{
/**
* Product name.
*
* @var string
* @since 3.5
*/
const PRODUCT = 'Joomla!';
/**
* Major release version.
*
* @var integer
* @since 3.8.0
*/
const MAJOR_VERSION = 3;
/**
* Minor release version.
*
* @var integer
* @since 3.8.0
*/
const MINOR_VERSION = 9;
/**
* Patch release version.
*
* @var integer
* @since 3.8.0
*/
const PATCH_VERSION = 14;
/**
* Extra release version info.
*
* This constant when not empty adds an additional identifier to the version string to reflect the development state.
* For example, for 3.8.0 when this is set to 'dev' the version string will be `3.8.0-dev`.
*
* @var string
* @since 3.8.0
*/
const EXTRA_VERSION = '';
/**
* Release version.
*
* @var string
* @since 3.5
* @deprecated 4.0 Use separated version constants instead
*/
const RELEASE = '3.9';
/**
* Maintenance version.
*
* @var string
* @since 3.5
* @deprecated 4.0 Use separated version constants instead
*/
const DEV_LEVEL = '14';
/**
* Development status.
*
* @var string
* @since 3.5
*/
const DEV_STATUS = 'Stable';
/**
* Build number.
*
* @var string
* @since 3.5
* @deprecated 4.0
*/
const BUILD = '';
/**
* Code name.
*
* @var string
* @since 3.5
*/
const CODENAME = 'Amani';
/**
* Release date.
*
* @var string
* @since 3.5
*/
const RELDATE = '17-December-2019';
/**
* Release time.
*
* @var string
* @since 3.5
*/
const RELTIME = '15:00';
/**
* Release timezone.
*
* @var string
* @since 3.5
*/
const RELTZ = 'GMT';
/**
* Copyright Notice.
*
* @var string
* @since 3.5
*/
const COPYRIGHT = 'Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.';
/**
* Link text.
*
* @var string
* @since 3.5
*/
const URL = '<a href="https://www.joomla.org">Joomla!</a> is Free Software released under the GNU General Public License.';
/**
* Magic getter providing access to constants previously defined as class member vars.
*
* @param string $name The name of the property.
*
* @return mixed A value if the property name is valid.
*
* @since 3.5
* @deprecated 4.0 Access the constants directly
*/
public function __get($name)
{
if (defined("JVersion::$name"))
{
\JLog::add(
'Accessing Version data through class member variables is deprecated, use the corresponding constant instead.',
\JLog::WARNING,
'deprecated'
);
return constant("\\Joomla\\CMS\\Version::$name");
}
$trace = debug_backtrace();
trigger_error(
'Undefined constant via __get(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'],
E_USER_NOTICE
);
}
/**
* Check if we are in development mode
*
* @return boolean
*
* @since 3.4.3
*/
public function isInDevelopmentState()
{
return strtolower(self::DEV_STATUS) !== 'stable';
}
/**
* Compares two a "PHP standardized" version number against the current Joomla version.
*
* @param string $minimum The minimum version of the Joomla which is compatible.
*
* @return boolean True if the version is compatible.
*
* @link https://www.php.net/version_compare
* @since 1.0
*/
public function isCompatible($minimum)
{
return version_compare(JVERSION, $minimum, 'ge');
}
/**
* Method to get the help file version.
*
* @return string Version suffix for help files.
*
* @since 1.0
*/
public function getHelpVersion()
{
return '.' . self::MAJOR_VERSION . self::MINOR_VERSION;
}
/**
* Gets a "PHP standardized" version string for the current Joomla.
*
* @return string Version string.
*
* @since 1.5
*/
public function getShortVersion()
{
$version = self::MAJOR_VERSION . '.' . self::MINOR_VERSION . '.' . self::PATCH_VERSION;
// Has to be assigned to a variable to support PHP 5.3 and 5.4
$extraVersion = self::EXTRA_VERSION;
if (!empty($extraVersion))
{
$version .= '-' . $extraVersion;
}
return $version;
}
/**
* Gets a version string for the current Joomla with all release information.
*
* @return string Complete version string.
*
* @since 1.5
*/
public function getLongVersion()
{
return self::PRODUCT . ' ' . $this->getShortVersion() . ' '
. self::DEV_STATUS . ' [ ' . self::CODENAME . ' ] ' . self::RELDATE . ' '
. self::RELTIME . ' ' . self::RELTZ;
}
/**
* Returns the user agent.
*
* @param string $component Name of the component.
* @param bool $mask Mask as Mozilla/5.0 or not.
* @param bool $add_version Add version afterwards to component.
*
* @return string User Agent.
*
* @since 1.0
*/
public function getUserAgent($component = null, $mask = false, $add_version = true)
{
if ($component === null)
{
$component = 'Framework';
}
if ($add_version)
{
$component .= '/' . self::RELEASE;
}
// If masked pretend to look like Mozilla 5.0 but still identify ourselves.
if ($mask)
{
return 'Mozilla/5.0 ' . self::PRODUCT . '/' . self::RELEASE . '.' . self::DEV_LEVEL . ($component ? ' ' . $component : '');
}
else
{
return self::PRODUCT . '/' . self::RELEASE . '.' . self::DEV_LEVEL . ($component ? ' ' . $component : '');
}
}
/**
* Generate a media version string for assets
* Public to allow third party developers to use it
*
* @return string
*
* @since 3.2
*/
public function generateMediaVersion()
{
$date = new \JDate;
return md5($this->getLongVersion() . \JFactory::getConfig()->get('secret') . $date->toSql());
}
/**
* Gets a media version which is used to append to Joomla core media files.
*
* This media version is used to append to Joomla core media in order to trick browsers into
* reloading the CSS and JavaScript, because they think the files are renewed.
* The media version is renewed after Joomla core update, install, discover_install and uninstallation.
*
* @return string The media version.
*
* @since 3.2
*/
public function getMediaVersion()
{
// Load the media version and cache it for future use
static $mediaVersion = null;
if ($mediaVersion === null)
{
// Get the joomla library params
$params = LibraryHelper::getParams('joomla');
// Get the media version
$mediaVersion = $params->get('mediaversion', '');
// Refresh assets in debug mode or when the media version is not set
if (JDEBUG || empty($mediaVersion))
{
$mediaVersion = $this->generateMediaVersion();
$this->setMediaVersion($mediaVersion);
}
}
return $mediaVersion;
}
/**
* Function to refresh the media version
*
* @return Version Instance of $this to allow chaining.
*
* @since 3.2
*/
public function refreshMediaVersion()
{
$newMediaVersion = $this->generateMediaVersion();
return $this->setMediaVersion($newMediaVersion);
}
/**
* Sets the media version which is used to append to Joomla core media files.
*
* @param string $mediaVersion The media version.
*
* @return Version Instance of $this to allow chaining.
*
* @since 3.2
*/
public function setMediaVersion($mediaVersion)
{
// Do not allow empty media versions
if (!empty($mediaVersion))
{
// Get library parameters
$params = LibraryHelper::getParams('joomla');
$params->set('mediaversion', $mediaVersion);
// Save modified params
LibraryHelper::saveParams('joomla', $params);
}
return $this;
}
}