From: Michael M Slusarz Date: Fri, 29 Jan 2010 04:29:10 +0000 (-0700) Subject: Add raw version output to Horde_Registry::getVersion() X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=64ef696f27bb1f20f6a55747f6c0e01246111b4a;p=horde.git Add raw version output to Horde_Registry::getVersion() --- diff --git a/framework/Core/lib/Horde/Registry.php b/framework/Core/lib/Horde/Registry.php index b2fe5c113..78d0a6e08 100644 --- a/framework/Core/lib/Horde/Registry.php +++ b/framework/Core/lib/Horde/Registry.php @@ -1254,11 +1254,13 @@ class Horde_Registry /** * Return the version string for a given application. * - * @param string $app The application to get the value for. + * @param string $app The application to get the value for. + * @param boolean $number Return the raw version number, suitable for + * comparison purposes. * * @return string The version string for the application. */ - public function getVersion($app = null) + public function getVersion($app = null, $number = false) { if (empty($app)) { $app = $this->getApp(); @@ -1266,10 +1268,13 @@ class Horde_Registry try { $api = $this->getApiInstance($app, 'application'); - return $api->version; } catch (Horde_Exception $e) { return 'unknown'; } + + return $number + ? $api->version + : preg_replace('/H\d \((.*)\)/', '$1', $api->version); } /** diff --git a/horde/admin/setup/index.php b/horde/admin/setup/index.php index 2ee9b03ae..78d544944 100644 --- a/horde/admin/setup/index.php +++ b/horde/admin/setup/index.php @@ -134,13 +134,13 @@ foreach ($a as $app) { $apps[$i]['name'] = $conf_link . $apps[$i]['sort'] . ''; $apps[$i]['icon'] = Horde::img($registry->get('icon', $app), $registry->get('name', $app), '', ''); $apps[$i]['version'] = ''; - if ($version = $registry->getVersion($app)) { + if ($version = $registry->getVersion($app, true)) { $apps[$i]['version'] = $version; if (!empty($versions)) { if (!isset($versions[$app])) { $apps[$i]['load'] = $warning; $apps[$i]['vstatus'] = _("No stable version exists yet."); - } elseif (version_compare(preg_replace('/H\d \((.*)\)/', '$1', $versions[$app]['version']), preg_replace('/H\d \((.*)\)/', '$1', $apps[$i]['version']), '>')) { + } elseif (version_compare(preg_replace('/H\d \((.*)\)/', '$1', $versions[$app]['version']), $apps[$i]['version'], '>')) { $apps[$i]['load'] = $error; $apps[$i]['vstatus'] = Horde::link($versions[$app]['url'], sprintf(_("Download %s"), $app)) . sprintf(_("A newer version (%s) exists."), $versions[$app]['version']) . ' '; } else {