Bugzilla – Attachment 147992 Details for
Bug 32680
Add hooks to allow cover images to be provided by plugins
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32680: Add hooks to allow cover art to come from plugins
Bug-32680-Add-hooks-to-allow-cover-art-to-come-fro.patch (text/plain), 12.40 KB, created by
Martin Renvoize (ashimema)
on 2023-03-09 10:49:14 UTC
(
hide
)
Description:
Bug 32680: Add hooks to allow cover art to come from plugins
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2023-03-09 10:49:14 UTC
Size:
12.40 KB
patch
obsolete
>From 3f0baac90ea7bc7829c71821b30474658a23e086 Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >Date: Thu, 19 Jan 2023 14:21:38 +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 >--- > catalogue/detail.pl | 5 +++++ > catalogue/search.pl | 5 +++++ > .../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 +++++ > 8 files changed, 66 insertions(+), 9 deletions(-) > >diff --git a/catalogue/detail.pl b/catalogue/detail.pl >index 905120ec9d..8ee5b33dfe 100755 >--- a/catalogue/detail.pl >+++ b/catalogue/detail.pl >@@ -686,4 +686,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 bf225911ef..68e75eba49 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/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >index 707a5d7cf3..306680a846 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 @@ > <span class="Z3988" title="[% ocoins | html %]"></span> > [% 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')) ) %] > <div id="catalogue_detail_biblio" class="col-xs-9"> > [% ELSE %] > <div id="catalogue_detail_biblio" class="col-xs-12"> >@@ -204,10 +204,10 @@ > [% END %] > </div> [%# .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')) ) %] > </div> > <div class="col-xs-3 bookcoverimg"> >- <div id="biblio-cover-slider" class="cover-slider"> >+ <div id="biblio-cover-slider" class="cover-slider cover_images_required"> > [% IF ( LocalCoverImages ) %] > [% IF localimages.count %] > [% FOREACH image IN localimages %] >@@ -1461,6 +1461,11 @@ Note that permanent location is a code, and location may be an authval. > </script> > [% Asset.js("js/modals/display_ticket.js") | $raw %] > [% END %] >+ [% IF ( Cover_Images_Required ) %] >+ <script> >+ var normalized_isbn = "[% normalized_isbn %]"; >+ </script> >+ [% END %] > <script> > var interface = "[% interface | html %]"; > var theme = "[% theme | html %]"; >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 ba3c7bc778..aef17698e6 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 @@ > <table> > <thead> > <tr> >- [% IF ( AmazonCoverImages || LocalCoverImages || ( SyndeticsCovers ) || (Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL')) ) %] >+ [% IF ( Cover_Images_Required || AmazonCoverImages || LocalCoverImages || ( SyndeticsCovers ) || (Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL')) ) %] > <th> </th> > [% END %] > <th colspan="2">Results</th> >@@ -461,9 +461,9 @@ > <tbody> > [% FOREACH SEARCH_RESULT IN SEARCH_RESULTS %] > <tr id="row[% SEARCH_RESULT.biblionumber | html %]"> >- [% 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')) ) %] > <td class="bookcoverimg"> >- <div id="cover-slides-[% SEARCH_RESULT.biblionumber | html %]" class="cover-slides" data-biblionumber="[% SEARCH_RESULT.biblionumber | html %]"> >+ <div id="cover-slides-[% SEARCH_RESULT.biblionumber | html %]" class="cover-slides search_cover_images_required" data-biblionumber="[% SEARCH_RESULT.biblionumber | html %]"> > [% IF ( LocalCoverImages ) %][% SEARCH_RESULT.localimage | html %] > <div id="local-coverimg-[% SEARCH_RESULT.biblionumber | html %]" class="cover-image local-coverimg"> > <a href="[% PROCESS biblio_a_href biblionumber => SEARCH_RESULT.biblionumber %]"> >@@ -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 ) %] >+ <script> >+ const search_results = {}; >+ [% FOREACH SEARCH_RESULT IN SEARCH_RESULTS %] >+ var cover_index = "[% loop.count %]"; >+ search_results[cover_index] = {}; >+ search_results[cover_index].isbn = "[% SEARCH_RESULT.normalized_isbn | html %]"; >+ search_results[cover_index].biblionumber = "[% SEARCH_RESULT.biblionumber | html %]"; >+ search_results[cover_index].processedBiblio = "[% PROCESS biblio_a_href biblionumber => SEARCH_RESULT.biblionumber | html %]" >+ [% END %] >+ </script> >+ [% END %] > <script> > var PREF_AmazonCoverImages = parseInt( "[% Koha.Preference('AmazonCoverImages') | html %]", 10); > var q_array = new Array(); // will hold search terms, if present >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >index ab2f28e615..6359fc79c7 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >@@ -59,7 +59,7 @@ > > <div class="bookcover"> > >- <div id="biblio-cover-slider" class="cover-slider"> >+ <div id="biblio-cover-slider" class="cover-slider cover_images_required"> > [% IF ( OPACLocalCoverImages ) %] > [% IF localimages.count %] > [% FOREACH image IN localimages %] >@@ -1454,6 +1454,12 @@ > [% Asset.js("js/ratings.js") | $raw %] > [% END %] > >+ [% IF ( Cover_Images_Required ) %] >+ <script> >+ var normalized_isbn = "[% normalized_isbn %]"; >+ </script> >+ [% 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 95fa8d6304..da5284f5cc 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 %] > <td class="bibliocol"> >- <div class="coverimages itemtype_[% SEARCH_RESULT.itemtype | html %]"> >+ <div class="coverimages search_cover_images_required itemtype_[% SEARCH_RESULT.itemtype | html %]"> > <a class="p1" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% SEARCH_RESULT.biblionumber | uri %]"> > [% 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 ) %] >+ <script> >+ const search_results = {}; >+ [% FOREACH SEARCH_RESULT IN SEARCH_RESULTS %] >+ var cover_index = "[% loop.count %]"; >+ search_results[cover_index] = {}; >+ search_results[cover_index].isbn = "[% SEARCH_RESULT.normalized_isbn | html %]"; >+ [% IF SEARCH_RESULT.img_title %] >+ search_results[cover_index].img_title = "[% SEARCH_RESULT.img_title | html %]"; >+ [% ELSE %] >+ search_results[cover_index].img_title = "[% SEARCH_RESULT.biblionumber | html %]"; >+ [% END %] >+ [% END %] >+ </script> >+ [% END %] > <script> > [% IF ( Koha.Preference( 'opacuserlogin' ) == 1 ) && ( Koha.Preference( 'OPACHoldRequests' ) == 1 ) %] > function holdMultiple() { >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index 98c4f94a8c..3ff5b91def 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -1242,4 +1242,9 @@ if ( C4::Context->preference('OPACAuthorIdentifiers') ) { > $template->param( author_identifiers => \@author_identifiers ); > } > >+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 ) >+} >+ > output_html_with_http_headers $query, $cookie, $template->output; >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index 65904676d1..2698474756 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -924,5 +924,10 @@ if ($offset == 0) { > $template->param(firstPage => 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 ) >+} >+ > $template->param( borrowernumber => $borrowernumber); > output_with_http_headers $cgi, $cookie, $template->output, $content_type; >-- >2.39.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 32680
:
145457
|
145458
|
145459
|
145474
|
145475
|
145898
|
145899
|
146695
|
147992
|
147993
|
147996
|
147997
|
148129
|
148158
|
148159
|
149868
|
149869
|
149886
|
149887
|
149888
|
149889
|
151191
|
151192
|
151193