Locate latest revision ISO
Modified: trunk/cis/ReactOS.RevisionISO/index.php

Modified: trunk/cis/ReactOS.RevisionISO/index.php
--- trunk/cis/ReactOS.RevisionISO/index.php	2005-08-02 16:11:13 UTC (rev 16972)
+++ trunk/cis/ReactOS.RevisionISO/index.php	2005-08-02 16:13:02 UTC (rev 16973)
@@ -109,9 +109,12 @@
 	</td>
 </tr>
 <tr>
-	<td colspan="7">
+	<td colspan="4">
 		<input type="submit" name="getnextiso" value="Next ISO" tabindex="4" style="border: 1px solid #000000"></input>
 	</td>
+	<td colspan="3" align="right">
+		<input type="submit" name="getlatestiso" value="Latest ISO" tabindex="5" style="border: 1px solid #000000"></input>
+	</td>
 </tr>
 </table>
 
@@ -139,7 +142,7 @@
 <?php
 }
 
-function getNextRevisionISO($branch, $revision)
+function locateRevisionISO($branch, $revision, $latest)
 {
 	$revision = intval($revision);
 	$path = ISO_PATH . "\\" . $branch;
@@ -153,14 +156,17 @@
 	$d->close();
 	
 	if (is_array($filelist)) {
-		usort($filelist, "dm_usort_cmp_desc");
+		$sortFunction = $latest ? "dm_usort_cmp" : "dm_usort_cmp_desc";
+		usort($filelist, $sortFunction);
 		reset($filelist);
 		while (list($key, $filename) = each($filelist)) {
 			if (ereg('ReactOS-' . $branch . '-r([0-9]*).iso', $filename, $regs))
 			{
 				$thisRevision = intval($regs[1]);
-				if ($thisRevision > $revision)
+				if (($latest) && ($thisRevision < $revision))
 					return $regs[1];
+				else if ($thisRevision > $revision)
+					return $regs[1];
 				$lastRevision = $thisRevision;
 			}
 		}
@@ -169,7 +175,16 @@
 	return "";
 }
 
+function getNextRevisionISO($branch, $revision)
+{
+	return locateRevisionISO($branch, $revision, false);
+}
 
+function getLatestRevisionISO($branch)
+{
+	return locateRevisionISO($branch, 999999, true);
+}
+
 function main()
 {
 	$branch = $_POST["branch"];
@@ -199,6 +214,12 @@
 	printMenu(getNextRevisionISO($_POST["branch"], $_POST["revision"]));
 	printFooter();
 }
+else if (!empty($_POST["getlatestiso"]) && !empty($_POST["branch"]))
+{
+	printHeader();
+	printMenu(getLatestRevisionISO($_POST["branch"]));
+	printFooter();
+}
 else
 {
 	printHeader();