added option to order pool list by created date/last updated/title/count
This commit is contained in:
parent
3e240fa78d
commit
b79a042bdc
@ -74,6 +74,8 @@ class Pools extends Extension {
|
||||
|
||||
if ($config->get_int("ext_pools_version") < 2){
|
||||
$database->Execute("ALTER TABLE `pools` ADD UNIQUE INDEX (`title`);");
|
||||
$database->Execute("ALTER TABLE `pools` ADD `lastupdated` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;");
|
||||
|
||||
$config->set_int("ext_pools_version", 2);
|
||||
}
|
||||
}
|
||||
@ -314,13 +316,26 @@ class Pools extends Extension {
|
||||
|
||||
$poolsPerPage = $config->get_int("poolsListsPerPage");
|
||||
|
||||
|
||||
$order_by = "";
|
||||
$order = get_prefixed_cookie("ui-order-pool");
|
||||
if($order == "created" || is_null($order)){
|
||||
$order_by = "ORDER BY p.date DESC";
|
||||
}elseif($order == "updated"){
|
||||
$order_by = "ORDER BY p.lastupdated DESC";
|
||||
}elseif($order == "name"){
|
||||
$order_by = "ORDER BY p.title ASC";
|
||||
}elseif($order == "count"){
|
||||
$order_by = "ORDER BY p.posts DESC";
|
||||
}
|
||||
|
||||
$pools = $database->get_all("
|
||||
SELECT p.id, p.user_id, p.public, p.title, p.description,
|
||||
p.posts, u.name as user_name
|
||||
FROM pools AS p
|
||||
INNER JOIN users AS u
|
||||
ON p.user_id = u.id
|
||||
ORDER BY p.date DESC
|
||||
$order_by
|
||||
LIMIT :l OFFSET :o
|
||||
", array("l"=>$poolsPerPage, "o"=>$pageNumber * $poolsPerPage)
|
||||
);
|
||||
|
10
ext/pools/script.js
Normal file
10
ext/pools/script.js
Normal file
@ -0,0 +1,10 @@
|
||||
$(function() {
|
||||
var order_pool = $.cookie("shm_ui-order-pool");
|
||||
$("#order_pool option[value="+order_pool+"]").attr("selected", true);
|
||||
|
||||
$('#order_pool').change(function(){
|
||||
var val = $("#order_pool option:selected").val();
|
||||
$.cookie("shm_ui-order-pool", val, {path: '/', expires: 365}); //FIXME: This won't play nice if COOKIE_PREFIX is not "shm_".
|
||||
window.location.href = '';
|
||||
});
|
||||
});
|
@ -67,11 +67,21 @@ class PoolsTheme extends Themelet {
|
||||
<br><a href="'.make_link("pool/updated").'">Pool Changes</a>
|
||||
';
|
||||
|
||||
$order_html = '
|
||||
<select id="order_pool">
|
||||
<option value="created">Recently created</option>
|
||||
<option value="updated">Last updated</option>
|
||||
<option value="name">Name</option>
|
||||
<option value="count">Post count</option>
|
||||
</select>
|
||||
';
|
||||
|
||||
$blockTitle = "Pools";
|
||||
$page->set_title(html_escape($blockTitle));
|
||||
$page->set_heading(html_escape($blockTitle));
|
||||
$page->add_block(new Block($blockTitle, $html, "main", 10));
|
||||
$page->add_block(new Block("Navigation", $nav_html, "left", 10));
|
||||
$page->add_block(new Block("Order By", $order_html, "left", 15));
|
||||
|
||||
$this->display_paginator($page, "pool/list", null, $pageNumber, $totalPages);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user