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

35 lines
1.1 KiB
PHP
Raw Normal View History

2020-01-26 13:19:35 +00:00
<?php declare(strict_types=1);
2020-01-26 23:12:48 +00:00
use function MicroHTML\INPUT;
class FeaturedTheme extends Themelet
{
public function display_featured(Page $page, Image $image): void
{
$page->add_block(new Block("Featured Image", $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']),
);
}
public function build_featured_html(Image $image, ?string $query=null): string
{
2020-01-26 19:44:36 +00:00
$i_id = $image->id;
$h_view_link = make_link("post/view/$i_id", $query);
$h_thumb_link = $image->get_thumb_link();
$h_tip = html_escape($image->get_tooltip());
$tsize = get_thumbnail_size($image->width, $image->height);
return "
2012-03-13 07:01:01 +00:00
<a href='$h_view_link'>
<img id='thumb_{$i_id}' title='{$h_tip}' alt='{$h_tip}' class='highlighted' style='height: {$tsize[1]}px; width: {$tsize[0]}px;' src='{$h_thumb_link}'>
2012-03-13 07:01:01 +00:00
</a>
";
}
}