mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
getting closer to printing package search results - also fixed some XHTML stuff
This commit is contained in:
parent
9c6ec26c32
commit
1f62f86af5
12 changed files with 161 additions and 33 deletions
|
@ -139,7 +139,7 @@ function display_account_form($UTYPE,$A,$U="",$T="",$S="",
|
||||||
print "<input type='submit' class='button'";
|
print "<input type='submit' class='button'";
|
||||||
print " value='".__("Create")."'> ";
|
print " value='".__("Create")."'> ";
|
||||||
}
|
}
|
||||||
print "<input type='reset' value='".__("Reset")."'>";
|
print "<input type='reset' class='button' value='".__("Reset")."'>";
|
||||||
print "</td>";
|
print "</td>";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,40 @@ $SUPPORTED_LANGS = array( # what languages we have translations for
|
||||||
$QBUG = 1; # toggle query logging to /tmp/aurq.log
|
$QBUG = 1; # toggle query logging to /tmp/aurq.log
|
||||||
$DBUG = 1; # use dbug($msg) to log to /tmp/aurd.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
|
# see if the visitor is already logged in
|
||||||
#
|
#
|
||||||
function check_sid() {
|
function check_sid() {
|
||||||
|
@ -261,15 +295,19 @@ function set_lang() {
|
||||||
#
|
#
|
||||||
function html_header() {
|
function html_header() {
|
||||||
global $_COOKIE;
|
global $_COOKIE;
|
||||||
|
global $LANG;
|
||||||
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
|
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 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"";
|
||||||
print "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"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 "<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/fonts.css'/>\n";
|
||||||
print "<link rel='stylesheet' type='text/css' href='/css/containers.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 "<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 "</head>\n";
|
||||||
print "<body bgcolor='white'>\n";
|
print "<body bgcolor='white'>\n";
|
||||||
print "<table cellspacing='0' ";
|
print "<table cellspacing='0' ";
|
||||||
|
@ -287,7 +325,7 @@ function html_header() {
|
||||||
|
|
||||||
# XXX Can I scale a PNG like this?
|
# 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 " <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 />";
|
||||||
|
|
||||||
|
|
114
web/lib/pkgs.inc
114
web/lib/pkgs.inc
|
@ -35,14 +35,18 @@ function pkgLocations() {
|
||||||
|
|
||||||
# display the search form in a boxSoft style
|
# 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
|
# L: PackageLocations.ID
|
||||||
# C: PackageCategories.ID
|
# C: PackageCategories.ID
|
||||||
# K: Keywords
|
# K: Keywords
|
||||||
# SB: Sort by
|
# SB: Sort by
|
||||||
|
# O: Row offset
|
||||||
# PP: Per page
|
# PP: Per page
|
||||||
$locs = pkgLocations();
|
$locs = pkgLocations();
|
||||||
$cats = pkgCategories();
|
$cats = pkgCategories();
|
||||||
|
$devs = getDevelopers();
|
||||||
|
$tus = getTrustedUsers();
|
||||||
|
$dbh = db_connect();
|
||||||
|
|
||||||
print "<center>\n";
|
print "<center>\n";
|
||||||
print "<table cellspacing='3' class='boxSoft'>\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 "<tr>\n";
|
||||||
print "<td align='right'>\n";
|
print "<td align='right'>\n";
|
||||||
print " <span class='f5'><span class='blue'>".__("Location");
|
print " <span class='f5'><span class='blue'>".__("Location");
|
||||||
print "</span></span><br>\n";
|
print "</span></span><br />\n";
|
||||||
print " <select name='L'>\n";
|
print " <select name='L'>\n";
|
||||||
print " <option value=0> ".__("Any")."\n";
|
print " <option value=0> ".__("Any")."\n";
|
||||||
while (list($id, $loc) = each($locs)) {
|
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 "<td align='right'>\n";
|
||||||
print " <span class='f5'><span class='blue'>".__("Category");
|
print " <span class='f5'><span class='blue'>".__("Category");
|
||||||
print "</span></span><br>\n";
|
print "</span></span><br />\n";
|
||||||
print " <select name='C'>\n";
|
print " <select name='C'>\n";
|
||||||
print " <option value=0> ".__("Any")."\n";
|
print " <option value=0> ".__("Any")."\n";
|
||||||
while (list($id, $cat) = each($cats)) {
|
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 "<td align='right'>\n";
|
||||||
print " <span class='f5'><span class='blue'>".__("Keywords");
|
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 " <input type='text' name='K' size='35'";
|
||||||
print " value='".$K."' maxlength='35'>\n";
|
print " value='".$K."' maxlength='35'>\n";
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
|
|
||||||
print "<td align='right'>\n";
|
print "<td align='right'>\n";
|
||||||
print " <span class='f5'><span class='blue'>".__("Sort by");
|
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 " <select name='SB'>\n";
|
||||||
|
print " <option value=n";
|
||||||
|
$SB == "n" ? print "selected> " : print "> ";
|
||||||
|
print __("Name")."\n";
|
||||||
print " <option value=c";
|
print " <option value=c";
|
||||||
$SB == "c" ? print "selected> " : print "> ";
|
$SB == "c" ? print "selected> " : print "> ";
|
||||||
print __("Category")."\n";
|
print __("Category")."\n";
|
||||||
print " <option value=l";
|
print " <option value=l";
|
||||||
$SB == "l" ? print "selected> " : print "> ";
|
$SB == "l" ? print "selected> " : print "> ";
|
||||||
print __("Location")."\n";
|
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";
|
print " <option value=p";
|
||||||
$SB == "p" ? print "selected> " : print "> ";
|
$SB == "p" ? print "selected> " : print "> ";
|
||||||
print __("Popularity")."\n";
|
print __("Popularity")."\n";
|
||||||
|
@ -119,7 +120,7 @@ function pkg_search_page($L="",$C="",$K="",$SB="",$PP="") {
|
||||||
|
|
||||||
print "<td align='right'>\n";
|
print "<td align='right'>\n";
|
||||||
print " <span class='f5'><span class='blue'>".__("Per page");
|
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 " <select name='PP'>\n";
|
||||||
print " <option value=25";
|
print " <option value=25";
|
||||||
$PP == 25 ? print "selected> 25\n" : print "> 25\n";
|
$PP == 25 ? print "selected> 25\n" : print "> 25\n";
|
||||||
|
@ -138,7 +139,96 @@ function pkg_search_page($L="",$C="",$K="",$SB="",$PP="") {
|
||||||
|
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
print "</table>\n";
|
print "</table>\n";
|
||||||
|
|
||||||
print "</form>\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 " </td>\n";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
print "</table>\n";
|
print "</table>\n";
|
||||||
|
|
Loading…
Add table
Reference in a new issue