appdb/include util.php

WineHQ wineowner at wine.codeweavers.com
Wed Jun 6 21:43:57 CDT 2007


ChangeSet ID:	31162
CVSROOT:	/opt/cvs-commit
Module name:	appdb
Changes by:	wineowner at winehq.org	2007/06/06 21:43:57

Modified files:
	include        : util.php 

Log message:
	Chris Morgan <cmorgan at alum.wpi.edu>
	Programmatically fix up the bugzilla versions list. Sort the versions with the newest version first, limit the
	total number of versions to 6 by truncating the array and manually add the 'CVS' entry since we trim this entry
	off. This should make it easier for users to figure out which version to pick.

Patch: http://cvs.winehq.org/patch.py?id=31162

Old revision  New revision  Changes     Path
 1.88          1.89          +39 -12     appdb/include/util.php

Index: appdb/include/util.php
diff -u -p appdb/include/util.php:1.88 appdb/include/util.php:1.89
--- appdb/include/util.php:1.88	7 Jun 2007  2:43:57 -0000
+++ appdb/include/util.php	7 Jun 2007  2:43:57 -0000
@@ -164,25 +164,52 @@ function make_bugzilla_version_list($var
 {
     $table = BUGZILLA_DB.".versions";
     $where = "WHERE product_id=".BUGZILLA_PRODUCT_ID;
-    $sQuery = "SELECT value FROM $table $where ORDER BY value";
+    $sQuery = "SELECT value FROM $table $where";
 
     $hResult = query_bugzilladb($sQuery);
     if(!$hResult) return;
 
+    // NOTE: perform some version list pruning
+    //       - Reverse the order, we want the newest entries first
+    //         and we can't use 'order by' since we have no column
+    //         to order by, but the entries should come out in the
+    //         order they were added
+    //       - Trim the list, we don't want every version of wine ever released
+    //       - Add 'CVS' explicitly since we trim it out
+    //
+    // TODO: if we ever get a reasonable way to order the list replace this code
+    //       with that
+    $aVersions = array();
+    while(list($value) = mysql_fetch_row($hResult))
+    {
+      // exclude unspecified versions
+      if($value != "unspecified")
+        $aVersions[] = $value;
+    }
+
+    // now reverse the array order
+    $aVersions = array_reverse($aVersions);
+
+    // now trim off all but the last X versions
+    $iVersionsToKeep = 6;
+    $aVersions = array_slice($aVersions, 0, $iVersionsToKeep);
+
+    // explicitly add 'CVS' since we are eliminating that above
+    $aVersions[] = "CVS";
+
+    // DONE TRIMMING VERSIONS
+    /////////////////////////
+
+
+    // build the selection array
     echo "<select name='$varname'>\n";
     echo "<option value=\"\">Choose ...</option>\n";
-    while(list($value) = mysql_fetch_row($hResult))
+    foreach($aVersions as $sKey => $sValue)
     {
-        if($value == "unspecified")
-        {
-            // We do not unspecified versions!!!
-        } else
-        {
-            if($value == $cvalue)
-                echo "<option value=$value selected>$value\n";
-            else
-                echo "<option value=$value>$value\n";
-        }
+      if($sValue == $cvalue)
+        echo "<option value=$sValue selected>$sValue\n";
+      else
+        echo "<option value=$sValue>$sValue\n";
     }
     echo "</select>\n";
 }



More information about the wine-cvs mailing list