From ad905248e87cb840d8463818589b83dab4307105 Mon Sep 17 00:00:00 2001 From: Shish Date: Tue, 4 Feb 2020 01:12:50 +0000 Subject: [PATCH] prev/next/preload links for any page with a paginator --- core/basethemelet.php | 8 ++++++++ ext/index/theme.php | 7 ------- ext/view/theme.php | 13 ++++++++++--- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/core/basethemelet.php b/core/basethemelet.php index 8d5e1e44..50b55b33 100644 --- a/core/basethemelet.php +++ b/core/basethemelet.php @@ -83,6 +83,14 @@ class BaseThemelet } $body = $this->build_paginator($page_number, $total_pages, $base, $query, $show_random); $page->add_block(new Block(null, $body, "main", 90, "paginator")); + + if($page_number < $total_pages) { + $page->add_html_header(""); + $page->add_html_header(""); + } + if($page_number > 1) { + $page->add_html_header(""); + } } private function gen_page_link(string $base_url, ?string $query, int $page, string $name): string diff --git a/ext/index/theme.php b/ext/index/theme.php index b977f070..c21f505b 100644 --- a/ext/index/theme.php +++ b/ext/index/theme.php @@ -44,13 +44,6 @@ and of course start organising your images :-) if (count($images) > 0) { $this->display_page_images($page, $images); - if ($this->page_number < $this->total_pages) { - $next = $this->page_number + 1; - $u_tags = url_escape(Tag::implode($this->search_terms)); - $query = empty($u_tags) ? "" : '/'.$u_tags; - $next = make_link('post/list'.$query.'/'.$next); - $page->add_html_header(""); - } } else { $this->display_error(404, "No Images Found", "No images were found to match the search criteria"); } diff --git a/ext/view/theme.php b/ext/view/theme.php index 862106c1..6646d684 100644 --- a/ext/view/theme.php +++ b/ext/view/theme.php @@ -25,6 +25,10 @@ class ViewImageTheme extends Themelet $page->add_block(new Block("Navigation", $this->build_navigation($image), "left", 0)); $page->add_block(new Block(null, $this->build_info($image, $editor_parts), "main", 20)); //$page->add_block(new Block(null, $this->build_pin($image), "main", 11)); + + $query = $this->get_query(); + $page->add_html_header(""); + $page->add_html_header(""); } public function display_admin_block(Page $page, $parts) @@ -34,15 +38,18 @@ class ViewImageTheme extends Themelet } } - - protected function build_pin(Image $image) - { + protected function get_query() { if (isset($_GET['search'])) { $query = "search=".url_escape(Tag::caret($_GET['search'])); } else { $query = null; } + return $query; + } + protected function build_pin(Image $image) + { + $query = $this->get_query(); $h_prev = "Prev"; $h_index = "Index"; $h_next = "Next";