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

48 lines
1.4 KiB
PHP
Raw Normal View History

2021-12-14 18:32:47 +00:00
<?php
declare(strict_types=1);
namespace Shimmie2;
2020-01-26 23:12:48 +00:00
use function MicroHTML\INPUT;
use function MicroHTML\DIV;
use function MicroHTML\A;
use function MicroHTML\IMG;
class FeaturedTheme extends Themelet
{
public function display_featured(Page $page, Image $image): void
{
2020-10-26 13:46:00 +00:00
$page->add_block(new Block("Featured Post", $this->build_featured_html($image), "left", 3));
}
public function get_buttons_html(int $image_id): string
{
2020-01-26 23:12:48 +00:00
return (string)SHM_SIMPLE_FORM(
2020-01-30 10:31:11 +00:00
"featured_image/set",
2020-01-26 23:12:48 +00:00
INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image_id]),
INPUT(["type"=>'submit', "value"=>'Feature This']),
);
}
2022-10-28 00:45:35 +00:00
public function build_featured_html(Image $image, ?string $query=null): \MicroHTML\HTMLElement
{
$tsize = get_thumbnail_size($image->width, $image->height);
2022-10-28 00:45:35 +00:00
return DIV(
["style"=>"text-align: center;"],
A(
["href"=>make_link("post/view/{$image->id}", $query)],
IMG([
"id"=>"thumb_rand_{$image->id}",
"title"=>$image->get_tooltip(),
"alt"=>$image->get_tooltip(),
"class"=>'highlighted',
"style"=>"max-height: {$tsize[1]}px; max-width: 100%;",
"src"=>$image->get_thumb_link()
])
)
);
}
}