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
|
@ -29,7 +29,7 @@ if (isset($_COOKIE["AURSID"])) {
|
|||
} else {
|
||||
# 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") {
|
||||
|
@ -73,7 +73,7 @@ if (isset($_COOKIE["AURSID"])) {
|
|||
if ($atype == "Trusted User" || $atype == "Developer") {
|
||||
# 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();
|
||||
|
||||
} else {
|
||||
|
@ -96,7 +96,7 @@ if (isset($_COOKIE["AURSID"])) {
|
|||
# normal user editing themselves.
|
||||
#
|
||||
print __("Use this form to update your account.");
|
||||
print "<br/>";
|
||||
print "<br />";
|
||||
print __("Leave the password fields blank to keep your same password.");
|
||||
display_account_form($atype, "UpdateAccount", $row["Username"],
|
||||
$row["AccountType"], $row["Suspended"], $row["Email"],
|
||||
|
|
|
@ -85,7 +85,7 @@ if (!isset($_COOKIE["AURSID"])) {
|
|||
#
|
||||
print "<form action='/index.php' method='post'>\n";
|
||||
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 "<tr>\n";
|
||||
|
@ -97,7 +97,7 @@ if (!isset($_COOKIE["AURSID"])) {
|
|||
print "<td><input type='password' name='pass' size='30' maxlength='32'></td>";
|
||||
print "</tr>\n";
|
||||
print "<tr>\n";
|
||||
print "<td colspan='2' align='right'> <br/>";
|
||||
print "<td colspan='2' align='right'> <br />";
|
||||
print "<input type='submit' class='button'";
|
||||
print " value='".__("Login")."'></td>";
|
||||
print "</tr>\n";
|
||||
|
|
|
@ -15,7 +15,7 @@ if (isset($_COOKIE["AURSID"])) {
|
|||
}
|
||||
|
||||
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$");
|
||||
|
|
|
@ -9,7 +9,7 @@ html_header(); # print out the HTML header
|
|||
# Any text you print out to the visitor, use the __() function
|
||||
# for i18n support. See 'testpo.php' for more details.
|
||||
#
|
||||
print __("Under construction...")."<br/>\n";
|
||||
print __("Under construction...")."<br />\n";
|
||||
|
||||
|
||||
html_footer("\$Id$");
|
||||
|
|
|
@ -38,7 +38,7 @@ if ($atype && $_REQUEST["Action"] == "Something") {
|
|||
#
|
||||
pkg_search_page();
|
||||
}
|
||||
print __("Under construction...")."<br/>\n";
|
||||
print __("Under construction...")."<br />\n";
|
||||
|
||||
|
||||
html_footer("\$Id$");
|
||||
|
|
|
@ -9,7 +9,7 @@ html_header(); # print out the HTML header
|
|||
# Any text you print out to the visitor, use the __() function
|
||||
# for i18n support. See 'testpo.php' for more details.
|
||||
#
|
||||
print __("Under construction...")."<br/>\n";
|
||||
print __("Under construction...")."<br />\n";
|
||||
|
||||
|
||||
html_footer("\$Id$");
|
||||
|
|
|
@ -9,7 +9,7 @@ html_header(); # print out the HTML header
|
|||
# Any text you print out to the visitor, use the __() function
|
||||
# for i18n support. See 'testpo.php' for more details.
|
||||
#
|
||||
print __("Under construction...")."<br/>\n";
|
||||
print __("Under construction...")."<br />\n";
|
||||
|
||||
|
||||
html_footer("\$Id$");
|
||||
|
|
|
@ -9,7 +9,7 @@ html_header(); # print out the HTML header
|
|||
# Any text you print out to the visitor, use the __() function
|
||||
# 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
|
||||
|
|
|
@ -34,8 +34,8 @@ print __("My current language tag is: '%s'.", array($LANG));
|
|||
print "</p>\n";
|
||||
|
||||
print "<ul>\n";
|
||||
print __("Hello, world!")."<br/>\n";
|
||||
print __("Hello, again!")."<br/>\n";
|
||||
print __("Hello, world!")."<br />\n";
|
||||
print __("Hello, again!")."<br />\n";
|
||||
print "</ul>\n";
|
||||
print "</body>\n</html>";
|
||||
|
||||
|
|
|
@ -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";
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
114
web/lib/pkgs.inc
114
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,7 +139,96 @@ 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";
|
||||
|
|
Loading…
Add table
Reference in a new issue