use joinHTML for paginator

This commit is contained in:
Shish 2023-08-17 18:23:36 +01:00 committed by Shish
parent 5879184895
commit 0c014fde01
4 changed files with 11 additions and 24 deletions

View file

@ -6,7 +6,7 @@ namespace Shimmie2;
use MicroHTML\HTMLElement;
use function MicroHTML\{A,B,BR,IMG,emptyHTML};
use function MicroHTML\{A,B,BR,IMG,emptyHTML,joinHTML};
/**
* Class BaseThemelet
@ -135,19 +135,6 @@ class BaseThemelet
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
{
$next = $current_page + 1;
@ -175,10 +162,10 @@ class BaseThemelet
foreach (range($start, $end) as $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(
$this->implode(" | ", [
joinHTML(" | ", [
$first_html,
$prev_html,
$random_html,

View file

@ -6,7 +6,7 @@ namespace Shimmie2;
use MicroHTML\HTMLElement;
use function MicroHTML\{A, B, DIV};
use function MicroHTML\{A, B, DIV, joinHTML};
class Themelet extends BaseThemelet
{
@ -54,7 +54,7 @@ class Themelet extends BaseThemelet
foreach (range($start, $end) as $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) {
$pdots = "...";
@ -68,6 +68,6 @@ class Themelet extends BaseThemelet
$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]));
}
}

View file

@ -6,7 +6,7 @@ namespace Shimmie2;
use MicroHTML\HTMLElement;
use function MicroHTML\{A,B,DIV};
use function MicroHTML\{A,B,DIV,joinHTML};
class Themelet extends BaseThemelet
{
@ -54,7 +54,7 @@ class Themelet extends BaseThemelet
foreach (range($start, $end) as $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) {
$pdots = "...";
@ -68,6 +68,6 @@ class Themelet extends BaseThemelet
$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]));
}
}

View file

@ -6,7 +6,7 @@ namespace Shimmie2;
use MicroHTML\HTMLElement;
use function MicroHTML\{A,DIV,SPAN};
use function MicroHTML\{A,DIV,SPAN,joinHTML};
/**
* Class Themelet
@ -83,7 +83,7 @@ class Themelet extends BaseThemelet
$prev_html,
$random_html,
"<< ",
$this->implode(" ", $pages),
joinHTML(" ", $pages),
" >>",
$next_html,
$last_html