From 14ecbf5fd577995a93f4437ce5d60069fd7cc771 Mon Sep 17 00:00:00 2001 From: Callan Barrett Date: Tue, 15 Jan 2008 18:59:48 +0900 Subject: Add search result information This adds search results numbers to the bottom of pages when searching based on tardo's repository, ex. Showing results 1 - 42 of 42 Signed-off-by: Callan Barrett --- web/lang/en/pkgfuncs_po.inc | 2 ++ web/lib/pkgfuncs.inc | 66 ++++++++++++++++++++++++--------------------- 2 files changed, 38 insertions(+), 30 deletions(-) diff --git a/web/lang/en/pkgfuncs_po.inc b/web/lang/en/pkgfuncs_po.inc index 2f6a62e..3e7d318 100644 --- a/web/lang/en/pkgfuncs_po.inc +++ b/web/lang/en/pkgfuncs_po.inc @@ -159,4 +159,6 @@ $_t["en"]["This package has been flagged out of date."] = "This package has been $_t["en"]["Toggle Notify"] = "Toggle Notify"; +$_t["en"]["Showing results %s - %s of %s"] = "Showing results %s - %s of %s"; + ?> diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc index a6086f8..713eb6b 100644 --- a/web/lib/pkgfuncs.inc +++ b/web/lib/pkgfuncs.inc @@ -712,24 +712,24 @@ function pkg_search_page($SID="") { print "\n"; print "\n"; - print " ".__("Search by"); - print "
\n"; - - print " \n"; - print "\n"; + print " ".__("Search by"); + print "
\n"; + + print " \n"; + print "\n"; print "\n"; print " ".__("Per page"); @@ -754,17 +754,6 @@ function pkg_search_page($SID="") { print " value='".__("Go")."'>\n"; print "\n"; - /* - * Commented the My Packages button because there is no need for it - * cause we already have a link. - * - if ($SID) { - print " \n"; - print " \n"; - print "\n"; - }*/ - print " \n"; print " \n"; @@ -884,7 +873,9 @@ function pkg_search_page($SID="") { $q.= "ORDER BY Name ".$order.", LocationID ASC, CategoryID DESC "; break; } - + + $allresults = mysql_num_rows(db_query($q, $dbh)); + $qnext = $q."LIMIT ".($O+$PP).", ".$PP; //next page's worth $q.= "LIMIT ".$O.", ".$PP; @@ -1116,6 +1107,21 @@ function pkg_search_page($SID="") { print " \n"; print " \n"; + # figure out the results to use + $first = $O + 1; + + if (($PP+$O) > $allresults) { + $last = $allresults; + } else { + $last = $PP + $O; + } + + # print number of results + # ok this styling sucks + print ""; + # first print the legend print "
"; + print __("Showing results %s - %s of %s", array($first, $last, $allresults)); + print "
"; print " \n"; -- cgit v1.2.3-70-g09d2