From 586e17cb257d861e0b833b380336b9873ac0ca25 Mon Sep 17 00:00:00 2001 From: Mark Dexter Date: Sat, 4 Jun 2011 13:35:56 +0000 Subject: [PATCH] [#26028] Fix backward incompatible changes to JVersion git-svn-id: http://joomlacode.org/svn/joomla/development/trunk@21438 6f6e1ebd-4c2b-0410-823f-f34bde69bce9 --- .../components/com_admin/models/sysinfo.php | 2 + .../views/sysinfo/tmpl/default_system.php | 7 + .../{helpsites-16.xml => helpsites-17.xml} | 4 +- administrator/includes/framework.php | 11 +- .../language/en-GB/en-GB.com_admin.ini | 1 + includes/framework.php | 5 + includes/version.php | 145 ++++++++++++++++++ installation/CHANGELOG | 3 + installation/index.php | 11 +- installation/models/filesystem.php | 12 +- libraries/import.php | 15 +- .../joomla/log/loggers/formattedtext.php | 2 +- .../{version.php => joomla/platform.php} | 23 ++- 13 files changed, 208 insertions(+), 33 deletions(-) rename administrator/help/{helpsites-16.xml => helpsites-17.xml} (61%) create mode 100644 includes/version.php rename libraries/{version.php => joomla/platform.php} (75%) diff --git a/administrator/components/com_admin/models/sysinfo.php b/administrator/components/com_admin/models/sysinfo.php index e74730aee80..7fc60d3b819 100644 --- a/administrator/components/com_admin/models/sysinfo.php +++ b/administrator/components/com_admin/models/sysinfo.php @@ -104,6 +104,7 @@ class AdminModelSysInfo extends JModel { $this->info = array(); $version = new JVersion(); + $platform = new JPlatform(); $db = JFactory::getDBO(); if (isset($_SERVER['SERVER_SOFTWARE'])) { $sf = $_SERVER['SERVER_SOFTWARE']; @@ -118,6 +119,7 @@ class AdminModelSysInfo extends JModel $this->info['server'] = $sf; $this->info['sapi_name'] = php_sapi_name(); $this->info['version'] = $version->getLongVersion(); + $this->info['platform'] = $platform->getLongVersion(); $this->info['useragent'] = phpversion() <= '4.2.1' ? getenv("HTTP_USER_AGENT") : $_SERVER['HTTP_USER_AGENT']; } return $this->info; diff --git a/administrator/components/com_admin/views/sysinfo/tmpl/default_system.php b/administrator/components/com_admin/views/sysinfo/tmpl/default_system.php index d9d18fc87bf..504ba8ffad8 100644 --- a/administrator/components/com_admin/views/sysinfo/tmpl/default_system.php +++ b/administrator/components/com_admin/views/sysinfo/tmpl/default_system.php @@ -85,6 +85,13 @@ defined('_JEXEC') or die; info['version'];?> + + + + + + info['platform'];?> + diff --git a/administrator/help/helpsites-16.xml b/administrator/help/helpsites-17.xml similarity index 61% rename from administrator/help/helpsites-16.xml rename to administrator/help/helpsites-17.xml index f9701902811..b6d5403f190 100644 --- a/administrator/help/helpsites-16.xml +++ b/administrator/help/helpsites-17.xml @@ -1,9 +1,11 @@ + English (GB) - Joomla help wiki 1.6 English (GB) - Joomla help wiki - \ No newline at end of file diff --git a/administrator/includes/framework.php b/administrator/includes/framework.php index 7e0867e9c8a..9d901d25a03 100644 --- a/administrator/includes/framework.php +++ b/administrator/includes/framework.php @@ -25,9 +25,14 @@ if (!file_exists(JPATH_CONFIGURATION.'/configuration.php') || (filesize(JPATH_CO exit(); } -/* - * Joomla! system startup - */ +// +// Joomla system startup. +// + +// Import the cms version library if necessary. +if (!class_exists('JVersion')) { + require JPATH_ROOT.'/includes/version.php'; +} // System includes. require_once JPATH_LIBRARIES.'/import.php'; diff --git a/administrator/language/en-GB/en-GB.com_admin.ini b/administrator/language/en-GB/en-GB.com_admin.ini index e03e5f7d150..07efc9dc21c 100644 --- a/administrator/language/en-GB/en-GB.com_admin.ini +++ b/administrator/language/en-GB/en-GB.com_admin.ini @@ -101,6 +101,7 @@ COM_ADMIN_PHP_BUILT_ON="PHP Built On" COM_ADMIN_PHP_INFORMATION="PHP Information" COM_ADMIN_PHP_SETTINGS="PHP Settings" COM_ADMIN_PHP_VERSION="PHP Version" +COM_ADMIN_PLATFORM_VERSION="Joomla! Platform Version" COM_ADMIN_REGISTER_GLOBALS="Register Globals" COM_ADMIN_RELEVANT_PHP_SETTINGS="Relevant PHP Settings" COM_ADMIN_SAFE_MODE="Safe Mode" diff --git a/includes/framework.php b/includes/framework.php index 8351d749463..68c1ee1fe2f 100644 --- a/includes/framework.php +++ b/includes/framework.php @@ -36,6 +36,11 @@ if (!file_exists(JPATH_CONFIGURATION.'/configuration.php') || (filesize(JPATH_CO // Joomla system startup. // +// Import the cms version library if necessary. +if (!class_exists('JVersion')) { + require JPATH_ROOT.'/includes/version.php'; +} + // System includes. require_once JPATH_LIBRARIES.'/import.php'; diff --git a/includes/version.php b/includes/version.php new file mode 100644 index 00000000000..116fb4a1c39 --- /dev/null +++ b/includes/version.php @@ -0,0 +1,145 @@ +Joomla! is Free Software released under the GNU General Public License.'; + + /** + * 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 bool True if the version is compatible. + * + * @see http://www.php.net/version_compare + * @since 1.0 + */ + public function isCompatible($minimum) + { + return (version_compare(JVERSION, $minimum, 'eq') == 1); + } + + /** + * Method to get the help file version. + * + * @return string Version suffix for help files. + * + * @since 1.0 + */ + public function getHelpVersion() + { + if ($this->RELEASE > '1.0') { + return '.' . str_replace('.', '', $this->RELEASE); + } + else { + return ''; + } + } + + /** + * Gets a "PHP standardized" version string for the current Joomla. + * + * @return string Version string. + * + * @since 1.5 + */ + public function getShortVersion() + { + return $this->RELEASE.'.'.$this->MAINTENANCE; + } + + /** + * Gets a version string for the current Joomla with all release information. + * + * @return string Complete version string. + * + * @since 1.5 + */ + public function getLongVersion() + { + return $this->PRODUCT.' '. $this->RELEASE.'.'.$this->MAINTENANCE.' ' + . $this->STATUS.' [ '.$this->CODE_NAME.' ] '.$this->RELEASE_DATE.' ' + .$this->RELEASE_TIME.' '.$this->RELEASE_TIME_ZONE; + } + + /** + * 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 .= '/'.$this->RELEASE; + } + + // If masked pretend to look like Mozilla 5.0 but still identify ourselves. + if ($mask) { + return 'Mozilla/5.0 '. $this->PRODUCT .'/'. $this->RELEASE . '.'.$this->DEV_LEVEL . ($component ? ' '. $component : ''); + } + else { + return $this->PRODUCT .'/'. $this->RELEASE . '.'.$this->DEV_LEVEL . ($component ? ' '. $component : ''); + } + } +} + +// Define the Joomla version if not already defined. +if (!defined('JVERSION')) { + $jversion = new JVersion; + define('JVERSION', $jversion->getShortVersion()); +} \ No newline at end of file diff --git a/installation/CHANGELOG b/installation/CHANGELOG index 4d020f893d0..e3754a6ccbc 100644 --- a/installation/CHANGELOG +++ b/installation/CHANGELOG @@ -27,6 +27,9 @@ $ -> Language fix or change - -> Removed ! -> Note +04-Jun-2011 Mark Dexter + # [#26028] Fix backward incompatible changes to JVersion + 04-Jun-2011 Andrew Eddie + Feature [#25866] Add support to log deprecated API. + Feature [#25987] JToolBarHelper functions for Save and Create New and Save as Copy (Joseph LeBlanc). diff --git a/installation/index.php b/installation/index.php index bcb44cdbc22..fe66ca04030 100644 --- a/installation/index.php +++ b/installation/index.php @@ -55,9 +55,14 @@ if (file_exists(JPATH_CONFIGURATION.'/configuration.php') && (filesize(JPATH_CON exit(); } -/* - * Joomla system startup - */ +// +// Joomla system startup. +// + +// Import the cms version library if necessary. +if (!class_exists('JVersion')) { + require JPATH_ROOT.'/includes/version.php'; +} // Bootstrap the Joomla Framework. require_once JPATH_LIBRARIES.'/import.php'; diff --git a/installation/models/filesystem.php b/installation/models/filesystem.php index cde8d1ec3b7..cf40b6185bd 100644 --- a/installation/models/filesystem.php +++ b/installation/models/filesystem.php @@ -90,10 +90,10 @@ class JInstallationModelFilesystem extends JModel // Check all possible paths for the real Joomla installation by comparing version files. $rootPath = false; - $checkValue = file_get_contents(JPATH_LIBRARIES.DS.'joomla'.DS.'version.php'); + $checkValue = file_get_contents(JPATH_ROOT.'/includes/version.php'); foreach ($paths as $tmp) { - $filePath = rtrim($tmp, '/').'/libraries/joomla/version.php'; + $filePath = rtrim($tmp, '/').'/includes/version.php'; $buffer = null; @ $ftp->read($filePath, $buffer); if ($buffer == $checkValue) { @@ -192,14 +192,14 @@ class JInstallationModelFilesystem extends JModel // Verify RETR function $buffer = null; - if ($ftp->read($root.'/libraries/joomla/version.php', $buffer) === false) { + if ($ftp->read($root.'/includes/version.php', $buffer) === false) { $ftp->quit(); $this->setError(JText::_('INSTL_FTP_NORETR')); return false; } // Verify valid root path, part two - $checkValue = file_get_contents(JPATH_LIBRARIES.DS.'joomla'.DS.'version.php'); + $checkValue = file_get_contents(JPATH_ROOT.'/includes/version.php'); if ($buffer !== $checkValue) { $ftp->quit(); $this->setError(JText::_('INSTL_FTP_INVALIDROOT')); @@ -347,14 +347,14 @@ class JInstallationModelFilesystem extends JModel // Verify RETR function $buffer = null; - if ($ftp->read($root.'/libraries/joomla/version.php', $buffer) === false) { + if ($ftp->read($root.'/includes/version.php', $buffer) === false) { $ftp->quit(); $this->setError(JText::_('INSTL_FTP_NORETR')); return false; } // Verify valid root path, part two - $checkValue = file_get_contents(JPATH_LIBRARIES.DS.'joomla'.DS.'version.php'); + $checkValue = file_get_contents(JPATH_ROOT.'/includes/version.php'); if ($buffer !== $checkValue) { $ftp->quit(); $this->setError(JText::_('INSTL_FTP_INVALIDROOT')); diff --git a/libraries/import.php b/libraries/import.php index 2fd7c332a7d..19d785b1c26 100644 --- a/libraries/import.php +++ b/libraries/import.php @@ -30,16 +30,21 @@ if (!defined('IS_UNIX')) { define('IS_UNIX', (($os !== 'MAC') && ($os !== 'WIN')) ? true : false); } -// Import the platform version library if necessary. -if (!class_exists('JVersion')) { - require_once JPATH_PLATFORM.'/version.php'; -} - // Import the library loader if necessary. if (!class_exists('JLoader')) { require_once JPATH_PLATFORM.'/loader.php'; } +// Register the JPlatform version class for lazy loading. +if (!class_exists('JPlatform')) { + JLoader::register('JPlatform', JPATH_PLATFORM.'/joomla/platform.php'); +} + +// Define the Joomla Platform version if not already defined. +if (!defined('JPLATFORM')) { + define('JPLATFORM', JPlatform::getShortVersion()); +} + /** * Import the base Joomla Platform libraries. */ diff --git a/libraries/joomla/log/loggers/formattedtext.php b/libraries/joomla/log/loggers/formattedtext.php index 9c768703630..064c10fd1a0 100644 --- a/libraries/joomla/log/loggers/formattedtext.php +++ b/libraries/joomla/log/loggers/formattedtext.php @@ -199,7 +199,7 @@ class JLoggerFormattedText extends JLogger $head[] = '#'; } $head[] = '#Date: '.gmdate('Y-m-d H:i:s').' UTC'; - $head[] = '#Software: '.JVersion::getLongVersion(); + $head[] = '#Software: '.JPlatform::getLongVersion(); $head[] = ''; // Prepare the fields string diff --git a/libraries/version.php b/libraries/joomla/platform.php similarity index 75% rename from libraries/version.php rename to libraries/joomla/platform.php index 70fd5e9bdb6..b89abe2bf11 100644 --- a/libraries/version.php +++ b/libraries/joomla/platform.php @@ -8,27 +8,22 @@ defined('JPATH_PLATFORM') or die; -// Define the Joomla Platform version if not already defined. -if (!defined('JVERSION')) { - define('JVERSION', JVersion::getShortVersion()); -} - /** * Version information class for the Joomla Platform. * * @package Joomla.Platform * @since 11.1 */ -final class JVersion +final class JPlatform { // Product name. const PRODUCT = 'Joomla Platform'; // Release version. - const RELEASE = '1.7'; + const RELEASE = '11'; // Maintenance version. - const MAINTENANCE = '0'; + const MAINTENANCE = '1'; // Development STATUS. - const STATUS = 'Alpha'; + const STATUS = 'Stable'; // Build number. const BUILD = 0; // Code name. @@ -56,7 +51,7 @@ final class JVersion */ public static function isCompatible($minimum) { - return (version_compare(JVERSION, $minimum, 'eq') == 1); + return (version_compare(JPLATFORM, $minimum, 'eq') == 1); } /** @@ -68,7 +63,7 @@ final class JVersion */ public static function getShortVersion() { - return JVersion::RELEASE.'.'.JVersion::MAINTENANCE; + return self::RELEASE.'.'.self::MAINTENANCE; } /** @@ -80,8 +75,8 @@ final class JVersion */ public static function getLongVersion() { - return JVersion::PRODUCT.' '. JVersion::RELEASE.'.'.JVersion::MAINTENANCE.' ' - . JVersion::STATUS.' [ '.JVersion::CODE_NAME.' ] '.JVersion::RELEASE_DATE.' ' - .JVersion::RELEASE_TIME.' '.JVersion::RELEASE_TIME_ZONE; + return self::PRODUCT.' '. self::RELEASE.'.'.self::MAINTENANCE.' ' + . self::STATUS.' [ '.self::CODE_NAME.' ] '.self::RELEASE_DATE.' ' + .self::RELEASE_TIME.' '.self::RELEASE_TIME_ZONE; } }