2021-12-14 18:32:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2023-01-10 22:44:09 +00:00
|
|
|
|
|
|
|
namespace Shimmie2;
|
|
|
|
|
2020-01-26 23:12:48 +00:00
|
|
|
use function MicroHTML\INPUT;
|
2020-03-28 00:23:29 +00:00
|
|
|
use function MicroHTML\DIV;
|
|
|
|
use function MicroHTML\A;
|
|
|
|
use function MicroHTML\IMG;
|
2008-05-19 02:19:46 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
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));
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2008-05-19 02:19:46 +00:00
|
|
|
|
2024-01-19 18:57:02 +00:00
|
|
|
public function get_buttons_html(int $image_id): \MicroHTML\HTMLElement
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2024-01-19 18:57:02 +00:00
|
|
|
return SHM_SIMPLE_FORM(
|
2020-01-30 10:31:11 +00:00
|
|
|
"featured_image/set",
|
2023-11-11 21:49:12 +00:00
|
|
|
INPUT(["type" => 'hidden', "name" => 'image_id', "value" => $image_id]),
|
|
|
|
INPUT(["type" => 'submit', "value" => 'Feature This']),
|
2020-01-26 23:12:48 +00:00
|
|
|
);
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2014-04-28 05:26:22 +00:00
|
|
|
|
2023-11-11 21:49:12 +00:00
|
|
|
public function build_featured_html(Image $image, ?string $query = null): \MicroHTML\HTMLElement
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
|
|
|
$tsize = get_thumbnail_size($image->width, $image->height);
|
2012-01-27 05:19:47 +00:00
|
|
|
|
2022-10-28 00:45:35 +00:00
|
|
|
return DIV(
|
2023-11-11 21:49:12 +00:00
|
|
|
["style" => "text-align: center;"],
|
2020-03-28 00:23:29 +00:00
|
|
|
A(
|
2023-11-11 21:49:12 +00:00
|
|
|
["href" => make_link("post/view/{$image->id}", $query)],
|
2020-03-28 00:23:29 +00:00
|
|
|
IMG([
|
2023-11-11 21:49:12 +00:00
|
|
|
"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()
|
2020-03-28 00:23:29 +00:00
|
|
|
])
|
|
|
|
)
|
|
|
|
);
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2008-05-19 02:19:46 +00:00
|
|
|
}
|