From 728e6872907ee08c1a5f97874918525e0b5adf53 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Wed, 19 Apr 2023 11:21:02 +0000 Subject: [PATCH] Bug 32680: Add cover images plugin hook This patch adds a plugin hook to inject cover images into the templates Test plan: 1) Apply all patches 2) Go to https://github.com/PTFS-Europe/koha-plugin-addBDSCovers 3) In the releases section, download the .kpz file 4) Upload this in the plugins section and enable the plugin 5) In either the OPAC or staff client, search the catalog 6) The results should have cover art from BDS covers 7) Click on a result and the detail page should also have the cover art Signed-off-by: Nick Clemens Signed-off-by: Tomas Cohen Arazi --- Koha/Template/Plugin/KohaPlugins.pm | 52 +++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/Koha/Template/Plugin/KohaPlugins.pm b/Koha/Template/Plugin/KohaPlugins.pm index 4a6e27c221..7d527b34e3 100644 --- a/Koha/Template/Plugin/KohaPlugins.pm +++ b/Koha/Template/Plugin/KohaPlugins.pm @@ -230,4 +230,56 @@ sub get_plugins_intranet_catalog_biblio_tab { return $tabs; } +=head3 get_plugins_intranet_cover_images + +[% KohaPlugins. get_plugins_intranet_cover_images %] + +This method collects the output of all plugins for injecting cover images into the intranet template and appends it to the javascript at the bottom of the page. + +=cut + +sub get_plugins_intranet_cover_images { + return q{} unless C4::Context->config("enable_plugins"); + + my $p = Koha::Plugins->new(); + + return q{} unless $p; + + my @plugins = $p->GetPlugins( + { + method => 'intranet_cover_images', + } + ); + + my @data = map { $_->intranet_cover_images || q{} } @plugins; + + return join( "\n", @data ); +} + +=head3 get_plugins_opac_cover_images + +[% KohaPlugins. get_plugins_opac_cover_images %] + +This method collects the output of all plugins for injecting cover images into the opac template and appends it to the javascript at the bottom of the page. + +=cut + +sub get_plugins_opac_cover_images { + return q{} unless C4::Context->config("enable_plugins"); + + my $p = Koha::Plugins->new(); + + return q{} unless $p; + + my @plugins = $p->GetPlugins( + { + method => 'opac_cover_images', + } + ); + + my @data = map { $_->opac_cover_images || q{} } @plugins; + + return join( "\n", @data ); +} + 1; -- 2.39.5