[Scummvm-cvs-logs] SF.net SVN: scummvm:[48306] web/trunk/include/Models/CompatibilityModel.php
jvprat at users.sourceforge.net
jvprat at users.sourceforge.net
Sat Mar 20 10:57:25 CET 2010
Revision: 48306
http://scummvm.svn.sourceforge.net/scummvm/?rev=48306&view=rev
Author: jvprat
Date: 2010-03-20 09:57:25 +0000 (Sat, 20 Mar 2010)
Log Message:
-----------
WEB: Fix the ordering of versions numbers on the compatibility page (release candidates go before the final releases)
Modified Paths:
--------------
web/trunk/include/Models/CompatibilityModel.php
Modified: web/trunk/include/Models/CompatibilityModel.php
===================================================================
--- web/trunk/include/Models/CompatibilityModel.php 2010-03-19 14:25:38 UTC (rev 48305)
+++ web/trunk/include/Models/CompatibilityModel.php 2010-03-20 09:57:25 UTC (rev 48306)
@@ -30,6 +30,33 @@
return $entries;
}
+ /**
+ * Compares two version strings and returns an integer less than, equal
+ * to, or greater than zero if the first argument is considered to be
+ * respectively less than, equal to, or greater than the second.
+ */
+ static public function compareVersions($version1, $version2) {
+ /* Get the length of the numeric part of the version strings. */
+ $lenNumber1 = strspn($version1, ".0123456789");
+ $lenNumber2 = strspn($version2, ".0123456789");
+ if (($lenNumber1 == $lenNumber2) && (substr($version1, 0, $lenNumber1) == substr($version2, 0, $lenNumber2))) {
+ /* Same version number. Handle special cases. */
+ $extraVersion1 = substr($version1, $lenNumber1);
+ $extraVersion2 = substr($version2, $lenNumber2);
+
+ /* Release candidates go before the final release. */
+ $rc1 = substr($extraVersion1, 0, 2);
+ $rc2 = substr($extraVersion2, 0, 2);
+ if (($rc1 == "rc") && ($rc2 != "rc"))
+ return -1;
+ if (($rc2 == "rc") && ($rc1 != "rc"))
+ return 1;
+
+ /* Break the tie with the standard comparison. */
+ }
+ return strnatcmp($version1, $version2);
+ }
+
/* Get version numbers for all available compatibility charts, excluding the SVN charts. */
static public function getAllVersions() {
if (!($files = scandir(DIR_COMPAT))) {
@@ -45,7 +72,7 @@
$dates[] = substr($file, (strpos($file, '-') + 1), -4);
}
}
- natsort($dates);
+ usort($dates, "CompatibilityModel::compareVersions");
$dates = array_reverse($dates);
return $dates;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list