From 1219a25717a25a5197e14d08590541a77b46408b 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 | 1 + catalogue/detail.pl | 5 +++++ catalogue/search.pl | 5 +++++ etc/koha-conf.xml | 2 +- .../prog/en/modules/catalogue/detail.tt | 11 ++++++++--- .../prog/en/modules/catalogue/results.tt | 18 +++++++++++++++--- .../bootstrap/en/modules/opac-detail.tt | 8 +++++++- .../bootstrap/en/modules/opac-results.tt | 18 ++++++++++++++++-- opac/opac-detail.pl | 5 +++++ opac/opac-search.pl | 5 +++++ 10 files changed, 68 insertions(+), 10 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 8e5b5f6e545..1526e6a48e2 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; diff --git a/catalogue/detail.pl b/catalogue/detail.pl index c7908bc9693..99bfc5779c6 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -684,4 +684,9 @@ $template->param(found1 => scalar $query->param('found1') ); $template->param(biblio => $biblio); +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 ) +} + output_html_with_http_headers $query, $cookie, $template->output; diff --git a/catalogue/search.pl b/catalogue/search.pl index bf225911ef9..68e75eba490 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -779,6 +779,11 @@ my $some_public_shelves = Koha::Virtualshelves->get_some_shelves( } ); +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 ) +} + $template->param( add_to_some_private_shelves => $some_private_shelves, diff --git a/etc/koha-conf.xml b/etc/koha-conf.xml index 3e5623cb960..3666cfc4548 100644 --- a/etc/koha-conf.xml +++ b/etc/koha-conf.xml @@ -78,7 +78,7 @@ authorities 1 __PLUGINS_DIR__ - 0 + 1 __INTRANET_CGI_DIR__ diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index ace46656c9b..d11de103af4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -114,7 +114,7 @@ [% END %] - [% 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')) ) %]
[% ELSE %]
@@ -204,10 +204,10 @@ [% END %]
[%# .page-section %] - [% 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')) ) %]
-
+
[% IF ( LocalCoverImages ) %] [% IF localimages.count %] [% FOREACH image IN localimages %] @@ -1310,6 +1310,11 @@ Note that permanent location is a code, and location may be an authval. [% Asset.js("js/recalls.js") | $raw %] [% Asset.js("js/coce.js") | $raw %] [% Asset.js("lib/Chocolat/js/chocolat.js") | $raw %] + [% IF ( Cover_Images_Required ) %] + + [% END %] + [% 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 %] -
+
[% IF ( SEARCH_RESULT.title ) %] [% img_title = SEARCH_RESULT.title %] @@ -587,7 +587,21 @@ [% IF OpenLibraryCovers || OpenLibrarySearch %] [% Asset.js("js/openlibrary.js") | $raw %] [% END %] - + [% IF ( Cover_Images_Required ) %] + + [% END %]