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

60 lines
1.9 KiB
PHP
Raw Normal View History

2021-12-14 18:32:47 +00:00
<?php
declare(strict_types=1);
namespace Shimmie2;
2021-12-14 18:32:47 +00:00
use function MicroHTML\emptyHTML;
use function MicroHTML\rawHTML;
use function MicroHTML\TABLE;
use function MicroHTML\TBODY;
use function MicroHTML\TFOOT;
use function MicroHTML\TR;
use function MicroHTML\TH;
use function MicroHTML\TD;
use function MicroHTML\LABEL;
use function MicroHTML\INPUT;
use function MicroHTML\SMALL;
use function MicroHTML\A;
use function MicroHTML\BR;
use function MicroHTML\P;
use function MicroHTML\SELECT;
use function MicroHTML\OPTION;
2020-03-18 17:29:08 +00:00
2020-02-01 18:22:08 +00:00
class CustomUserPageTheme extends UserPageTheme
{
2023-12-26 22:53:09 +00:00
// Override to display user block in the head and in the left column
// (with css media queries deciding which one is visible), and also
// to switch between new-line and inline display depending on the
// number of links.
/**
* @param array<array{link: string, name: string}> $parts
*/
public function display_user_block(Page $page, User $user, array $parts): void
2020-02-01 18:22:08 +00:00
{
$h_name = html_escape($user->name);
$lines = [];
foreach ($parts as $part) {
2023-06-28 13:05:50 +00:00
if ($part["name"] == "User Options") {
continue;
}
2020-02-01 18:22:08 +00:00
$lines[] = "<a href='{$part["link"]}'>{$part["name"]}</a>";
}
if (count($lines) < 6) {
$html = implode("\n<br>", $lines);
} else {
$html = implode(" | \n", $lines);
}
$page->add_block(new Block("Logged in as $h_name", $html, "head", 90, "UserBlockhead"));
$page->add_block(new Block("Logged in as $h_name", $html, "left", 15, "UserBlockleft"));
}
2023-12-26 22:53:09 +00:00
// Override to display login block in the head and in the left column
// (with css media queries deciding which one is visible)
public function display_login_block(Page $page): void
2020-02-01 18:22:08 +00:00
{
$page->add_block(new Block("Login", $this->create_login_block(), "head", 90));
$page->add_block(new Block("Login", $this->create_login_block(), "left", 15));
2020-11-01 10:39:06 +00:00
}
2020-02-01 18:22:08 +00:00
}