From 4b80bc34ffb738ef3cd1a7944e8716d3e8140565 Mon Sep 17 00:00:00 2001 From: eric Date: Mon, 28 Jun 2004 19:37:02 +0000 Subject: re-working pkgsearch, NumVotes add to Packages table --- web/lib/pkgs.inc | 176 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 95 insertions(+), 81 deletions(-) (limited to 'web/lib/pkgs.inc') diff --git a/web/lib/pkgs.inc b/web/lib/pkgs.inc index b4c4788..9fd70cb 100644 --- a/web/lib/pkgs.inc +++ b/web/lib/pkgs.inc @@ -35,7 +35,8 @@ function pkgLocations() { # display the search form in a boxSoft style # -function pkg_search_page($SID="",$L="",$C="",$K="",$SB="",$M=0,$O=0,$PP=25) { +function pkg_search_page($SID="",$L="",$C="",$K="",$SB="",$M=0,$O=0,$PP=25, + $D="") { # SID: session id cookie # L: PackageLocations.ID # C: PackageCategories.ID @@ -44,12 +45,15 @@ function pkg_search_page($SID="",$L="",$C="",$K="",$SB="",$M=0,$O=0,$PP=25) { # M: search "my packages" # O: Row offset # PP: Per page + # D: Direction to advance (Less/More) $locs = pkgLocations(); $cats = pkgCategories(); $devs = getDevelopers(); $tus = getTrustedUsers(); $dbh = db_connect(); + + if (!$PP) {$PP = 25;} if ($O) { $OFFSET = intval($O); } else { @@ -68,6 +72,17 @@ function pkg_search_page($SID="",$L="",$C="",$K="",$SB="",$M=0,$O=0,$PP=25) { # The search form # + print "SID=$SID, L=$L, C=$C, K=$K, SB=$SB, M=$M, O=$O, PP=$PP
\n"; + + print "
\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "
\n"; print "\n"; print "\n"; @@ -77,8 +92,6 @@ function pkg_search_page($SID="",$L="",$C="",$K="",$SB="",$M=0,$O=0,$PP=25) { print "\n"; print "\n"; print " \n"; print "\n"; print "
\n"; - print "\n"; - print "\n"; print "\n"; print "\n"; @@ -154,12 +167,13 @@ function pkg_search_page($SID="",$L="",$C="",$K="",$SB="",$M=0,$O=0,$PP=25) { print "\n"; print "\n"; if ($SID) { print "\n"; } @@ -167,61 +181,18 @@ function pkg_search_page($SID="",$L="",$C="",$K="",$SB="",$M=0,$O=0,$PP=25) { print "\n"; print "
 \n"; - print " \n"; + print " \n"; print " \n"; - print " \n"; print "
\n"; - print "\n"; print "
\n"; print "
\n"; print "
\n"; - - # TODO need an "action" table in here like on /devel? It would - # allow the visitor to flag packages out-of-date, vote, adopt/disown? - # Probably need to think about the overall UI of this - the package - # name will be a link that goes to 'details'. There should also be - # a column for 'manage/edit' - - if ($SID) { - print "
\n"; - print "
\n"; - print "\n"; - print "\n"; - print " \n"; - print "\n"; - print "\n"; - print " \n"; - print "\n"; - print "
\n"; - print " ".__("Actions")."\n"; - print "
\n"; - print "\n"; - print "\n"; - print "\n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print "\n"; - print "
"; - print ""; - print ""; - print ""; - print "
\n"; - print "
\n"; - print "
\n"; - print "
\n"; - print "
\n"; - } - # query to pull out package info # - $q = "SELECT Packages.*, IF(ISNULL(PackageID), 0, COUNT(*)) AS Votes "; - $q.= "FROM Packages LEFT JOIN PackageVotes "; - $q.= "ON Packages.ID = PackageVotes.PackageID "; +# $q = "SELECT Packages.*, IF(ISNULL(PackageID), 0, COUNT(*)) AS Votes "; +# $q.= "FROM Packages LEFT JOIN PackageVotes "; +# $q.= "ON Packages.ID = PackageVotes.PackageID "; + $q = "SELECT * FROM Packages "; $has_where = 0; if ($L) { $q.= "WHERE LocationID = ".intval($L)." "; @@ -256,7 +227,6 @@ function pkg_search_page($SID="",$L="",$C="",$K="",$SB="",$M=0,$O=0,$PP=25) { } } - $q.= "GROUP BY PackageID "; switch ($SB) { case 'c': $q.= "ORDER BY CategoryID ASC, Name ASC, LocationID ASC "; @@ -265,7 +235,7 @@ function pkg_search_page($SID="",$L="",$C="",$K="",$SB="",$M=0,$O=0,$PP=25) { $q.= "ORDER BY LocationID ASC, Name ASC, CategoryID ASC "; break; case 'v': - $q.= "ORDER BY Votes DESC, Name ASC, CategoryID ASC "; + $q.= "ORDER BY NumVotes DESC, Name ASC, CategoryID ASC "; break; default: $q.= "ORDER BY Name ASC, LocationID ASC, CategoryID ASC "; @@ -273,6 +243,8 @@ function pkg_search_page($SID="",$L="",$C="",$K="",$SB="",$M=0,$O=0,$PP=25) { } $q.= "LIMIT ".$OFFSET.", ".intval($PP); + print $q."
\n"; + $result = db_query($q, $dbh); if (!$result) { print __("No packages matched your search criteria."); @@ -281,6 +253,45 @@ function pkg_search_page($SID="",$L="",$C="",$K="",$SB="",$M=0,$O=0,$PP=25) { print __("No packages matched your search criteria."); } else { + # TODO need an "action" table in here like on /devel? It would + # allow the visitor to flag packages out-of-date, vote, adopt/disown? + # Probably need to think about the overall UI of this - the package + # name will be a link that goes to 'details'. There should also be + # a column for 'manage/edit' + + if ($SID) { + print "
\n"; + print "\n"; + print "\n"; + print " \n"; + print "\n"; + print "\n"; + print " \n"; + print "\n"; + print "
\n"; + print " ".__("Actions")."\n"; + print "
\n"; + print "\n"; + print "\n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print "\n"; + print "
"; + print ""; + print ""; + print ""; + print "
\n"; + print "
\n"; + print "
\n"; + print "
\n"; + } + # print out package search results # print "
\n"; @@ -310,6 +321,10 @@ function pkg_search_page($SID="",$L="",$C="",$K="",$SB="",$M=0,$O=0,$PP=25) { print " bottom'>".__("Description")."\n"; print " ".__("Maintainer")."\n"; + if ($SID) { + print " ".__("Manage")."\n"; + } print "\n"; for ($i=0; $row = mysql_fetch_assoc($result); $i++) { @@ -320,7 +335,12 @@ function pkg_search_page($SID="",$L="",$C="",$K="",$SB="",$M=0,$O=0,$PP=25) { if ($row["OutOfDate"]) { print ""; } - print ""; + print ""; + if ($i == 0) { + $all_ids = $row["ID"]; + } else { + $all_ids .= ":".$row["ID"]; + } if ($row["OutOfDate"]) { print ""; } @@ -330,21 +350,34 @@ function pkg_search_page($SID="",$L="",$C="",$K="",$SB="",$M=0,$O=0,$PP=25) { print $locs[$row["LocationID"]]."\n"; print " "; print $cats[$row["CategoryID"]]."\n"; - print " "; - print $row["Name"]."-".$row["Version"]."\n"; + print " "; + $details_url = "".$row["Name"]; + $details_url.= "-".$row["Version"].""; + print $details_url."\n"; print " "; - print "   ".$row["Votes"]."\n"; + print "   ".$row["NumVotes"]."\n"; print " "; print $row["Description"]."\n"; print " "; + $not_managed = 0; if (isset($devs[$row["MaintainerUID"]])) { print $devs[$row["MaintainerUID"]]["Username"]; } elseif (isset($tus[$row["MaintainerUID"]])) { print $tus[$row["MaintainerUID"]]["Username"]; } else { print "None"; + $not_managed = 1; } print "\n"; + if ($myuid == $row["MaintainerUID"] || $not_managed) { + $manage_url = "Manage"; + print " "; + print $manage_url."\n"; + } else { + print " \n"; + } print "\n"; @@ -353,40 +386,20 @@ function pkg_search_page($SID="",$L="",$C="",$K="",$SB="",$M=0,$O=0,$PP=25) { print " \n"; print "\n"; print "\n"; + print "\n"; - print "
\n"; print "\n"; print "\n"; print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
"; - print "
\n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print "
\n"; print "
"; - print "
\n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print " \n"; - print "
\n"; print "
\n"; @@ -395,6 +408,7 @@ function pkg_search_page($SID="",$L="",$C="",$K="",$SB="",$M=0,$O=0,$PP=25) { print "
\n"; print "
\n"; } + print "\n"; return; } -- cgit v1.2.3-54-g00ecf