Added dsa's sorting improvement patch (closes #3370, #4091, #4097 and #4098).

This commit is contained in:
swiergot 2006-08-22 13:58:36 +00:00
parent d0da4199ae
commit 18dc7c783e
3 changed files with 105 additions and 33 deletions

View file

@ -141,4 +141,10 @@ $_t["en"]["Search by"] = "Search by";
$_t["en"]["Submitter"] = "Submitter"; $_t["en"]["Submitter"] = "Submitter";
$_t["en"]["All"] = "All";
$_t["en"]["Unsafe"] = "Unsafe";
$_t["en"]["Status"] = "Status";
?> ?>

View file

@ -81,7 +81,7 @@ $_t["pt"]["Manage"] = "Gerenciar";
$_t["pt"]["Sort by"] = "Ordenar por"; $_t["pt"]["Sort by"] = "Ordenar por";
$_t["pt"]["Sort order"] = "Ordem de Ordenação"; $_t["pt"]["Sort order"] = "Ordem";
$_t["pt"]["Ascending"] = "Ascendente"; $_t["pt"]["Ascending"] = "Ascendente";
@ -139,4 +139,12 @@ $_t["pt"]["Last Updated"] = "Últimos Pacotes Atualizados";
$_t["pt"]["Search by"] = "Pesquisar por"; $_t["pt"]["Search by"] = "Pesquisar por";
?> $_t["pt"]["Submitter"] = "Colaborador";
$_t["pt"]["All"] = "Todos";
$_t["pt"]["Unsafe"] = "Não Seguro";
$_t["pt"]["Status"] = "Status";
?>

View file

