Add raw version output to Horde_Registry::getVersion()
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 29 Jan 2010 04:29:10 +0000 (21:29 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 29 Jan 2010 18:21:19 +0000 (11:21 -0700)
framework/Core/lib/Horde/Registry.php
horde/admin/setup/index.php

index b2fe5c1..78d0a6e 100644 (file)
@@ -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);
     }
 
     /**
index 2ee9b03..78d5449 100644 (file)
@@ -134,13 +134,13 @@ foreach ($a as $app) {
     $apps[$i]['name'] = $conf_link . $apps[$i]['sort'] . '</a>';
     $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']) . '</a> ';
             } else {