added sort order field to packages search bar (closes #3060)

This commit is contained in:
swiergot 2005-09-02 16:27:30 +00:00
parent cb63efbfc5
commit 400fc9487b
3 changed files with 34 additions and 8 deletions

View file

@ -79,6 +79,12 @@ $_t["en"]["Manage"] = "Manage";
$_t["en"]["Sort by"] = "Sort by"; $_t["en"]["Sort by"] = "Sort by";
$_t["en"]["Sort order"] = "Sort order";
$_t["en"]["Ascending"] = "Ascending";
$_t["en"]["Descending"] = "Descending";
$_t["en"]["Actions"] = "Actions"; $_t["en"]["Actions"] = "Actions";
$_t["en"]["Sources"] = "Sources"; $_t["en"]["Sources"] = "Sources";

View file

@ -21,6 +21,9 @@ $_t["pl"]["Name"] = "Nazwa";
$_t["pl"]["Per page"] = "Na stronie"; $_t["pl"]["Per page"] = "Na stronie";
$_t["pl"]["Popularity"] = "Popularność"; $_t["pl"]["Popularity"] = "Popularność";
$_t["pl"]["Sort by"] = "Sortuj według"; $_t["pl"]["Sort by"] = "Sortuj według";
$_t["pl"]["Sort order"] = "Porządek";
$_t["pl"]["Ascending"] = "Rosnąco";
$_t["pl"]["Descending"] = "Malejąco";
$_t["pl"]["Search Criteria"] = "Kryteria wyszukiwania"; $_t["pl"]["Search Criteria"] = "Kryteria wyszukiwania";
$_t["pl"]["Location"] = "Lokacja"; $_t["pl"]["Location"] = "Lokacja";
$_t["pl"]["Keywords"] = "Słowa kluczowe"; $_t["pl"]["Keywords"] = "Słowa kluczowe";

View file

@ -3,7 +3,7 @@ include_once("pkgfuncs_po.inc");
# define variables used during pkgsearch # 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 # print out the 'return to package details' link
@ -658,7 +658,7 @@ function pkg_search_page($SID="") {
print "<td align='right'>\n"; print "<td align='right'>\n";
print " <span class='f5'><span class='blue'>".__("Keywords"); 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 " <input type='text' name='K' size='20'";
$K = str_replace("\"", "", $_REQUEST["K"]); # TODO better testing for $K = str_replace("\"", "", $_REQUEST["K"]); # TODO better testing for
# SQL trickery... # SQL trickery...
print " value=\"".stripslashes($K)."\" maxlength='35'>\n"; print " value=\"".stripslashes($K)."\" maxlength='35'>\n";
@ -696,6 +696,22 @@ function pkg_search_page($SID="") {
print " </select>\n"; print " </select>\n";
print "</td>\n"; print "</td>\n";
print "<td align='right'>\n";
print " <span class='f5'><span class='blue'>".__("Sort order");
print "</span></span><br />\n";
print " <select name='SO'>\n";
print " <option value=a";
$_REQUEST["SO"] == "a" ? print " selected> " : print "> ";
print __("Ascending")."</option>\n";
print " <option value=d";
$_REQUEST["SO"] == "d" ? print " selected> " : print "> ";
print __("Descending")."</option>\n";
print " </select>\n";
print "</td>\n";
print "<td align='right'>\n"; print "<td align='right'>\n";
print " <span class='f5'><span class='blue'>".__("Per page"); print " <span class='f5'><span class='blue'>".__("Per page");
print "</span></span><br />\n"; print "</span></span><br />\n";
@ -800,24 +816,25 @@ function pkg_search_page($SID="") {
$q.= "MaintainerUID = 0) "; $q.= "MaintainerUID = 0) ";
} }
} }
$order = $_REQUEST["SO"] == 'd' ? 'DESC' : 'ASC';
switch ($_REQUEST["SB"]) { switch ($_REQUEST["SB"]) {
case 'c': case 'c':
$q.= "ORDER BY CategoryID DESC, Name ASC, LocationID ASC "; $q.= "ORDER BY CategoryID ".$order.", Name ASC, LocationID ASC ";
break; break;
case 'l': case 'l':
$q.= "ORDER BY LocationID ASC, Name ASC, CategoryID DESC "; $q.= "ORDER BY LocationID ".$order.", Name ASC, CategoryID DESC ";
break; break;
case 'v': case 'v':
$q.= "ORDER BY NumVotes DESC, Name ASC, CategoryID DESC "; $q.= "ORDER BY NumVotes ".$order.", Name ASC, CategoryID DESC ";
break; break;
case 'm': case 'm':
$q.= "ORDER BY Username ASC, Name ASC, LocationID ASC "; $q.= "ORDER BY Username ".$order.", Name ASC, LocationID ASC ";
break; break;
case 'a': 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; break;
default: default:
$q.= "ORDER BY Name ASC, LocationID ASC, CategoryID DESC "; $q.= "ORDER BY Name ".$order.", LocationID ASC, CategoryID DESC ";
break; break;
} }
$qnext = $q."LIMIT ".($O+$PP).", ".$PP; //next page's worth $qnext = $q."LIMIT ".($O+$PP).", ".$PP; //next page's worth