diff options
author | eric <eric> | 2004-06-24 19:08:35 +0000 |
---|---|---|
committer | eric <eric> | 2004-06-24 19:08:35 +0000 |
commit | 1f62f86af5225643f2a7d72c1a050c46ffc37477 (patch) | |
tree | 491ff279b1ad75d461b071f993d6978de19aac3f /web/lib | |
parent | 9c6ec26c3279ca3e1d186196d229449d9501c386 (diff) | |
download | aurweb-1f62f86af5225643f2a7d72c1a050c46ffc37477.tar.xz |
getting closer to printing package search results - also fixed some XHTML stuff
Diffstat (limited to 'web/lib')
-rw-r--r-- | web/lib/acctfuncs.inc | 2 | ||||
-rw-r--r-- | web/lib/aur.inc | 52 | ||||
-rw-r--r-- | web/lib/pkgs.inc | 114 |
3 files changed, 148 insertions, 20 deletions
diff --git a/web/lib/acctfuncs.inc b/web/lib/acctfuncs.inc index a7c6da5..9cd7fab 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 "<input type='submit' class='button'"; print " value='".__("Create")."'> "; } - print "<input type='reset' value='".__("Reset")."'>"; + print "<input type='reset' class='button' value='".__("Reset")."'>"; print "</td>"; print "</tr>\n"; diff --git a/web/lib/aur.inc b/web/lib/aur.inc index ce3b7d9..39c5c92 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 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; - print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"; - print "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">"; + print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\""; + print " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"; + print "<html xmlns=\"http://www.w3.org/1999/xhtml\""; + print " xml:lang=\"".$LANG."\" lang=\"".$LANG."\">\n"; print "<head>\n"; - print "<title>AUR</title>\n"; + print "<title>AUR (".$LANG.")</title>\n"; print "<link rel='stylesheet' type='text/css' href='/css/fonts.css'/>\n"; print "<link rel='stylesheet' type='text/css' href='/css/containers.css'/>\n"; print "<link rel='shortcut icon' href='/images/favicon.ico'/>\n"; - print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n"; + print "<meta http-equiv=\"Content-Type\""; + print " content=\"text/html; charset=UTF-8\" />\n"; print "</head>\n"; print "<body bgcolor='white'>\n"; print "<table cellspacing='0' "; @@ -287,9 +325,9 @@ function html_header() { # XXX Can I scale a PNG like this? # - print "<img src='/images/AUR-logo-80.png' width='85' height='45' border='0'></a></td>\n"; + print "<img src='/images/AUR-logo-80.png' width='85' height='45' border='0' /></a></td>\n"; print " <td class='headerDisplay' valign='top' align='right'>"; - print "<span class='preHeader'>ArchLinux User-community Repository</span><br/>"; + print "<span class='preHeader'>ArchLinux User-community Repository</span><br />"; # 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 " </tr>"; print " <tr>\n"; print " <td class='contentDisplay'>\n"; - print " <br/>\n"; + print " <br />\n"; print "<!-- Start of main content -->\n\n"; return; diff --git a/web/lib/pkgs.inc b/web/lib/pkgs.inc index e26d455..bd63ee2 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 "<center>\n"; print "<table cellspacing='3' class='boxSoft'>\n"; @@ -60,7 +64,7 @@ function pkg_search_page($L="",$C="",$K="",$SB="",$PP="") { print "<tr>\n"; print "<td align='right'>\n"; print " <span class='f5'><span class='blue'>".__("Location"); - print "</span></span><br>\n"; + print "</span></span><br />\n"; print " <select name='L'>\n"; print " <option value=0> ".__("Any")."\n"; while (list($id, $loc) = each($locs)) { @@ -75,7 +79,7 @@ function pkg_search_page($L="",$C="",$K="",$SB="",$PP="") { print "<td align='right'>\n"; print " <span class='f5'><span class='blue'>".__("Category"); - print "</span></span><br>\n"; + print "</span></span><br />\n"; print " <select name='C'>\n"; print " <option value=0> ".__("Any")."\n"; while (list($id, $cat) = each($cats)) { @@ -90,27 +94,24 @@ function pkg_search_page($L="",$C="",$K="",$SB="",$PP="") { print "<td align='right'>\n"; print " <span class='f5'><span class='blue'>".__("Keywords"); - print "</span></span><br>\n"; + print "</span></span><br />\n"; print " <input type='text' name='K' size='35'"; print " value='".$K."' maxlength='35'>\n"; print "</td>\n"; print "<td align='right'>\n"; print " <span class='f5'><span class='blue'>".__("Sort by"); - print "</span></span><br>\n"; + print "</span></span><br />\n"; print " <select name='SB'>\n"; + print " <option value=n"; + $SB == "n" ? print "selected> " : print "> "; + print __("Name")."\n"; print " <option value=c"; $SB == "c" ? print "selected> " : print "> "; print __("Category")."\n"; print " <option value=l"; $SB == "l" ? print "selected> " : print "> "; print __("Location")."\n"; - print " <option value=m"; - $SB == "m" ? print "selected> " : print "> "; - print __("Maintainer")."\n"; - print " <option value=n"; - $SB == "n" ? print "selected> " : print "> "; - print __("Name")."\n"; print " <option value=p"; $SB == "p" ? print "selected> " : print "> "; print __("Popularity")."\n"; @@ -119,7 +120,7 @@ function pkg_search_page($L="",$C="",$K="",$SB="",$PP="") { print "<td align='right'>\n"; print " <span class='f5'><span class='blue'>".__("Per page"); - print "</span></span><br>\n"; + print "</span></span><br />\n"; print " <select name='PP'>\n"; print " <option value=25"; $PP == 25 ? print "selected> 25\n" : print "> 25\n"; @@ -138,11 +139,100 @@ function pkg_search_page($L="",$C="",$K="",$SB="",$PP="") { print "</tr>\n"; print "</table>\n"; + print "</form>\n"; print " </td>\n"; print "</tr>\n"; print "</table>\n"; print "</center>\n"; + print "<br />\n"; + + print "<center>\n"; + print "<table cellspacing='3' class='boxSoft'>\n"; + print "<tr>\n"; + print " <td class='boxSoftTitle' align='right'>\n"; + print " <span class='f3'Package Listing</span>\n"; + print " </td>\n"; + print " <td class='boxSoft'>\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."<br />\n"; + print __("No packages matched your search criteria."); + } else { + + # print out package search results + # + print "<center>\n"; + print "<table cellspacing='3' class='boxSoft'>\n"; + print "<tr>\n"; + print " <td class='boxSoftTitle' align='right'>\n"; + print " <span class='f3'Package Listing</span>\n"; + print " </td>\n"; + print " <td class='boxSoft'>\n"; + +# for ($i=0; $row = mysql_fetch_assoc($result); $i++) { +# (($i % 2) == 0) ? $c = "data1" : $c = "data2"; +# print "<tr>\n"; +# print "<td "; +# print "</tr>\n"; +# +# } + print "Yippie! You found some packages!"; + + print " </td>\n"; + print "</tr>\n"; + print "</table>\n"; + print "</center>\n"; + } + + + print " </td>\n"; + print "</tr>\n"; + print "</table>\n"; + print "</center>\n"; return; } |