[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Joomla! Content Management System 5 * 6 * @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org> 7 * @license GNU General Public License version 2 or later; see LICENSE.txt 8 */ 9 10 namespace Joomla\CMS; 11 12 use Joomla\CMS\Cache\CacheController; 13 use Joomla\CMS\Cache\CacheControllerFactoryInterface; 14 use Joomla\CMS\Cache\Controller\CallbackController; 15 use Joomla\CMS\Date\Date; 16 17 // phpcs:disable PSR1.Files.SideEffects 18 \defined('JPATH_PLATFORM') or die; 19 // phpcs:enable PSR1.Files.SideEffects 20 21 /** 22 * Version information class for the Joomla CMS. 23 * 24 * @since 1.0 25 */ 26 final class Version 27 { 28 /** 29 * Product name. 30 * 31 * @var string 32 * @since 3.5 33 */ 34 public const PRODUCT = 'Joomla!'; 35 36 /** 37 * Major release version. 38 * 39 * @var integer 40 * @since 3.8.0 41 */ 42 public const MAJOR_VERSION = 4; 43 44 /** 45 * Minor release version. 46 * 47 * @var integer 48 * @since 3.8.0 49 */ 50 public const MINOR_VERSION = 2; 51 52 /** 53 * Patch release version. 54 * 55 * @var integer 56 * @since 3.8.0 57 */ 58 public const PATCH_VERSION = 2; 59 60 /** 61 * Extra release version info. 62 * 63 * This constant when not empty adds an additional identifier to the version string to reflect the development state. 64 * For example, for 3.8.0 when this is set to 'dev' the version string will be `3.8.0-dev`. 65 * 66 * @var string 67 * @since 3.8.0 68 */ 69 public const EXTRA_VERSION = ''; 70 71 /** 72 * Development status. 73 * 74 * @var string 75 * @since 3.5 76 */ 77 public const DEV_STATUS = 'Stable'; 78 79 /** 80 * Code name. 81 * 82 * @var string 83 * @since 3.5 84 */ 85 public const CODENAME = 'Uaminifu'; 86 87 /** 88 * Release date. 89 * 90 * @var string 91 * @since 3.5 92 */ 93 public const RELDATE = '2-September-2022'; 94 95 /** 96 * Release time. 97 * 98 * @var string 99 * @since 3.5 100 */ 101 public const RELTIME = '20:41'; 102 103 /** 104 * Release timezone. 105 * 106 * @var string 107 * @since 3.5 108 */ 109 public const RELTZ = 'GMT'; 110 111 /** 112 * Copyright Notice. 113 * 114 * @var string 115 * @since 3.5 116 */ 117 public const COPYRIGHT = '(C) 2005 Open Source Matters, Inc. <https://www.joomla.org>'; 118 119 /** 120 * Link text. 121 * 122 * @var string 123 * @since 3.5 124 */ 125 public const URL = '<a href="https://www.joomla.org">Joomla!</a> is Free Software released under the GNU General Public License.'; 126 127 /** 128 * Media version string 129 * 130 * @var string 131 * @since 4.2.0 132 */ 133 private static $mediaVersion = null; 134 135 /** 136 * Check if we are in development mode 137 * 138 * @return boolean 139 * 140 * @since 3.4.3 141 */ 142 public function isInDevelopmentState(): bool 143 { 144 return strtolower(self::DEV_STATUS) !== 'stable'; 145 } 146 147 /** 148 * Compares two a "PHP standardized" version number against the current Joomla version. 149 * 150 * @param string $minimum The minimum version of the Joomla which is compatible. 151 * 152 * @return boolean True if the version is compatible. 153 * 154 * @link https://www.php.net/version_compare 155 * @since 1.0 156 */ 157 public function isCompatible(string $minimum): bool 158 { 159 return version_compare(JVERSION, $minimum, 'ge'); 160 } 161 162 /** 163 * Method to get the help file version. 164 * 165 * @return string Version suffix for help files. 166 * 167 * @since 1.0 168 */ 169 public function getHelpVersion(): string 170 { 171 return '.' . self::MAJOR_VERSION . self::MINOR_VERSION; 172 } 173 174 /** 175 * Gets a "PHP standardized" version string for the current Joomla. 176 * 177 * @return string Version string. 178 * 179 * @since 1.5 180 */ 181 public function getShortVersion(): string 182 { 183 $version = self::MAJOR_VERSION . '.' . self::MINOR_VERSION . '.' . self::PATCH_VERSION; 184 185 if (!empty(self::EXTRA_VERSION)) { 186 $version .= '-' . self::EXTRA_VERSION; 187 } 188 189 return $version; 190 } 191 192 /** 193 * Gets a version string for the current Joomla with all release information. 194 * 195 * @return string Complete version string. 196 * 197 * @since 1.5 198 */ 199 public function getLongVersion(): string 200 { 201 return self::PRODUCT . ' ' . $this->getShortVersion() . ' ' 202 . self::DEV_STATUS . ' [ ' . self::CODENAME . ' ] ' . self::RELDATE . ' ' 203 . self::RELTIME . ' ' . self::RELTZ; 204 } 205 206 /** 207 * Returns the user agent. 208 * 209 * @param string $suffix String to append to resulting user agent. 210 * @param bool $mask Mask as Mozilla/5.0 or not. 211 * @param bool $addVersion Add version afterwards to component. 212 * 213 * @return string User Agent. 214 * 215 * @since 1.0 216 */ 217 public function getUserAgent(string $suffix = '', bool $mask = false, bool $addVersion = true): string 218 { 219 if ($suffix === '') { 220 $suffix = 'Framework'; 221 } 222 223 if ($addVersion) { 224 $suffix .= '/' . self::MAJOR_VERSION . '.' . self::MINOR_VERSION; 225 } 226 227 // If masked pretend to look like Mozilla 5.0 but still identify ourselves. 228 return ($mask ? 'Mozilla/5.0 ' : '') . self::PRODUCT . '/' . $this->getShortVersion() . ($suffix ? ' ' . $suffix : ''); 229 } 230 231 /** 232 * Generate a media version string for assets 233 * Public to allow third party developers to use it 234 * 235 * @return string 236 * 237 * @since 3.2 238 */ 239 public function generateMediaVersion(): string 240 { 241 return md5($this->getLongVersion() . Factory::getApplication()->get('secret') . (new Date())->toSql()); 242 } 243 244 /** 245 * Gets a media version which is used to append to Joomla core media files. 246 * 247 * This media version is used to append to Joomla core media in order to trick browsers into 248 * reloading the CSS and JavaScript, because they think the files are renewed. 249 * The media version is renewed after Joomla core update, install, discover_install and uninstallation. 250 * 251 * @return string The media version. 252 * 253 * @since 3.2 254 */ 255 public function getMediaVersion(): string 256 { 257 // Load the media version and cache it for future use 258 if (self::$mediaVersion === null) { 259 self::$mediaVersion = $this->getMediaVersionCache() 260 ->get([$this, 'generateMediaVersion'], [], md5('_media_version' . $this->getLongVersion())); 261 } 262 263 return self::$mediaVersion; 264 } 265 266 /** 267 * Function to refresh the media version 268 * 269 * @return Version Instance of $this to allow chaining. 270 * 271 * @since 3.2 272 */ 273 public function refreshMediaVersion(): Version 274 { 275 return $this->setMediaVersion($this->generateMediaVersion()); 276 } 277 278 /** 279 * Sets the media version which is used to append to Joomla core media files. 280 * 281 * @param string $mediaVersion The media version. 282 * 283 * @return Version Instance of $this to allow chaining. 284 * 285 * @since 3.2 286 */ 287 public function setMediaVersion(string $mediaVersion): Version 288 { 289 // Do not allow empty media versions 290 if (!empty($mediaVersion)) { 291 self::$mediaVersion = $mediaVersion; 292 293 $this->getMediaVersionCache() 294 ->store(['result' => $mediaVersion, 'output' => ''], md5('_media_version' . $this->getLongVersion())); 295 } 296 297 return $this; 298 } 299 300 /** 301 * Get cache instance for MediaVersion caching. 302 * 303 * @return CacheController 304 * 305 * @since 4.2.0 306 */ 307 private function getMediaVersionCache(): CacheController 308 { 309 /** @var CallbackController $cache */ 310 $cache = Factory::getContainer()->get(CacheControllerFactoryInterface::class) 311 ->createCacheController('callback', ['defaultgroup' => '_media_version', 'caching' => true]); 312 313 $cache->setLifeTime(315576000); 314 315 // Disable cache when Debug is enabled 316 if (JDEBUG) { 317 $cache->setCaching(false); 318 } 319 320 return $cache; 321 } 322 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |