From 49e4c3f9c7418d2472f266cf44560f7f8924edb7 Mon Sep 17 00:00:00 2001 From: Shish Date: Fri, 31 Jul 2020 15:50:57 +0100 Subject: [PATCH] info as part of view ext --- ext/image/config.php | 1 + ext/rule34/main.php | 6 ------ ext/view/main.php | 16 ++++++++++++++++ ext/view/test.php | 12 ++++++++++++ 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/ext/image/config.php b/ext/image/config.php index 1485c7d0..e622bef6 100644 --- a/ext/image/config.php +++ b/ext/image/config.php @@ -17,6 +17,7 @@ abstract class ImageConfig const ILINK = 'image_ilink'; const TLINK = 'image_tlink'; const TIP = 'image_tip'; + const INFO = 'image_info'; const EXPIRES = 'image_expires'; const UPLOAD_COLLISION_HANDLER = 'upload_collision_handler'; diff --git a/ext/rule34/main.php b/ext/rule34/main.php index 1a98a2b8..a0c577b6 100644 --- a/ext/rule34/main.php +++ b/ext/rule34/main.php @@ -46,12 +46,6 @@ class Rule34 extends Extension ) ); $event->add_part($html, 90); - - $html = (string)TR( - TH("Info"), - TD($event->image->parse_link_template('$size // $filesize // $ext')) - ); - $event->add_part($html, 90); } public function onAdminBuilding(AdminBuildingEvent $event) diff --git a/ext/view/main.php b/ext/view/main.php index 3b534158..6c314557 100644 --- a/ext/view/main.php +++ b/ext/view/main.php @@ -5,6 +5,9 @@ require_once "events/image_info_box_building_event.php"; require_once "events/image_info_set_event.php"; require_once "events/image_admin_block_building_event.php"; +use function MicroHTML\TR; +use function MicroHTML\TH; +use function MicroHTML\TD; class ViewImage extends Extension { @@ -98,4 +101,17 @@ class ViewImage extends Extension ksort($iabbe->parts); $this->theme->display_admin_block($page, $iabbe->parts); } + + public function onImageInfoBoxBuilding(ImageInfoBoxBuildingEvent $event) + { + global $config; + $image_info = $config->get_string(ImageConfig::INFO); + if ($image_info) { + $html = (string)TR( + TH("Info"), + TD($event->image->parse_link_template($image_info)) + ); + $event->add_part($html, 85); + } + } } diff --git a/ext/view/test.php b/ext/view/test.php index 3d6e0cc8..a0f18c75 100644 --- a/ext/view/test.php +++ b/ext/view/test.php @@ -16,6 +16,18 @@ class ViewImageTest extends ShimmiePHPUnitTestCase $this->assert_title("Image $image_id_1: test"); } + public function testViewInfo() + { + global $config; + + $this->log_in_as_user(); + $image_id_1 = $this->post_image("tests/pbx_screenshot.jpg", "test"); + + $config->set_string(ImageConfig::INFO, '$size // $filesize // $ext'); + $this->get_page("post/view/$image_id_1"); + $this->assert_text("640x480 // 19.3KB // jpg"); + } + public function testPrevNext() { $this->log_in_as_user();