mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Add sorting by "Voted" and "Notify" fields
Signed-off-by: Loui Chang <louipc.ist@gmail.com>
This commit is contained in:
parent
290c436046
commit
b18fb08ddc
3 changed files with 27 additions and 9 deletions
|
@ -515,32 +515,46 @@ function pkg_search_page($SID="") {
|
||||||
|
|
||||||
$order = $_GET["SO"] == 'd' ? 'DESC' : 'ASC';
|
$order = $_GET["SO"] == 'd' ? 'DESC' : 'ASC';
|
||||||
|
|
||||||
|
$q_sort = "ORDER BY Name ".$order.", LocationID ASC, CategoryID DESC ";
|
||||||
switch ($_GET["SB"]) {
|
switch ($_GET["SB"]) {
|
||||||
case 'c':
|
case 'c':
|
||||||
$q.= "ORDER BY CategoryID ".$order.", Name ASC, LocationID ASC ";
|
$q_sort = "ORDER BY CategoryID ".$order.", Name ASC, LocationID ASC ";
|
||||||
$_GET["SB"] = 'c';
|
$_GET["SB"] = 'c';
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
$q.= "ORDER BY LocationID ".$order.", Name ASC, CategoryID DESC ";
|
$q_sort = "ORDER BY LocationID ".$order.", Name ASC, CategoryID DESC ";
|
||||||
$_GET["SB"] = 'l';
|
$_GET["SB"] = 'l';
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
$q.= "ORDER BY NumVotes ".$order.", Name ASC, CategoryID DESC ";
|
$q_sort = "ORDER BY NumVotes ".$order.", Name ASC, CategoryID DESC ";
|
||||||
$_GET["SB"] = 'v';
|
$_GET["SB"] = 'v';
|
||||||
break;
|
break;
|
||||||
|
case 'w':
|
||||||
|
if ($SID) {
|
||||||
|
$q_sort = "ORDER BY Voted ".$order.", Name ASC, CategoryID DESC ";
|
||||||
|
}
|
||||||
|
$_GET["SB"] = 'w';
|
||||||
|
break;
|
||||||
|
case 'o':
|
||||||
|
if ($SID) {
|
||||||
|
$q_sort = "ORDER BY Notify ".$order.", Name ASC, CategoryID DESC ";
|
||||||
|
}
|
||||||
|
$_GET["SB"] = 'o';
|
||||||
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
$q.= "ORDER BY Maintainer ".$order.", Name ASC, LocationID ASC ";
|
$q_sort = "ORDER BY Maintainer ".$order.", Name ASC, LocationID ASC ";
|
||||||
$_GET["SB"] = 'm';
|
$_GET["SB"] = 'm';
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
$q.= "ORDER BY GREATEST(SubmittedTS,ModifiedTS) ".$order.", Name ASC, LocationID ASC ";
|
$q_sort = "ORDER BY GREATEST(SubmittedTS,ModifiedTS) ".$order.", Name ASC, LocationID ASC ";
|
||||||
$_GET["SB"] = 'a';
|
$_GET["SB"] = 'a';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$q.= "ORDER BY Name ".$order.", LocationID ASC, CategoryID DESC ";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$q.= $q_sort;
|
||||||
|
|
||||||
$q.= "LIMIT ".$_GET["O"].", ".$_GET["PP"];
|
$q.= "LIMIT ".$_GET["O"].", ".$_GET["PP"];
|
||||||
|
|
||||||
$result = db_query($q, $dbh);
|
$result = db_query($q, $dbh);
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
<label><?php print __("Sort by"); ?></label>
|
<label><?php print __("Sort by"); ?></label>
|
||||||
<select name='SB'>
|
<select name='SB'>
|
||||||
<?php
|
<?php
|
||||||
$sortby = array('n' => 'Name', 'c' => 'Category', 'l' => 'Location', 'v' => 'Votes', 'm' => 'Maintainer', 'a' => 'Age');
|
$sortby = array('n' => 'Name', 'c' => 'Category', 'l' => 'Location', 'v' => 'Votes', 'w' => 'Voted', 'o' => 'Notify', 'm' => 'Maintainer', 'a' => 'Age');
|
||||||
foreach ($sortby as $k => $v):
|
foreach ($sortby as $k => $v):
|
||||||
if ($_REQUEST['SB'] == $k):
|
if ($_REQUEST['SB'] == $k):
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -29,8 +29,12 @@
|
||||||
</span></th>
|
</span></th>
|
||||||
|
|
||||||
<?php if ($SID): ?>
|
<?php if ($SID): ?>
|
||||||
<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("Voted") ?></span></th>
|
<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'>
|
||||||
<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("Notify") ?></span></th>
|
<a href='?<?php print mkurl('SB=w&SO=' . $SO_next) ?>'><?php print __("Voted") ?></a>
|
||||||
|
</span></th>
|
||||||
|
<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'>
|
||||||
|
<a href='?<?php print mkurl('SB=o&SO=' . $SO_next) ?>'><?php print __("Notify") ?></a>
|
||||||
|
</span></th>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("Description") ?></span></th>
|
<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'><?php print __("Description") ?></span></th>
|
||||||
<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'>
|
<th style='border-bottom: #666 1px solid; vertical-align: bottom'><span class='f2'>
|
||||||
|
|
Loading…
Add table
Reference in a new issue