@ -707,26 +707,60 @@ function pkg_search_page($SID="") {
print "</td>\n"; print "</td>\n";
print "<td align='right'>\n"; print "<td align='right'>\n";
print " <span class='f5'><span class='blue'>".__("Search by"); print " <span class='f5'><span class='blue'>".__("Search by");
print "</span></span><br />\n"; print "</span></span><br />\n";
print " <select name='SeB'>\n"; print " <select name='SeB'>\n";
# by name/description # by name/description
print " <option value=nd"; print " <option value=nd";
$_REQUEST["SeB"] == "nd" ? print " selected> " : print "> "; $_REQUEST["SeB"] == "nd" ? print " selected> " : print "> ";
print __("Name")."</option>\n"; print __("Name")."</option>\n";
# by maintainer # by maintainer
print " <option value=m"; print " <option value=m";
$_REQUEST["SeB"] == "m" ? print " selected> " : print "> "; $_REQUEST["SeB"] == "m" ? print " selected> " : print "> ";
print __("Maintainer")."</option>\n"; print __("Maintainer")."</option>\n";
print " <option value=s"; print " <option value=s";
$_REQUEST["SeB"] == "s" ? print " selected> " : print "> "; $_REQUEST["SeB"] == "s" ? print " selected> " : print "> ";
print __("Submitter")."</option>\n"; print __("Submitter")."</option>\n";
print " </select>\n"; print " </select>\n";
print "</td>\n"; print "</td>\n";
/* Status Safe-Unsafe */
# Added the code below to handle the safe package flag.
# So we can search for then for 'all' packages, 'safe'
# packages and 'unsafe' packages.
# Added by: dsa <dsandrade@gmail.com> "Happily breaking the lang files ;oD" (Joking)
print "<td align='right'>\n";
print " <span class='f5'><span class='blue'>".__("Status");
print "</span></span><br />\n";
print " <select name='PaS'>\n";
# Flagged Safe
print " <option value=all";
$_REQUEST["PaS"] == "all" ? print " selected> " : print "> ";
print __("All")."</option>\n";
# Flagged Safe
print " <option value=fs";
$_REQUEST["PaS"] == "fs" ? print " selected> " : print "> ";
print __("Safe")."</option>\n";
# Unflagged Safe
print " <option value=us";
$_REQUEST["PaS"] == "us" ? print " selected> " : print "> ";
print __("Unsafe")."</option>\n";
print " </select>\n";
print "</td>\n";
/* End of Package Status */
/* print "<td align='right'>\n"; /* Sort by */
print "<td align='right'>\n";
print " <span class='f5'><span class='blue'>".__("Sort by"); print " <span class='f5'><span class='blue'>".__("Sort by");
print "</span></span><br />\n"; print "</span></span><br />\n";
print " <select name='SB'>\n"; print " <select name='SB'>\n";
@ -773,7 +807,9 @@ function pkg_search_page($SID="") {
print " </select>\n"; print " </select>\n";
print "</td>\n"; print "</td>\n";
*/
/* End of Sort by */
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";
@ -850,7 +886,7 @@ function pkg_search_page($SID="") {
} else { } else {
$q.= "AND Username = '".mysql_escape_string($K)."' "; $q.= "AND Username = '".mysql_escape_string($K)."' ";
} }
} elseif ($_REQUEST["SeB"] == "s") { } elseif ($_REQUEST["SeB"] == "s") {
if (!$has_where) { if (!$has_where) {
$q.= "WHERE SubmitterUID = ".uid_from_username($K)." "; $q.= "WHERE SubmitterUID = ".uid_from_username($K)." ";
$has_where = 1; $has_where = 1;
@ -869,7 +905,8 @@ function pkg_search_page($SID="") {
} }
} }
} }
if ($_REQUEST["do_MyPackages"] && $SID) {
if ($_REQUEST["do_MyPackages"] && $SID) {
# list packages that the user is a AUR Maintainer of, or if it the # list packages that the user is a AUR Maintainer of, or if it the
# vistior is a registered user, if they are the Maintainer. # vistior is a registered user, if they are the Maintainer.
# #
@ -896,8 +933,34 @@ function pkg_search_page($SID="") {
$q.= "MaintainerUID = 0) "; $q.= "MaintainerUID = 0) ";
} }
} }
$order = $_REQUEST["SO"] == 'd' ? 'DESC' : 'ASC';
switch ($_REQUEST["SB"]) { # Added the code below to handle the safe package flag.
# So we can search for then for 'all' packages, 'safe'
# packages and 'unsafe' packages.
# Added by: dsa <dsandrade@gmail.com>
if ($_REQUEST["PaS"] <> "all") {
# Flagged Safe
if ($_REQUEST["PaS"] == "fs")
if (!$has_where) {
$q.= "WHERE Safe = 1 ";
$has_where = 1;
} else {
$q.= "AND Safe = 1 ";
}
# Unflagged Safe
if ($_REQUEST["PaS"] == "us")
if (!$has_where) {
$q.= "WHERE Safe = 0 ";
$has_where = 1;
} else {
$q.= "AND Safe = 0 ";
}
}
$order = $_REQUEST["SO"] == 'd' ? 'DESC' : 'ASC';
switch ($_REQUEST["SB"]) {
case 'c': case 'c':
$q.= "ORDER BY CategoryID ".$order.", Name ASC, LocationID ASC "; $q.= "ORDER BY CategoryID ".$order.", Name ASC, LocationID ASC ";
break; break;
@ -920,7 +983,7 @@ function pkg_search_page($SID="") {
$qnext = $q."LIMIT ".($O+$PP).", ".$PP; //next page's worth $qnext = $q."LIMIT ".($O+$PP).", ".$PP; //next page's worth
$q.= "LIMIT ".$O.", ".$PP; $q.= "LIMIT ".$O.", ".$PP;
print "<!-- Query: ".$q." -->\n"; print "<!-- Query: ".$q." -->\n";
$result = db_query($q, $dbh); $result = db_query($q, $dbh);
if (!$result) { if (!$result) {
print __("Error retrieving package list."); print __("Error retrieving package list.");
@ -1033,13 +1096,7 @@ function pkg_search_page($SID="") {
# } # }
print "</tr>\n"; print "</tr>\n";
# Solve the sorting problem, so we can force the for ($i=0; $row = mysql_fetch_assoc($result); $i++) {
# passage of the sorting params to the next pages.
# Added by: dsa <dsandrade@gmail.com>
print "<input type='hidden' name='SB' value='".$_REQUEST['SB']."' >";
print "<input type='hidden' name='SO' value='".$_REQUEST['SO']."' >";
for ($i=0; $row = mysql_fetch_assoc($result); $i++) {
(($i % 2) == 0) ? $c = "data1" : $c = "data2"; (($i % 2) == 0) ? $c = "data1" : $c = "data2";
print "<tr>\n"; print "<tr>\n";
if ($SID) { if ($SID) {
@ -1079,6 +1136,7 @@ function pkg_search_page($SID="") {
} }
reset($pkgsearch_vars); reset($pkgsearch_vars);
$url.= "'>"; $url.= "'>";
if ($row["Safe"] == 1 || $locs[$row["LocationID"]] == "community") { if ($row["Safe"] == 1 || $locs[$row["LocationID"]] == "community") {
$url.="<span class='green'>"; $url.="<span class='green'>";
} }