From 1f62f86af5225643f2a7d72c1a050c46ffc37477 Mon Sep 17 00:00:00 2001 From: eric Date: Thu, 24 Jun 2004 19:08:35 +0000 Subject: getting closer to printing package search results - also fixed some XHTML stuff --- web/lib/acctfuncs.inc | 2 +- web/lib/aur.inc | 52 +++++++++++++++++++---- web/lib/pkgs.inc | 114 ++++++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 148 insertions(+), 20 deletions(-) (limited to 'web/lib') diff --git a/web/lib/acctfuncs.inc b/web/lib/acctfuncs.inc index a7c6da55..9cd7fab2 100644 --- a/web/lib/acctfuncs.inc +++ b/web/lib/acctfuncs.inc @@ -139,7 +139,7 @@ function display_account_form($UTYPE,$A,$U="",$T="",$S="", print "   "; } - print ""; + print ""; print ""; print "\n"; diff --git a/web/lib/aur.inc b/web/lib/aur.inc index ce3b7d9a..39c5c92f 100644 --- a/web/lib/aur.inc +++ b/web/lib/aur.inc @@ -22,6 +22,40 @@ $SUPPORTED_LANGS = array( # what languages we have translations for $QBUG = 1; # toggle query logging to /tmp/aurq.log $DBUG = 1; # use dbug($msg) to log to /tmp/aurd.log + +# return an array of info for each Trusted user +# +function getTrustedUsers() { + $tus = array(); + $dbh = db_connect(); + $q = "SELECT * FROM Users WHERE AccountTypeID = 2 "; + $q.= "ORDER BY Username ASC"; + $result = db_query($q, $dbh); + if ($result) { + while ($row = mysql_fetch_assoc($result)) { + $tus[] = $row; + } + } + return $tus; +} + + +# return an array of info for each Developer +# +function getDevelopers() { + $devs = array(); + $dbh = db_connect(); + $q = "SELECT * FROM Users WHERE AccountTypeID = 3 "; + $q.= "ORDER BY Username ASC"; + $result = db_query($q, $dbh); + if ($result) { + while ($row = mysql_fetch_assoc($result)) { + $devs[] = $row; + } + } + return $devs; +} + # see if the visitor is already logged in # function check_sid() { @@ -261,15 +295,19 @@ function set_lang() { # function html_header() { global $_COOKIE; + global $LANG; print "\n"; - print "\n"; - print ""; + print "\n"; + print "\n"; print "\n"; - print "AUR\n"; + print "AUR (".$LANG.")\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 "
"; - print "ArchLinux User-community Repository
"; + print "ArchLinux User-community Repository
"; # XXX CSS help - a:link, a:visited, etc are defined, but I don't want to # use the defaults. Is this the way to override them? @@ -333,7 +371,7 @@ function html_header() { print "
\n"; - print "  
\n"; + print "  
\n"; print "\n\n"; return; diff --git a/web/lib/pkgs.inc b/web/lib/pkgs.inc index e26d455d..bd63ee2e 100644 --- a/web/lib/pkgs.inc +++ b/web/lib/pkgs.inc @@ -35,14 +35,18 @@ function pkgLocations() { # display the search form in a boxSoft style # -function pkg_search_page($L="",$C="",$K="",$SB="",$PP="") { +function pkg_search_page($L="",$C="",$K="",$SB="",$O=0,$PP=25) { # L: PackageLocations.ID # C: PackageCategories.ID # K: Keywords # SB: Sort by + # O: Row offset # PP: Per page $locs = pkgLocations(); $cats = pkgCategories(); + $devs = getDevelopers(); + $tus = getTrustedUsers(); + $dbh = db_connect(); print "
\n"; print "\n"; @@ -60,7 +64,7 @@ function pkg_search_page($L="",$C="",$K="",$SB="",$PP="") { print "\n"; print "\n"; print "\n"; print "
\n"; print " ".__("Location"); - print "
\n"; + print "
\n"; print "
\n"; print " ".__("Category"); - print "
\n"; + print "
\n"; print "
\n"; print " ".__("Keywords"); - print "
\n"; + print "
\n"; print " \n"; print "
\n"; print " ".__("Sort by"); - print "
\n"; + print "
\n"; print "
\n"; print " ".__("Per page"); - 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 "
\n"; + print " \n"; + print " \n"; + + # query to pull out package info + # + $q = "SELECT Packages.*, IF(ISNULL(PackageID), 0, COUNT(*)) AS Popularity "; + $q.= "FROM Packages LEFT JOIN PackageVotes "; + $q.= "ON Packages.ID = PackageVotes.PackageID "; + $has_where = 0; + if ($L) { + $q.= "WHERE LocationID = ".intval($L)." "; + $has_where = 1; + } + if ($C) { + if (!$has_where) { + $q.= "WHERE CategoryID = ".intval($C)." "; + $has_where = 1; + } else { + $q.= "AND CategoryID = ".intval($C)." "; + } + } + if ($K) { + if (!$has_where) { + $q.= "WHERE (Name LIKE '".mysql_escape_string($K)."%' OR "; + $q.= "Description LIKE '%".mysql_escape_string($K)."%') "; + $has_where = 1; + } else { + $q.= "AND (Name LIKE '".mysql_escape_string($K)."%' OR "; + $q.= "Description LIKE '%".mysql_escape_string($K)."%') "; + } + } + + $q.= "GROUP BY PackageID "; + switch ($SB) { + case 'c': + $q.= "ORDER BY CategoryID ASC, Name ASC, LocationID ASC "; + break; + case 'l': + $q.= "ORDER BY LocationID ASC, Name ASC, CategoryID ASC "; + break; + default: + $q.= "ORDER BY Name ASC, LocationID ASC, CategoryID ASC "; + break; + } + $q.= "LIMIT ".intval($O).", ".intval($PP); + $result = db_query($q, $dbh); + if (!$result) { + print $q."
\n"; + print __("No packages matched your search criteria."); + } else { + + # print out package search results + # + print "
\n"; + print "\n"; + print "\n"; + print " \n"; + print " \n"; +# print "\n"; + print "\n"; + print "
\n"; + print " \n"; + print " \n"; + +# for ($i=0; $row = mysql_fetch_assoc($result); $i++) { +# (($i % 2) == 0) ? $c = "data1" : $c = "data2"; +# print "
\n"; +# +# } + print "Yippie! You found some packages!"; + + print "
\n"; + print "
\n"; + } + + print "
\n"; -- cgit v1.2.3-24-g4f1b