info as part of view ext

This commit is contained in:
Shish 2020-07-31 15:50:57 +01:00
parent 804fc038bf
commit 49e4c3f9c7
4 changed files with 29 additions and 6 deletions

View file

@ -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';

View file

@ -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)

View file

@ -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);
}
}
}

View file

@ -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();