use joinHTML for paginator
This commit is contained in:
parent
5879184895
commit
0c014fde01
4 changed files with 11 additions and 24 deletions
|
@ -6,7 +6,7 @@ namespace Shimmie2;
|
||||||
|
|
||||||
use MicroHTML\HTMLElement;
|
use MicroHTML\HTMLElement;
|
||||||
|
|
||||||
use function MicroHTML\{A,B,BR,IMG,emptyHTML};
|
use function MicroHTML\{A,B,BR,IMG,emptyHTML,joinHTML};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class BaseThemelet
|
* Class BaseThemelet
|
||||||
|
@ -135,19 +135,6 @@ class BaseThemelet
|
||||||
return $paginator;
|
return $paginator;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function implode(string|HTMLElement $glue, array $pieces): HTMLElement
|
|
||||||
{
|
|
||||||
$out = emptyHTML();
|
|
||||||
$n = 0;
|
|
||||||
foreach ($pieces as $piece) {
|
|
||||||
if ($n++ > 0) {
|
|
||||||
$out->appendChild($glue);
|
|
||||||
}
|
|
||||||
$out->appendChild($piece);
|
|
||||||
}
|
|
||||||
return $out;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function build_paginator(int $current_page, int $total_pages, string $base_url, ?string $query, bool $show_random): HTMLElement
|
private function build_paginator(int $current_page, int $total_pages, string $base_url, ?string $query, bool $show_random): HTMLElement
|
||||||
{
|
{
|
||||||
$next = $current_page + 1;
|
$next = $current_page + 1;
|
||||||
|
@ -175,10 +162,10 @@ class BaseThemelet
|
||||||
foreach (range($start, $end) as $i) {
|
foreach (range($start, $end) as $i) {
|
||||||
$pages[] = $this->gen_page_link_block($base_url, $query, $i, $current_page, (string)$i);
|
$pages[] = $this->gen_page_link_block($base_url, $query, $i, $current_page, (string)$i);
|
||||||
}
|
}
|
||||||
$pages_html = $this->implode(" | ", $pages);
|
$pages_html = joinHTML(" | ", $pages);
|
||||||
|
|
||||||
return emptyHTML(
|
return emptyHTML(
|
||||||
$this->implode(" | ", [
|
joinHTML(" | ", [
|
||||||
$first_html,
|
$first_html,
|
||||||
$prev_html,
|
$prev_html,
|
||||||
$random_html,
|
$random_html,
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace Shimmie2;
|
||||||
|
|
||||||
use MicroHTML\HTMLElement;
|
use MicroHTML\HTMLElement;
|
||||||
|
|
||||||
use function MicroHTML\{A, B, DIV};
|
use function MicroHTML\{A, B, DIV, joinHTML};
|
||||||
|
|
||||||
class Themelet extends BaseThemelet
|
class Themelet extends BaseThemelet
|
||||||
{
|
{
|
||||||
|
@ -54,7 +54,7 @@ class Themelet extends BaseThemelet
|
||||||
foreach (range($start, $end) as $i) {
|
foreach (range($start, $end) as $i) {
|
||||||
$pages[] = $this->gen_page_link_block($base_url, $query, $i, $current_page, (string)$i);
|
$pages[] = $this->gen_page_link_block($base_url, $query, $i, $current_page, (string)$i);
|
||||||
}
|
}
|
||||||
$pages_html = $this->implode(" ", $pages);
|
$pages_html = joinHTML(" ", $pages);
|
||||||
|
|
||||||
if ($first_html) {
|
if ($first_html) {
|
||||||
$pdots = "...";
|
$pdots = "...";
|
||||||
|
@ -68,6 +68,6 @@ class Themelet extends BaseThemelet
|
||||||
$ndots = "";
|
$ndots = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return DIV(["id"=>'paginator'], $this->implode(" ", [$prev_html, $first_html, $pdots, $pages_html, $ndots, $last_html, $next_html]));
|
return DIV(["id"=>'paginator'], joinHTML(" ", [$prev_html, $first_html, $pdots, $pages_html, $ndots, $last_html, $next_html]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace Shimmie2;
|
||||||
|
|
||||||
use MicroHTML\HTMLElement;
|
use MicroHTML\HTMLElement;
|
||||||
|
|
||||||
use function MicroHTML\{A,B,DIV};
|
use function MicroHTML\{A,B,DIV,joinHTML};
|
||||||
|
|
||||||
class Themelet extends BaseThemelet
|
class Themelet extends BaseThemelet
|
||||||
{
|
{
|
||||||
|
@ -54,7 +54,7 @@ class Themelet extends BaseThemelet
|
||||||
foreach (range($start, $end) as $i) {
|
foreach (range($start, $end) as $i) {
|
||||||
$pages[] = $this->gen_page_link_block($base_url, $query, $i, $current_page, (string)$i);
|
$pages[] = $this->gen_page_link_block($base_url, $query, $i, $current_page, (string)$i);
|
||||||
}
|
}
|
||||||
$pages_html = $this->implode(" ", $pages);
|
$pages_html = joinHTML(" ", $pages);
|
||||||
|
|
||||||
if ($first_html) {
|
if ($first_html) {
|
||||||
$pdots = "...";
|
$pdots = "...";
|
||||||
|
@ -68,6 +68,6 @@ class Themelet extends BaseThemelet
|
||||||
$ndots = "";
|
$ndots = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return DIV(["id"=>"paginator"], $this->implode(" ", [$prev_html, $first_html, $pdots, $pages_html, $ndots, $last_html, $next_html]));
|
return DIV(["id"=>"paginator"], joinHTML(" ", [$prev_html, $first_html, $pdots, $pages_html, $ndots, $last_html, $next_html]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace Shimmie2;
|
||||||
|
|
||||||
use MicroHTML\HTMLElement;
|
use MicroHTML\HTMLElement;
|
||||||
|
|
||||||
use function MicroHTML\{A,DIV,SPAN};
|
use function MicroHTML\{A,DIV,SPAN,joinHTML};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Themelet
|
* Class Themelet
|
||||||
|
@ -83,7 +83,7 @@ class Themelet extends BaseThemelet
|
||||||
$prev_html,
|
$prev_html,
|
||||||
$random_html,
|
$random_html,
|
||||||
"<< ",
|
"<< ",
|
||||||
$this->implode(" ", $pages),
|
joinHTML(" ", $pages),
|
||||||
" >>",
|
" >>",
|
||||||
$next_html,
|
$next_html,
|
||||||
$last_html
|
$last_html
|
||||||
|
|
Reference in a new issue