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/html/account.php | 6 +-- web/html/index.php | 4 +- web/html/logout.php | 2 +- web/html/pkgmgmnt.php | 2 +- web/html/pkgsearch.php | 2 +- web/html/pkgsubmit.php | 2 +- web/html/pkgvote.php | 2 +- web/html/template.php | 2 +- web/html/testpo.php | 4 +- web/lib/acctfuncs.inc | 2 +- web/lib/aur.inc | 52 +++++++++++++++++++--- web/lib/pkgs.inc | 114 +++++++++++++++++++++++++++++++++++++++++++------ 12 files changed, 161 insertions(+), 33 deletions(-) (limited to 'web') diff --git a/web/html/account.php b/web/html/account.php index a00a5e5..0975ab7 100644 --- a/web/html/account.php +++ b/web/html/account.php @@ -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.")."
\n"; + print __("You are not allowed to access this area.")."
\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.")."
\n"; + print __("Use this form to search existing accounts.")."
\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 "
"; + print "
"; print __("Leave the password fields blank to keep your same password."); display_account_form($atype, "UpdateAccount", $row["Username"], $row["AccountType"], $row["Suspended"], $row["Email"], diff --git a/web/html/index.php b/web/html/index.php index 09e87cc..67ff657 100644 --- a/web/html/index.php +++ b/web/html/index.php @@ -85,7 +85,7 @@ if (!isset($_COOKIE["AURSID"])) { # print "
\n"; if ($login_error) { - print "" . $login_error . "
\n"; + print "" . $login_error . "
\n"; } print "\n"; print "\n"; @@ -97,7 +97,7 @@ if (!isset($_COOKIE["AURSID"])) { print ""; print "\n"; print "\n"; - print ""; print "\n"; diff --git a/web/html/logout.php b/web/html/logout.php index a81c645..a25da7c 100644 --- a/web/html/logout.php +++ b/web/html/logout.php @@ -15,7 +15,7 @@ if (isset($_COOKIE["AURSID"])) { } html_header(); # print out the HTML header -print __("You have been successfully logged out.")."
\n"; +print __("You have been successfully logged out.")."
\n"; html_footer("\$Id$"); diff --git a/web/html/pkgmgmnt.php b/web/html/pkgmgmnt.php index b1768db..5544016 100644 --- a/web/html/pkgmgmnt.php +++ b/web/html/pkgmgmnt.php @@ -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...")."
\n"; +print __("Under construction...")."
\n"; html_footer("\$Id$"); diff --git a/web/html/pkgsearch.php b/web/html/pkgsearch.php index b47ee95..6b23265 100644 --- a/web/html/pkgsearch.php +++ b/web/html/pkgsearch.php @@ -38,7 +38,7 @@ if ($atype && $_REQUEST["Action"] == "Something") { # pkg_search_page(); } -print __("Under construction...")."
\n"; +print __("Under construction...")."
\n"; html_footer("\$Id$"); diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php index c9465a1..60b6dc5 100644 --- a/web/html/pkgsubmit.php +++ b/web/html/pkgsubmit.php @@ -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...")."
\n"; +print __("Under construction...")."
\n"; html_footer("\$Id$"); diff --git a/web/html/pkgvote.php b/web/html/pkgvote.php index 594ec16..eed4a35 100644 --- a/web/html/pkgvote.php +++ b/web/html/pkgvote.php @@ -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...")."
\n"; +print __("Under construction...")."
\n"; html_footer("\$Id$"); diff --git a/web/html/template.php b/web/html/template.php index 9ae001e..2a870ec 100644 --- a/web/html/template.php +++ b/web/html/template.php @@ -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!")."
\n"; +print __("Hi, this is worth reading!")."
\n"; html_footer("\$Id$"); # Use the $Id$ keyword diff --git a/web/html/testpo.php b/web/html/testpo.php index 7f2f1d9..64c4b3e 100644 --- a/web/html/testpo.php +++ b/web/html/testpo.php @@ -34,8 +34,8 @@ print __("My current language tag is: '%s'.", array($LANG)); print "

\n"; print "\n"; print "\n"; 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 "   "; } - print ""; + print ""; print ""; print "\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 "\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 "
 
"; + print "
 
"; 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 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 "
\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-70-g09d2