This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/themes/rule34v2/index.theme.php

50 lines
1.7 KiB
PHP
Raw Normal View History

2020-02-01 18:22:08 +00:00
<?php
2021-12-14 18:32:47 +00:00
2023-01-10 21:21:26 +00:00
declare(strict_types=1);
namespace Shimmie2;
2020-02-01 18:22:08 +00:00
class CustomIndexTheme extends IndexTheme
{
2023-12-16 01:25:56 +00:00
public static array $_search_query = [];
2023-12-26 22:53:09 +00:00
// override to add the can-del class, so that thumbnail HTML can be cached
// with admin-controls included, and CSS is used to show or hide the controls
2020-02-01 18:22:08 +00:00
protected function build_table(array $images, ?string $query): string
{
global $user;
$candel = $user->can("delete_image") ? "can-del" : "";
$h_query = html_escape($query);
$table = "<div class='shm-image-list $candel' data-query='$h_query'>";
foreach ($images as $image) {
$table .= $this->build_thumb_html($image);
}
$table .= "</div>";
return $table;
}
2023-12-26 22:53:09 +00:00
// Override to add a custom error message
public function display_page(Page $page, $images): void
2020-02-01 18:22:08 +00:00
{
$this->display_page_header($page, $images);
$nav = $this->build_navigation($this->page_number, $this->total_pages, $this->search_terms);
if (!empty($this->search_terms)) {
2023-12-16 01:25:56 +00:00
static::$_search_query = $this->search_terms;
2020-02-01 18:22:08 +00:00
}
$page->add_block(new Block("Navigation", $nav, "left", 0));
if (count($images) > 0) {
$this->display_page_images($page, $images);
} else {
$this->display_error(
404,
2020-10-26 15:26:23 +00:00
"No Posts Found",
2020-02-01 18:22:08 +00:00
"No images were found to match the search criteria. Try looking up a character/series/artist by another name if they go by more than one. Remember to use underscores in place of spaces and not to use commas. If you came to this page by following a link, try using the search box directly instead. See the FAQ for more information."
);
}
}
}