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;
|
2008-05-19 02:19:46 +00:00
|
|
|
|
2019-05-28 17:59:38 +01:00
|
|
|
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));
|
|
|
|
}
|
2008-05-19 02:19:46 +00:00
|
|
|
|
2019-05-28 17:59:38 +01:00
|
|
|
public function get_buttons_html(int $image_id): string
|
|
|
|
{
|
2020-01-26 23:12:48 +00:00
|
|
|
return (string)SHM_SIMPLE_FORM(
|
|
|
|
make_link("featured_image/set"),
|
|
|
|
INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image_id]),
|
|
|
|
INPUT(["type"=>'submit', "value"=>'Feature This']),
|
|
|
|
);
|
2019-05-28 17:59:38 +01:00
|
|
|
}
|
2014-04-28 01:26:22 -04:00
|
|
|
|
2019-05-28 17:59:38 +01:00
|
|
|
public function build_featured_html(Image $image, ?string $query=null): string
|
|
|
|
{
|
2020-01-26 19:44:36 +00:00
|
|
|
$i_id = $image->id;
|
2019-05-28 17:59:38 +01:00
|
|
|
$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);
|
2012-01-27 05:19:47 +00:00
|
|
|
|
2019-05-28 17:59:38 +01:00
|
|
|
return "
|
2012-03-13 07:01:01 +00:00
|
|
|
<a href='$h_view_link'>
|
2014-04-28 01:26:22 -04:00
|
|
|
<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>
|
2012-01-27 05:19:47 +00:00
|
|
|
";
|
2019-05-28 17:59:38 +01:00
|
|
|
}
|
2008-05-19 02:19:46 +00:00
|
|
|
}
|