added option to hide random link on paginator (only post/list should show now)
This commit is contained in:
parent
a7de21523f
commit
be18140944
7 changed files with 26 additions and 16 deletions
|
@ -84,9 +84,9 @@ class BaseThemelet {
|
|||
* @param int $page_number
|
||||
* @param int $total_pages
|
||||
*/
|
||||
public function display_paginator(Page $page, $base, $query, $page_number, $total_pages) {
|
||||
public function display_paginator(Page $page, $base, $query, $page_number, $total_pages, $show_random) {
|
||||
if($total_pages == 0) $total_pages = 1;
|
||||
$body = $this->build_paginator($page_number, $total_pages, $base, $query);
|
||||
$body = $this->build_paginator($page_number, $total_pages, $base, $query, $show_random);
|
||||
$page->add_block(new Block(null, $body, "main", 90, "paginator"));
|
||||
}
|
||||
|
||||
|
@ -129,17 +129,22 @@ class BaseThemelet {
|
|||
* @param string $query
|
||||
* @return string
|
||||
*/
|
||||
private function build_paginator($current_page, $total_pages, $base_url, $query) {
|
||||
private function build_paginator($current_page, $total_pages, $base_url, $query, $show_random = FALSE) {
|
||||
$next = $current_page + 1;
|
||||
$prev = $current_page - 1;
|
||||
$rand = mt_rand(1, $total_pages);
|
||||
|
||||
$at_start = ($current_page <= 1 || $total_pages <= 1);
|
||||
$at_end = ($current_page >= $total_pages);
|
||||
|
||||
$first_html = $at_start ? "First" : $this->gen_page_link($base_url, $query, 1, "First");
|
||||
$prev_html = $at_start ? "Prev" : $this->gen_page_link($base_url, $query, $prev, "Prev");
|
||||
$random_html = $this->gen_page_link($base_url, $query, $rand, "Random");
|
||||
|
||||
$random_html = "-";
|
||||
if($show_random) {
|
||||
$rand = mt_rand(1, $total_pages);
|
||||
$random_html = $this->gen_page_link($base_url, $query, $rand, "Random");
|
||||
}
|
||||
|
||||
$next_html = $at_end ? "Next" : $this->gen_page_link($base_url, $query, $next, "Next");
|
||||
$last_html = $at_end ? "Last" : $this->gen_page_link($base_url, $query, $total_pages, "Last");
|
||||
|
||||
|
|
|
@ -106,10 +106,10 @@ and of course start organising your images :-)
|
|||
if (count($this->search_terms) > 0) {
|
||||
$query = url_escape(implode(' ', $this->search_terms));
|
||||
$page->add_block(new Block("Images", $this->build_table($images, "#search=$query"), "main", 10, "image-list"));
|
||||
$this->display_paginator($page, "post/list/$query", null, $this->page_number, $this->total_pages);
|
||||
$this->display_paginator($page, "post/list/$query", null, $this->page_number, $this->total_pages, TRUE);
|
||||
} else {
|
||||
$page->add_block(new Block("Images", $this->build_table($images, null), "main", 10, "image-list"));
|
||||
$this->display_paginator($page, "post/list", null, $this->page_number, $this->total_pages);
|
||||
$this->display_paginator($page, "post/list", null, $this->page_number, $this->total_pages, TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ class Themelet extends BaseThemelet {
|
|||
* @param int $page_number
|
||||
* @param int $total_pages
|
||||
*/
|
||||
public function display_paginator(Page $page, $base, $query, $page_number, $total_pages) {
|
||||
public function display_paginator(Page $page, $base, $query, $page_number, $total_pages, $show_random) {
|
||||
if($total_pages == 0) $total_pages = 1;
|
||||
$body = $this->build_paginator($page_number, $total_pages, $base, $query);
|
||||
$page->add_block(new Block(null, $body, "main", 90));
|
||||
|
|
|
@ -7,7 +7,7 @@ class Themelet extends BaseThemelet {
|
|||
* @param int $page_number
|
||||
* @param int $total_pages
|
||||
*/
|
||||
public function display_paginator(Page $page, $base, $query, $page_number, $total_pages) {
|
||||
public function display_paginator(Page $page, $base, $query, $page_number, $total_pages, $show_random) {
|
||||
if($total_pages == 0) $total_pages = 1;
|
||||
$body = $this->build_paginator($page_number, $total_pages, $base, $query);
|
||||
$page->add_block(new Block(null, $body, "main", 90));
|
||||
|
|
|
@ -15,7 +15,7 @@ class CustomCommentListTheme extends CommentListTheme {
|
|||
$page->disable_left();
|
||||
$page->add_block(new Block(null, $this->build_upload_box(), "main", 0));
|
||||
$page->add_block(new Block(null, "<hr>", "main", 80));
|
||||
$this->display_paginator($page, "comment/list", null, $page_number, $total_pages, 90);
|
||||
$this->display_paginator($page, "comment/list", null, $page_number, $total_pages);
|
||||
|
||||
// parts for each image
|
||||
$position = 10;
|
||||
|
|
|
@ -11,10 +11,10 @@ class Themelet extends BaseThemelet {
|
|||
* @param int $total_pages
|
||||
* @param int $position
|
||||
*/
|
||||
public function display_paginator(Page $page, $base, $query, $page_number, $total_pages, $position=90) {
|
||||
public function display_paginator(Page $page, $base, $query, $page_number, $total_pages, $show_random) {
|
||||
if($total_pages == 0) $total_pages = 1;
|
||||
$body = $this->futaba_build_paginator($page_number, $total_pages, $base, $query);
|
||||
$page->add_block(new Block(null, $body, "main", $position));
|
||||
$page->add_block(new Block(null, $body, "main", 90));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,9 +28,9 @@ class Themelet extends BaseThemelet {
|
|||
* @param int $page_number
|
||||
* @param int $total_pages
|
||||
*/
|
||||
public function display_paginator(Page $page, $base, $query, $page_number, $total_pages) {
|
||||
public function display_paginator(Page $page, $base, $query, $page_number, $total_pages, $show_random) {
|
||||
if($total_pages == 0) $total_pages = 1;
|
||||
$body = $this->litetheme_build_paginator($page_number, $total_pages, $base, $query);
|
||||
$body = $this->litetheme_build_paginator($page_number, $total_pages, $base, $query, $show_random);
|
||||
$page->add_block(new Block(null, $body, "main", 90));
|
||||
}
|
||||
|
||||
|
@ -74,14 +74,19 @@ class Themelet extends BaseThemelet {
|
|||
public function litetheme_build_paginator($current_page, $total_pages, $base_url, $query) {
|
||||
$next = $current_page + 1;
|
||||
$prev = $current_page - 1;
|
||||
$rand = mt_rand(1, $total_pages);
|
||||
|
||||
$at_start = ($current_page <= 1 || $total_pages <= 1);
|
||||
$at_end = ($current_page >= $total_pages);
|
||||
|
||||
$first_html = $at_start ? "<span class='tab'>First</span>" : $this->litetheme_gen_page_link($base_url, $query, 1, "First");
|
||||
$prev_html = $at_start ? "<span class='tab'>Prev</span>" : $this->litetheme_gen_page_link($base_url, $query, $prev, "Prev");
|
||||
$random_html = $this->litetheme_gen_page_link($base_url, $query, $rand, "Random");
|
||||
|
||||
$random_html = "";
|
||||
if($show_random) {
|
||||
$rand = mt_rand(1, $total_pages);
|
||||
$random_html = $this->litetheme_gen_page_link($base_url, $query, $rand, "Random");
|
||||
}
|
||||
|
||||
$next_html = $at_end ? "<span class='tab'>Next</span>" : $this->litetheme_gen_page_link($base_url, $query, $next, "Next");
|
||||
$last_html = $at_end ? "<span class='tab'>Last</span>" : $this->litetheme_gen_page_link($base_url, $query, $total_pages, "Last");
|
||||
|
||||
|
|
Reference in a new issue