From b4a62c4915cc969e53abf803cd57d9d994eaf48c Mon Sep 17 00:00:00 2001 From: Callan Barrett Date: Mon, 22 Dec 2008 01:49:35 +0900 Subject: Move package search results to a template Logic is separated from html as much as possible, all html in a template Signed-off-by: Callan Barrett Signed-off-by: Loui Chang --- web/lib/pkgfuncs.inc | 227 ++++----------------------------------------------- 1 file changed, 17 insertions(+), 210 deletions(-) (limited to 'web/lib') diff --git a/web/lib/pkgfuncs.inc b/web/lib/pkgfuncs.inc index dfda0e8..740d786 100644 --- a/web/lib/pkgfuncs.inc +++ b/web/lib/pkgfuncs.inc @@ -767,219 +767,26 @@ function pkg_search_page($SID="") { $result = db_query($q, $dbh); $total = mysql_result(db_query('SELECT FOUND_ROWS() AS Total', $dbh), 0); - print "
\n"; - print "
\n"; - print "\n"; - print "\n"; - print " \n"; - print "\n"; - print "\n"; - print " \n"; - print "\n"; - print "
\n"; - print " ".__("Package Listing")."\n"; - print "
\n"; - print "\n"; - - if (!$result) { - print "
"; - print __("Error retrieving package list."); - print "
"; - } elseif ($total == 0) { - print "
"; - print __("No packages matched your search criteria."); - print "
"; - } else { - // print out package search results - // - - // SO_next used to change sort order on header click - if ($_REQUEST["SO"] == "d"){ - $SO_next="a"; - $SO = 'd'; - } else { - $SO_next="d"; - $SO = 'a'; - } - print "\n"; - if ($SID) { - print " \n"; - } - print " \n"; - print " \n"; - print " \n"; - print " \n"; - if ($SID) { - print " \n"; - } - if ($SID) { - 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"; - if ($SID) { - if ($row["OutOfDate"]) { - $c = "outofdate"; - } - print " \n"; - } - print " \n"; - print " \n"; - print " \n"; - print " \n"; - if ($SID) { - print " \n"; - } else { - print " \n"; - } - print " \n"; - } else { - print " \n"; - } - } - print " \n"; - print " \n"; - print "\n"; - - } - print "
 "; - print "".__("Location").""; - print ""; - print "".__("Category").""; - print ""; - print "".__("Name").""; - print ""; - print "".__("Votes").""; - print "".__("Voted")."".__("Notify")."".__("Description").""; - print ""; - print "".__("Maintainer").""; - print "
"; - print ""; - if ($row["OutOfDate"]) { - print ""; - } - print ""; - print $row["Location"].""; - print $row["Category"].""; - $url = ""; - $url.=""; - $url.=$row["Name"]; - $url.= " ".$row["Version"].""; - print $url.""; - print "   ".$row["NumVotes"].""; - if (isset($row["Voted"])) { - print "  ".__("Yes").""; - if (isset($row["Notify"])) { - print "  ".__("Yes").""; - print $row["Description"].""; - - if (isset($row["Maintainer"])) { - print "".$row['Maintainer'].""; - } else { - print ""; - print __("orphan"); - print ""; - } - print "
\n"; - print "
\n"; - - if ($SID) { - // The 'Actions' box - // - print "
"; - print ""; - print ""; - print "
"; - } - - print "\n"; - print "\n"; - print " \n"; - print "\n"; - print "
\n"; - print " \n"; - print " \n"; - - // figure out the results to use - $first = $O + 1; + if ($result && $total > 0) { + if ($_REQUEST["SO"] == "d"){ + $SO_next="a"; + $SO = 'd'; + } else { + $SO_next="d"; + $SO = 'a'; + } + } - if (($PP+$O) > $total) { - $last = $total; - } else { - $last = $PP + $O; - } + // figure out the results to use + $first = $O + 1; - // print number of results - // ok this styling sucks - // patches welcome! - print ""; - - // first print the legend - print " \n"; - print " "; - - - // now print the forward and back buttons on the bottom - // LEFT - print " "; - print " "; - // RIGHT - print " \n"; - print " \n"; + if (($PP+$O) > $total) { + $last = $total; + } else { + $last = $PP + $O; } - print "
"; - print __("Showing results %s - %s of %s", array($first, $last, $total)); - print "
"; - print " \n"; - if ($SID) { - print ' '.__("Out of Date").' '."    "; - } - print "
"; - if (($O-$PP) >= 0) { - print "" . __("Less") . ""; - } else if ($O<$PP && $O>0) { - print "" . __("Less") . ""; - } - print " "; - if ($total - $PP - $O > 0) { - print "" . - __("More") . ""; - } - print "
\n"; - print "
\n"; - print "
\n"; - print "
\n"; + + include('pkg_search_results.php'); return; } -- cgit v1.2.3-70-g09d2