From cfc5019a208ab0a617e6b364754ed43a516dd100 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Thu, 19 Jan 2023 11:31:31 +0000 Subject: [PATCH] Bug 32680: Add hooks to allow cover art to come from plugins This patch adds hooks to Koha core that allow a plugin for cover art to inject the images into the OPAC and staff client. These hooks could be re-used for other providers. As an example, a plugin has been created for BDS covers, the link is in another comment Test plan: 1) Apply patch 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 --- C4/Auth.pm | 10 ++++++++++ .../prog/en/modules/catalogue/results.tt | 18 +++++++++++++++--- .../bootstrap/en/modules/opac-detail.tt | 8 +++++++- .../bootstrap/en/modules/opac-results.tt | 18 ++++++++++++++++-- 4 files changed, 48 insertions(+), 6 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 8e5b5f6e545..5ce3968a90b 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -51,6 +51,7 @@ use Net::CIDR; use C4::Log qw( logaction ); use Koha::CookieManager; use Koha::Auth::Permissions; +use Koha::Template::Plugin::KohaPlugins; # use utf8; @@ -458,6 +459,15 @@ sub get_template_and_user { $can_make_suggestions = Koha::Patrons->find(C4::Context->userenv->{'number'})->category->can_make_suggestions; } + my $intranet_js_plugins = Koha::Template::Plugin::KohaPlugins->get_plugins_intranet_js; + if(index($intranet_js_plugins, "Cover Image Plugin") != -1){ + $template->param( Cover_Images_Required => 1 ) + } + my $opac_js_plugins = Koha::Template::Plugin::KohaPlugins->get_plugins_opac_js; + if(index($opac_js_plugins, "Cover Image Plugin") != -1){ + $template->param( Cover_Images_Required => 1 ) + } + my $minPasswordLength = C4::Context->preference('minPasswordLength'); $minPasswordLength = 3 if not $minPasswordLength or $minPasswordLength < 3; $template->param( diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt index 82735d4be81..eb61a12dcd1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt @@ -449,7 +449,7 @@ - [% IF ( AmazonCoverImages || LocalCoverImages || ( SyndeticsCovers ) || (Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL')) ) %] + [% IF ( Cover_Images_Required || AmazonCoverImages || LocalCoverImages || ( SyndeticsCovers ) || (Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL')) ) %] [% END %] @@ -461,9 +461,9 @@ [% FOREACH SEARCH_RESULT IN SEARCH_RESULTS %] - [% IF ( AmazonCoverImages || LocalCoverImages || IntranetCoce || ( SyndeticsCovers ) || (Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL')) ) %] + [% IF ( Cover_Images_Required || AmazonCoverImages || LocalCoverImages || IntranetCoce || ( SyndeticsCovers ) || (Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL')) ) %]
 Results
-
+
[% IF ( LocalCoverImages ) %][% SEARCH_RESULT.localimage | html %]
@@ -781,6 +781,18 @@ [% Asset.css("css/humanmsg.css") | $raw %] [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %] [% INCLUDE 'select2.inc' %] + [% IF ( Cover_Images_Required ) %] + + [% END %] + [% END %] + [% IF ( OpacHighlightedWords ) %][% Asset.js("lib/jquery/plugins/jquery.highlight-3.js") | $raw %][% END %] [% IF ( Koha.Preference('OPACDetailQRCode') ) %] [% Asset.js("lib/kjua/kjua.min.js") | $raw %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt index 95fa8d63046..da5284f5ccb 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt @@ -341,7 +341,7 @@ [% # Cell 4: Search result details and controls %]
-