getting closer to printing package search results - also fixed some XHTML stuff

This commit is contained in:
eric 2004-06-24 19:08:35 +00:00
parent 9c6ec26c32
commit 1f62f86af5
12 changed files with 161 additions and 33 deletions

View file

@ -29,7 +29,7 @@ if (isset($_COOKIE["AURSID"])) {
} else { } else {
# a non-privileged user is trying to access the search page # a non-privileged user is trying to access the search page
# #
print __("You are not allowed to access this area.")."<br/>\n"; print __("You are not allowed to access this area.")."<br />\n";
} }
} elseif ($_REQUEST["Action"] == "DisplayAccount") { } elseif ($_REQUEST["Action"] == "DisplayAccount") {
@ -73,7 +73,7 @@ if (isset($_COOKIE["AURSID"])) {
if ($atype == "Trusted User" || $atype == "Developer") { if ($atype == "Trusted User" || $atype == "Developer") {
# display the search page if they're a TU/dev # display the search page if they're a TU/dev
# #
print __("Use this form to search existing accounts.")."<br/>\n"; print __("Use this form to search existing accounts.")."<br />\n";
search_accounts_form(); search_accounts_form();
} else { } else {
@ -96,7 +96,7 @@ if (isset($_COOKIE["AURSID"])) {
# normal user editing themselves. # normal user editing themselves.
# #
print __("Use this form to update your account."); print __("Use this form to update your account.");
print "<br/>"; print "<br />";
print __("Leave the password fields blank to keep your same password."); print __("Leave the password fields blank to keep your same password.");
display_account_form($atype, "UpdateAccount", $row["Username"], display_account_form($atype, "UpdateAccount", $row["Username"],
$row["AccountType"], $row["Suspended"], $row["Email"], $row["AccountType"], $row["Suspended"], $row["Email"],

View file

@ -85,7 +85,7 @@ if (!isset($_COOKIE["AURSID"])) {
# #
print "<form action='/index.php' method='post'>\n"; print "<form action='/index.php' method='post'>\n";
if ($login_error) { if ($login_error) {
print "<span class='error'>" . $login_error . "</span><br/>\n"; print "<span class='error'>" . $login_error . "</span><br />\n";
} }
print "<table border='0' cellpadding='0' cellspacing='0' width='100%'>\n"; print "<table border='0' cellpadding='0' cellspacing='0' width='100%'>\n";
print "<tr>\n"; print "<tr>\n";
@ -97,7 +97,7 @@ if (!isset($_COOKIE["AURSID"])) {
print "<td><input type='password' name='pass' size='30' maxlength='32'></td>"; print "<td><input type='password' name='pass' size='30' maxlength='32'></td>";
print "</tr>\n"; print "</tr>\n";
print "<tr>\n"; print "<tr>\n";
print "<td colspan='2' align='right'>&nbsp;<br/>"; print "<td colspan='2' align='right'>&nbsp;<br />";
print "<input type='submit' class='button'"; print "<input type='submit' class='button'";
print " value='".__("Login")."'></td>"; print " value='".__("Login")."'></td>";
print "</tr>\n"; print "</tr>\n";

View file

@ -15,7 +15,7 @@ if (isset($_COOKIE["AURSID"])) {
} }
html_header(); # print out the HTML header html_header(); # print out the HTML header
print __("You have been successfully logged out.")."<br/>\n"; print __("You have been successfully logged out.")."<br />\n";
html_footer("\$Id$"); html_footer("\$Id$");

View file

@ -9,7 +9,7 @@ html_header(); # print out the HTML header
# Any text you print out to the visitor, use the __() function # Any text you print out to the visitor, use the __() function
# for i18n support. See 'testpo.php' for more details. # for i18n support. See 'testpo.php' for more details.
# #
print __("Under construction...")."<br/>\n"; print __("Under construction...")."<br />\n";
html_footer("\$Id$"); html_footer("\$Id$");

View file

@ -38,7 +38,7 @@ if ($atype && $_REQUEST["Action"] == "Something") {
# #
pkg_search_page(); pkg_search_page();
} }
print __("Under construction...")."<br/>\n"; print __("Under construction...")."<br />\n";
html_footer("\$Id$"); html_footer("\$Id$");

View file

@ -9,7 +9,7 @@ html_header(); # print out the HTML header
# Any text you print out to the visitor, use the __() function # Any text you print out to the visitor, use the __() function
# for i18n support. See 'testpo.php' for more details. # for i18n support. See 'testpo.php' for more details.
# #
print __("Under construction...")."<br/>\n"; print __("Under construction...")."<br />\n";
html_footer("\$Id$"); html_footer("\$Id$");

View file

@ -9,7 +9,7 @@ html_header(); # print out the HTML header
# Any text you print out to the visitor, use the __() function # Any text you print out to the visitor, use the __() function
# for i18n support. See 'testpo.php' for more details. # for i18n support. See 'testpo.php' for more details.
# #
print __("Under construction...")."<br/>\n"; print __("Under construction...")."<br />\n";
html_footer("\$Id$"); html_footer("\$Id$");

View file

@ -9,7 +9,7 @@ html_header(); # print out the HTML header
# Any text you print out to the visitor, use the __() function # Any text you print out to the visitor, use the __() function
# for i18n support. See 'testpo.php' for more details. # for i18n support. See 'testpo.php' for more details.
# #
print __("Hi, this is worth reading!")."<br/>\n"; print __("Hi, this is worth reading!")."<br />\n";
html_footer("\$Id$"); # Use the $Id$ keyword html_footer("\$Id$"); # Use the $Id$ keyword

View file

@ -34,8 +34,8 @@ print __("My current language tag is: '%s'.", array($LANG));
print "</p>\n"; print "</p>\n";
print "<ul>\n"; print "<ul>\n";
print __("Hello, world!")."<br/>\n"; print __("Hello, world!")."<br />\n";
print __("Hello, again!")."<br/>\n"; print __("Hello, again!")."<br />\n";
print "</ul>\n"; print "</ul>\n";
print "</body>\n</html>"; print "</body>\n</html>";

View file

@ -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")."'> &nbsp; "; print " value='".__("Create")."'> &nbsp; ";
} }
print "<input type='reset' value='".__("Reset")."'>"; print "<input type='reset' class='button' value='".__("Reset")."'>";
print "</td>"; print "</td>";
print "</tr>\n"; print "</tr>\n";

View file

@ -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,9 +325,9 @@ 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 />";
# XXX CSS help - a:link, a:visited, etc are defined, but I don't want to # 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? # use the defaults. Is this the way to override them?
@ -333,7 +371,7 @@ function html_header() {
print " </tr>"; print " </tr>";
print " <tr>\n"; print " <tr>\n";
print " <td class='contentDisplay'>\n"; print " <td class='contentDisplay'>\n";
print " &nbsp;<br/>\n"; print " &nbsp;<br />\n";
print "<!-- Start of main content -->\n\n"; print "<!-- Start of main content -->\n\n";
return; return;

View file

@ -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";