";
return $html;
}
public function get_source_editor_html(Image $image): HTMLElement
{
global $user;
return SHM_POST_INFO(
"Source Link",
DIV(
["style" => "overflow: hidden; white-space: nowrap; max-width: 350px; text-overflow: ellipsis;"],
$this->format_source($image->get_source())
),
$user->can(Permissions::EDIT_IMAGE_SOURCE) ? INPUT(["type" => "text", "name" => "source", "value" => $image->get_source()]) : null,
link: Extension::is_enabled(SourceHistoryInfo::KEY) ? make_link("source_history/{$image->id}") : null,
);
}
protected function format_source(string $source = null): HTMLElement
{
if (!empty($source)) {
if (!str_contains($source, "://")) {
$source = "https://" . $source;
}
$proto_domain = explode("://", $source);
$h_source = $proto_domain[1];
if (str_ends_with($h_source, "/")) {
$h_source = substr($h_source, 0, -1);
}
return A(["href" => $source], $h_source);
}
return rawHTML("Unknown");
}
}