arrowkey navigation on post/list now supports tags

This commit is contained in:
DrudexSoftware 2013-02-23 23:26:08 +01:00
parent 13d8b0831e
commit 069b7ee9ea

View File

@ -51,21 +51,24 @@ class arrowkey_navigation extends Extension {
private function get_list_pageinfo($event) { private function get_list_pageinfo($event) {
global $config, $database; global $config, $database;
// determine if post/list with tag, add prefix if needed // get the amount of images per page
$prefix = ""; $images_per_page = $config->get_int('index_images');
$page_number = (int)$event->get_arg(0);
if ($page_number == 0) { // if there are no tags, use default
$prefix = $event->get_arg(0)."/"; if ($event->get_arg(1) == null){
$page_number = (int)$event->get_arg(1); $prefix = "";
$page_number = (int)$event->get_arg(0);
$total_pages = ceil($database->get_one(
"SELECT COUNT(*) FROM images") / $images_per_page);
} }
// if the page number is still invalid, set it to 1 else { // if there are tags, use pages with tags
if(is_null($page_number) || $page_number <= 0) $prefix = $event->get_arg(0)."/";
$page_number = 1; $page_number = (int)$event->get_arg(1);
$total_pages = ceil($database->get_one(
// Determine the amount of pages "SELECT count FROM tags WHERE tag=:tag",
$images_per_page = $config->get_int('index_images'); array("tag"=>$event->get_arg(0))) / $images_per_page);
$total_pages = ceil($database->get_one("SELECT COUNT(*) FROM images") / $images_per_page); }
// creates previous & next values // creates previous & next values
// When previous first page, go to last page // When previous first page, go to last page