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/upload.theme.php

114 lines
3.9 KiB
PHP
Raw Normal View History

2020-02-01 18:22:08 +00:00
<?php
2023-01-10 21:21:26 +00:00
declare(strict_types=1);
namespace Shimmie2;
2021-12-14 18:10:15 +00:00
use MicroHTML\HTMLElement;
2023-06-25 10:17:56 +00:00
use function MicroHTML\TABLE;
use function MicroHTML\TR;
use function MicroHTML\TD;
use function MicroHTML\SMALL;
use function MicroHTML\rawHTML;
use function MicroHTML\INPUT;
use function MicroHTML\emptyHTML;
use function MicroHTML\NOSCRIPT;
use function MicroHTML\DIV;
use function MicroHTML\BR;
2021-12-14 18:10:15 +00:00
use function MicroHTML\A;
2023-06-25 10:17:56 +00:00
use function MicroHTML\P;
2021-12-14 18:10:15 +00:00
2020-02-01 18:22:08 +00:00
class CustomUploadTheme extends UploadTheme
{
2021-12-14 18:10:15 +00:00
public function display_block(Page $page): void
2020-02-01 18:22:08 +00:00
{
$page->add_block(new Block("Upload", $this->build_upload_block(), "head", 20));
$page->add_block(new Block("Upload", $this->build_upload_block(), "left", 20));
}
2021-12-14 18:10:15 +00:00
public function display_full(Page $page): void
2020-02-01 18:22:08 +00:00
{
$page->add_block(new Block("Upload", "Disk nearly full, uploads disabled", "head", 20));
}
2021-12-14 18:10:15 +00:00
public function display_page(Page $page): void
2020-02-01 18:22:08 +00:00
{
2023-06-25 10:17:56 +00:00
global $config, $page;
$tl_enabled = ($config->get_string(UploadConfig::TRANSLOAD_ENGINE, "none") != "none");
$max_size = $config->get_int(UploadConfig::SIZE);
$max_kb = to_shorthand_int($max_size);
$upload_list = $this->h_upload_list_1();
$form = SHM_FORM("upload", "POST", true, "file_upload");
$form->appendChild(
TABLE(
2023-11-11 21:49:12 +00:00
["id" => "large_upload_form", "class" => "vert"],
2023-06-25 10:17:56 +00:00
TR(
2023-11-11 21:49:12 +00:00
TD(["width" => "20"], rawHTML("Common&nbsp;Tags")),
TD(["colspan" => "5"], INPUT(["name" => "tags", "type" => "text", "placeholder" => "tagme", "autocomplete" => "off"]))
2023-06-25 10:17:56 +00:00
),
TR(
2023-11-11 21:49:12 +00:00
TD(["width" => "20"], rawHTML("Common&nbsp;Source")),
TD(["colspan" => "5"], INPUT(["name" => "source", "type" => "text"]))
2023-06-25 10:17:56 +00:00
),
$upload_list,
TR(
2023-11-11 21:49:12 +00:00
TD(["colspan" => "6"], INPUT(["id" => "uploadbutton", "type" => "submit", "value" => "Post"]))
2023-06-25 10:17:56 +00:00
),
)
);
$html = emptyHTML(
$form,
SMALL("(Max file size is $max_kb)")
);
$page->set_title("Upload");
$page->set_heading("Upload");
$page->add_block(new NavBlock());
$page->add_block(new Block("Upload", $html, "main", 20));
2023-06-25 10:17:56 +00:00
if ($tl_enabled) {
$page->add_block(new Block("Bookmarklets", (string)$this->h_bookmarklets(), "left", 20));
}
2020-02-01 18:22:08 +00:00
$html = "
<a href='//rule34.paheal.net/wiki/tagging'>Tagging Guide</a>
";
$page->add_block(new Block(null, $html, "main", 19));
}
2021-12-14 18:10:15 +00:00
protected function build_upload_block(): HTMLElement
2020-02-01 18:22:08 +00:00
{
2023-11-11 21:49:12 +00:00
return A(["href" => make_link("upload"), "style" => 'font-size: 2em; display: block;'], "Upload");
2020-02-01 18:22:08 +00:00
}
2023-06-25 10:17:56 +00:00
protected function h_upload_list_1(): HTMLElement
{
global $config;
$upload_list = emptyHTML();
$upload_count = $config->get_int(UploadConfig::COUNT);
$tl_enabled = ($config->get_string(UploadConfig::TRANSLOAD_ENGINE, "none") != "none");
$accept = $this->get_accept();
$upload_list->appendChild(
TR(
2023-11-11 21:49:12 +00:00
TD(["colspan" => $tl_enabled ? 2 : 4], "Files"),
$tl_enabled ? TD(["colspan" => "2"], "URLs") : emptyHTML(),
TD(["colspan" => "2"], "Post-Specific Tags"),
2023-06-25 10:17:56 +00:00
)
);
2023-11-11 21:49:12 +00:00
for ($i = 0; $i < $upload_count; $i++) {
2023-06-25 10:17:56 +00:00
$upload_list->appendChild(
TR(
2023-11-11 21:49:12 +00:00
TD(["colspan" => $tl_enabled ? 2 : 4], INPUT(["type" => "file", "name" => "data{$i}[]", "accept" => $accept, "multiple" => true])),
$tl_enabled ? TD(["colspan" => "2"], INPUT(["type" => "text", "name" => "url{$i}"])) : emptyHTML(),
TD(["colspan" => "2"], INPUT(["type" => "text", "name" => "tags{$i}", "autocomplete" => "off"])),
2023-06-25 10:17:56 +00:00
)
);
}
return $upload_list;
}
2020-02-01 18:22:08 +00:00
}