From 400fc9487b2efaa580a808f6c3f7dce2e180761b Mon Sep 17 00:00:00 2001 From: swiergot Date: Fri, 2 Sep 2005 16:27:30 +0000 Subject: added sort order field to packages search bar (closes #3060) --- web/lib/pkgfuncs.inc | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) (limited to 'web/lib/pkgfuncs.inc') diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc index 7117c8e6..e277ef5b 100644 --- a/web/lib/pkgfuncs.inc +++ b/web/lib/pkgfuncs.inc @@ -3,7 +3,7 @@ include_once("pkgfuncs_po.inc"); # define variables used during pkgsearch # -$pkgsearch_vars = array("O", "L", "C", "K", "SB", "PP", "do_MyPackages", "do_Orphans"); +$pkgsearch_vars = array("O", "L", "C", "K", "SB", "SO", "PP", "do_MyPackages", "do_Orphans"); # print out the 'return to package details' link @@ -658,7 +658,7 @@ function pkg_search_page($SID="") { print "\n"; print " ".__("Keywords"); print "
\n"; - print " \n"; @@ -696,6 +696,22 @@ function pkg_search_page($SID="") { print " \n"; print "\n"; + print "\n"; + print " ".__("Sort order"); + print "
\n"; + print " \n"; + print "\n"; + print "\n"; print " ".__("Per page"); print "
\n"; @@ -800,24 +816,25 @@ function pkg_search_page($SID="") { $q.= "MaintainerUID = 0) "; } } + $order = $_REQUEST["SO"] == 'd' ? 'DESC' : 'ASC'; switch ($_REQUEST["SB"]) { case 'c': - $q.= "ORDER BY CategoryID DESC, Name ASC, LocationID ASC "; + $q.= "ORDER BY CategoryID ".$order.", Name ASC, LocationID ASC "; break; case 'l': - $q.= "ORDER BY LocationID ASC, Name ASC, CategoryID DESC "; + $q.= "ORDER BY LocationID ".$order.", Name ASC, CategoryID DESC "; break; case 'v': - $q.= "ORDER BY NumVotes DESC, Name ASC, CategoryID DESC "; + $q.= "ORDER BY NumVotes ".$order.", Name ASC, CategoryID DESC "; break; case 'm': - $q.= "ORDER BY Username ASC, Name ASC, LocationID ASC "; + $q.= "ORDER BY Username ".$order.", Name ASC, LocationID ASC "; break; case 'a': - $q.= "ORDER BY GREATEST(SubmittedTS,ModifiedTS) ASC, Name ASC, LocationID ASC "; + $q.= "ORDER BY GREATEST(SubmittedTS,ModifiedTS) ".$order.", Name ASC, LocationID ASC "; break; default: - $q.= "ORDER BY Name ASC, LocationID ASC, CategoryID DESC "; + $q.= "ORDER BY Name ".$order.", LocationID ASC, CategoryID DESC "; break; } $qnext = $q."LIMIT ".($O+$PP).", ".$PP; //next page's worth -- cgit v1.2.3-24-g4f1b