Bugzilla – Attachment 73401 Details for
Bug 18421
Make Coce cover images available for staff search
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug18421 - Add Coce to the staff intranet
Bug18421---Add-Coce-to-the-staff-intranet.patch (text/plain), 21.71 KB, created by
Charles Farmer
on 2018-03-28 17:47:13 UTC
(
hide
)
Description:
Bug18421 - Add Coce to the staff intranet
Filename:
MIME Type:
Creator:
Charles Farmer
Created:
2018-03-28 17:47:13 UTC
Size:
21.71 KB
patch
obsolete
>From 46891abf1415f841a72ed2a153678dd1d00557f7 Mon Sep 17 00:00:00 2001 >From: Charles Farmer <charles.farmer@inLibro.com> >Date: Mon, 19 Feb 2018 23:32:25 -0500 >Subject: [PATCH] Bug18421 - Add Coce to the staff intranet > >TEST PLAN: > 1) Apply the patch with git-bz > 2) Run updatedatabase.pl > 2.1) Console output should confirm database modification > 3) Visit the 'Enhanced Content' tab of admin/syspref > 3.1) ressource is /cgi-bin/koha/admin/preferences.pl?tab=enhanced_content > 3.2) You should see that the previous preference, Coce, is now CoceOPAC, > and that a new preference was added, CoceIntranet > 4) Activate CoceIntranet > 5) Do a search for a book for which you have a Coce cover > 5.1) The cover image url should now point to a provider you defined in Coce > 5.2) Your Coce log should show a query > 6) Click on the book's name to visit the detail.pl page > 6.1) The book's cover should also be provided by Coce on that page > >Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com> >--- > C4/Auth.pm | 6 ++- > .../atomicupdate/bug_18421_add_coce_intranet.perl | 30 +++++++++++++++ > installer/data/mysql/sysprefs.sql | 3 +- > .../admin/preferences/enhanced_content.pref | 10 ++++- > .../prog/en/modules/catalogue/detail.tt | 31 ++++++++++++++-- > .../prog/en/modules/catalogue/results.tt | 20 +++++++++- > koha-tmpl/intranet-tmpl/prog/js/coce.js | 43 ++++++++++++++++++++++ > .../bootstrap/en/includes/opac-bottom.inc | 2 +- > .../bootstrap/en/includes/shelfbrowser.inc | 2 +- > .../opac-tmpl/bootstrap/en/modules/opac-detail.tt | 8 ++-- > .../opac-tmpl/bootstrap/en/modules/opac-results.tt | 4 +- > 11 files changed, 142 insertions(+), 17 deletions(-) > create mode 100755 installer/data/mysql/atomicupdate/bug_18421_add_coce_intranet.perl > create mode 100644 koha-tmpl/intranet-tmpl/prog/js/coce.js > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index 13c4652..277cd7f 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -501,7 +501,11 @@ sub get_template_and_user { > EnableBorrowerFiles => C4::Context->preference('EnableBorrowerFiles'), > UseKohaPlugins => C4::Context->preference('UseKohaPlugins'), > UseCourseReserves => C4::Context->preference("UseCourseReserves"), >- useDischarge => C4::Context->preference('useDischarge') >+ useDischarge => C4::Context->preference('useDischarge'), >+ KOHA_VERSION => C4::Context->preference('Version'), >+ CoceIntranet => C4::Context->preference('CoceIntranet'), >+ CoceProviders => C4::Context->preference('CoceProviders'), >+ CoceHost => C4::Context->preference('CoceHost'), > ); > } > else { >diff --git a/installer/data/mysql/atomicupdate/bug_18421_add_coce_intranet.perl b/installer/data/mysql/atomicupdate/bug_18421_add_coce_intranet.perl >new file mode 100755 >index 0000000..74aef50 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_18421_add_coce_intranet.perl >@@ -0,0 +1,30 @@ >+#! /usr/bin/perl >+ >+use strict; >+use warnings; >+use C4::Context; >+use Data::Dumper; >+my $dbh=C4::Context->dbh; >+ >+################# >+# Coce intranet # >+################# >+ >+# validate systempreferences.Coce and save the config for CoceOpac >+my $select = "SELECT * FROM systempreferences WHERE variable = 'Coce'"; >+my $sth = $dbh->prepare($select); >+$sth->execute; >+my $rows = $sth->fetchall_hashref(['variable']); >+my $current_coce_pref = 0; >+if ($rows and $rows->{Coce} and $rows->{Coce}->{value}) { >+ $current_coce_pref = $rows->{Coce}->{value}; >+} >+ >+# add two new systempreferences in order to have distinct behavior between intranet and OPAC >+$dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES >+ ('CoceIntranet','0', NULL, 'If on, enables cover retrieval from the configured Coce server in the staff intranet', 'YesNo'), >+ ('CoceOPAC','$current_coce_pref', NULL, 'If on, enables cover retrieval from the configured Coce server in the OPAC', 'YesNo') >+ ;") or die "Impossible d\'executer cam5446_ajouter_coce_intranet: erreur lors de l'ajout des nouvelles prefs: ". $dbh->errstr . "\n"; >+$dbh->do("DELETE FROM systempreferences WHERE variable = 'Coce';") >+ or die "Impossible d\'executer cam5446_ajouter_coce_intranet: erreur lors de la suppression de la préférence 'Coce': ". $dbh->errstr . "\n"; >+print "cam5446: Add Coce image cache to the staff intranet.\n"; >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index b9c2e4e..bdd5a33 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -108,7 +108,8 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('CircControl','ItemHomeLibrary','PickupLibrary|PatronLibrary|ItemHomeLibrary','Specify the agency that controls the circulation and fines policy','Choice'), > ('CircSidebar','0',NULL,'Activate or deactivate the navigation sidebar on all Circulation pages','YesNo'), > ('ClaimsBccCopy','0','','Bcc the ClaimAcquisition and ClaimIssues alerts','YesNo'), >-('Coce','0', NULL, 'If on, enables cover retrieval from the configured Coce server', 'YesNo'), >+('CoceIntranet','0', NULL, 'If on, enables cover retrieval from the configured Coce server in the staff intranet', 'YesNo'), >+('CoceOPAC','0', NULL, 'If on, enables cover retrieval from the configured Coce server in the OPAC', 'YesNo'), > ('CoceHost', '', NULL, 'Coce server URL', 'Free'), > ('CoceProviders', '', 'aws,gb,ol', 'Coce providers', 'multiple'), > ('COinSinOPACResults','1','','If ON, use COinS in OPAC search results page. NOTE: this can slow down search response time significantly','YesNo'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref >index f62882d..be314f7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/enhanced_content.pref >@@ -374,11 +374,17 @@ Enhanced Content: > - with OverDrive. > Coce Cover images cache: > - >- - pref: Coce >+ - pref: CoceOPAC > choices: > yes: Enable > no: "Don't enable" >- - a Coce image cache service. >+ - a Coce image cache service in the OPAC. >+ - >+ - pref: CoceIntranet >+ choices: >+ yes: Enable >+ no: "Don't enable" >+ - a Coce image cache service in the staff intranet. > - > - Coce server URL > - pref: CoceHost >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 d3b12b4..0de4de0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -64,7 +64,7 @@ > <span class="Z3988" title="[% ocoins %]"></span> > [% END %] > >- [% IF ( AmazonCoverImages || LocalCoverImages ) %] >+ [% IF ( AmazonCoverImages || LocalCoverImages || CoceIntranet ) %] > [% IF ( XSLTDetailsDisplay ) %] > <div class="yui-gc"> > <div id="catalogue_detail_biblio" class="yui-u first"> >@@ -125,7 +125,7 @@ > </span> > [% END %] > >- [% IF ( AmazonCoverImages || LocalCoverImages ) %] >+ [% IF ( AmazonCoverImages || LocalCoverImages || CoceIntranet ) %] > </div><div class="yui-u" id="bookcoverimg"> > [% IF ( LocalCoverImages ) %] > <div title="[% biblionumber |url %]" class="[% biblionumber %]" id="local-thumbnail-preview"></div> >@@ -136,6 +136,16 @@ > <img src="https://images-na.ssl-images-amazon.com/images/P/[% normalized_isbn %].01.MZZZZZZZ.jpg" alt="" /> > </a></div> > [% END %] >+ [% IF ( CoceIntranet && CoceProviders ) %] >+ [% coce_id = normalized_ean || normalized_isbn %] >+ <a class="p1" href="/cgi-bin/koha/catalogue/[% DetailPage %]?biblionumber=[% biblionumber |url %]"> >+ [% IF ( coce_id ) %] >+ <span style="block" title="[% biblionumber |url %]" class="[% coce_id %]" id="coce-thumbnail-preview"></span> >+ [% ELSE %] >+ <span class="no-image">No cover image available</span> >+ [% END %] >+ </a> >+ [% END %] > [% END %] > [% ELSE %] > >@@ -199,7 +209,7 @@ > </ul> > </div> > >- [% IF ( AmazonCoverImages || LocalCoverImages ) %] >+ [% IF ( AmazonCoverImages || LocalCoverImages || CoceIntranet ) %] > <div class="yui-u" id="bookcoverimg"> > [% IF ( LocalCoverImages ) %] > <div title="[% biblionumber |url %]" class="[% biblionumber %]" id="local-thumbnail-preview"></div> >@@ -211,6 +221,16 @@ > </a> > </div> > [% END %] >+ [% IF ( CoceIntranet && CoceProviders ) %] >+ [% coce_id = normalized_ean || normalized_isbn %] >+ <a class="p1" href="/cgi-bin/koha/catalogue/[% DetailPage %]?biblionumber=[% biblionumber |url %]"> >+ [% IF ( coce_id ) %] >+ <span style="block" title="[% biblionumber |url %]" class="[% coce_id %]" id="coce-thumbnail-preview"></span> >+ [% ELSE %] >+ <span class="no-image">No cover image available</span> >+ [% END %] >+ </a> >+ [% END %] > </div> > [% END %] > >@@ -848,6 +868,7 @@ > [% INCLUDE 'catalog-strings.inc' %] > <script type="text/javascript" src="[% interface %]/[% theme %]/js/catalog_[% KOHA_VERSION %].js"></script> > [% INCLUDE 'greybox.inc' %] >+ <script type="text/javascript" src="[% interface %]/prog/js/coce_[% KOHA_VERSION %].js"></script> > <script type="text/javascript"> > // http://www.oreillynet.com/pub/a/javascript/2003/10/21/amazonhacks.html > function verify_images() { >@@ -1003,6 +1024,10 @@ > [% IF LocalCoverImages %] > KOHA.LocalCover.GetCoverFromBibnumber(true); > [% END %] >+ [% IF ( CoceIntranet && CoceProviders ) %] >+ KOHA.coce.getURL('[% CoceHost %]', '[% CoceProviders %]'); >+ [% END %] >+ > $("body").on("click",".previewMARC", function(e){ > e.preventDefault(); > var page = $(this).attr("href"); >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 459bc08..ac4cb9a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >@@ -351,7 +351,7 @@ > <!-- TABLE RESULTS START --> > <table> > <tr> >- [% IF ( AmazonCoverImages || LocalCoverImages ) %]<th> </th>[% END %] >+ [% IF ( AmazonCoverImages || LocalCoverImages || CoceIntranet ) %]<th> </th>[% END %] > <th colspan="2">Results</th> > <th>Location</th> > </tr> >@@ -359,7 +359,7 @@ > [% SET MaxSearchResultsItemsPerRecordStatusCheck = Koha.Preference('MaxSearchResultsItemsPerRecordStatusCheck') %] > [% FOREACH SEARCH_RESULT IN SEARCH_RESULTS %] > <tr> >- [% IF ( AmazonCoverImages || LocalCoverImages ) %] >+ [% IF ( AmazonCoverImages || LocalCoverImages || CoceIntranet ) %] > <td> > [% IF ( LocalCoverImages) %] > <a class="p1" href="/cgi-bin/koha/catalogue/[% DetailPage %]?biblionumber=[% SEARCH_RESULT.biblionumber |url %]"> >@@ -376,6 +376,17 @@ > [% END %] > </a> > [% END %] >+ [% IF ( CoceIntranet && CoceProviders ) %] >+ [% coce_id = SEARCH_RESULT.normalized_ean || SEARCH_RESULT.normalized_isbn %] >+ <a class="p1" href="/cgi-bin/koha/catalogue/[% DetailPage %]?biblionumber=[% SEARCH_RESULT.biblionumber |url %]"> >+ [% IF ( coce_id ) %] >+ <span style="block" title="[% SEARCH_RESULT.biblionumber |url %]" class="[% coce_id %]" id="coce-thumbnail[% loop.count %]"></span> >+ [% ELSE %] >+ <span class="no-image">No cover image available</span> >+ [% END %] >+ </a> >+ [% END %] >+ > </td> > [% END %] > <td> >@@ -625,6 +636,7 @@ > <script type="text/javascript" src="[% interface %]/js/browser_[% KOHA_VERSION %].js"></script> > <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.fixFloat_[% KOHA_VERSION %].js"></script> > <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min_[% KOHA_VERSION %].js"></script> >+ <script type="text/javascript" src="[% interface %]/prog/js/coce_[% KOHA_VERSION %].js"></script> > <script type="text/javascript"> > var MSG_NO_ITEM_SELECTED = _("Nothing is selected."); > var MSG_NON_RESERVES_SELECTED = _("One or more selected items cannot be placed on hold."); >@@ -750,6 +762,10 @@ > KOHA.LocalCover.LoadResultsCovers(); > [% END %] > >+ [% IF ( CoceIntranet && CoceProviders ) %] >+ KOHA.coce.getURL('[% CoceHost %]', '[% CoceProviders %]'); >+ [% END %] >+ > $("#select_all").on("click",function(e){ > e.preventDefault(); > selectAll(); >diff --git a/koha-tmpl/intranet-tmpl/prog/js/coce.js b/koha-tmpl/intranet-tmpl/prog/js/coce.js >new file mode 100644 >index 0000000..95669a0 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/js/coce.js >@@ -0,0 +1,43 @@ >+if (KOHA === undefined || !KOHA) { var KOHA = {}; } >+ >+ >+/** >+ * A namespace for Coce cover images cache >+ */ >+KOHA.coce = { >+ >+ /** >+ * Search all: >+ * <div title="biblionumber" id="isbn" class="coce-thumbnail"></div> >+ * or >+ * <div title="biblionumber" id="isbn" class="coce-thumbnail-preview"></div> >+ * and run a search with all collected isbns to coce cover service. >+ * The result is asynchronously returned, and used to append <img>. >+ */ >+ getURL: function(host,provider,newWindow) { >+ var ids = []; >+ $("[id^=coce-thumbnail]").each(function(i) { >+ var id = $(this).attr("class"); // id=isbn >+ if ( id !== '' ) { ids.push(id); } >+ }); >+ if (ids.length == 0) return; >+ ids = ids.join(','); >+ var coceURL = host + '/cover?id=' + ids + '&provider=' + provider; >+ $.ajax({ >+ url: coceURL, >+ dataType: 'jsonp', >+ success: function(urlPerID){ >+ for (var id in urlPerID) { >+ var url = urlPerID[id]; >+ $("[id^=coce-thumbnail]."+id).each(function() { >+ var img = document.createElement("img"); >+ img.src = url; >+ img.title = url; //FIXME: to delete >+ $(this).html(img); >+ }); >+ } >+ } >+ }); >+ } >+ >+}; >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >index 8827242..1c2eb41 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >@@ -193,7 +193,7 @@ $.widget.bridge('uitooltip', $.ui.tooltip); > //]]> > </script> > [% END %] >-[% IF ( Koha.Preference('Coce') && Koha.Preference('CoceProviders') ) %] >+[% IF ( Koha.Preference('CoceOPAC') && Koha.Preference('CoceProviders') ) %] > <script type="text/javascript" src="[% interface %]/[% theme %]/js/coce_[% KOHA_VERSION %].js"></script> > <script type="text/javascript"> > //<![CDATA[ >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/shelfbrowser.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/shelfbrowser.inc >index 161f279..e427b78 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/shelfbrowser.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/shelfbrowser.inc >@@ -53,7 +53,7 @@ > <span class="no-image">No cover image available</span> > [% END %] > [% END %] >- [% IF ( Koha.Preference('Coce') && Koha.Preference('CoceProviders') ) %] >+ [% IF ( Koha.Preference('CoceOPAC') && Koha.Preference('CoceProviders') ) %] > [% coce_id = item.browser_normalized_ean || item.browser_normalized_isbn %] > <div title="[% item.biblionumber |url %]" class="[% coce_id %]" id="coce-thumbnail-preview-[% coce_id %]"></div> > [% END %] >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 c688a3f..c8f4729 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >@@ -85,7 +85,7 @@ > [% IF ( GoogleJackets ) %] > <div title="[% biblio.biblionumber %]" class="[% normalized_isbn %]" id="gbs-thumbnail-preview"></div> > [% END %] >- [% IF ( Koha.Preference('Coce') && Koha.Preference('CoceProviders') ) %] >+ [% IF ( Koha.Preference('CoceOPAC') && Koha.Preference('CoceProviders') ) %] > [% coce_id = normalized_ean || normalized_isbn %] > <div style="block" title="[% biblio.biblionumber %]" class="[% coce_id %]" id="coce-thumbnail-preview"></div> > [% END %] >@@ -1541,7 +1541,7 @@ > [% IF ( GoogleJackets ) %] > KOHA.Google.GetCoverFromIsbn([% covernewwindow %]); > [% END %] >- [% IF ( Koha.Preference('Coce') && Koha.Preference('CoceProviders') ) %] >+ [% IF ( Koha.Preference('CoceOPAC') && Koha.Preference('CoceProviders') ) %] > KOHA.coce.getURL('[% Koha.Preference('CoceHost') %]', '[% Koha.Preference('CoceProviders') %]',[% covernewwindow %]); > [% END %] > >@@ -1616,7 +1616,7 @@ > [% IF ( GoogleJackets ) %] > KOHA.Google.GetCoverFromIsbn([% covernewwindow %]); > [% END %] >- [% IF ( Koha.Preference('Coce') && Koha.Preference('CoceProviders') ) %] >+ [% IF ( Koha.Preference('CoceOPAC') && Koha.Preference('CoceProviders') ) %] > KOHA.coce.getURL('[% Koha.Preference('CoceHost') %]', '[% Koha.Preference('CoceProviders') %]',[% covernewwindow %]); > [% END %] > [% IF OpenLibraryCovers %] >@@ -1642,7 +1642,7 @@ > [% IF ( GoogleJackets ) %] > KOHA.Google.GetCoverFromIsbn([% covernewwindow %]); > [% END %] >- [% IF ( Koha.Preference('Coce') && Koha.Preference('CoceProviders') ) %] >+ [% IF ( Koha.Preference('CoceOPAC') && Koha.Preference('CoceProviders') ) %] > KOHA.coce.getURL('[% Koha.Preference('CoceHost') %]', '[% Koha.Preference('CoceProviders') %]',[% covernewwindow %]); > [% END %] > [% IF OpenLibraryCovers %] >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 36211c9..fb74412 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >@@ -255,7 +255,7 @@ > [% END %] > [% END %] > >- [% IF ( Koha.Preference('Coce') && Koha.Preference('CoceProviders') ) %] >+ [% IF ( Koha.Preference('CoceOPAC') && Koha.Preference('CoceProviders') ) %] > [% coce_id = SEARCH_RESULT.normalized_ean || SEARCH_RESULT.normalized_isbn %] > [% IF ( coce_id ) %] > <span style="block" title="[% SEARCH_RESULT.biblionumber |url %]" class="[% coce_id %]" id="coce-thumbnail[% loop.count %]"></span> >@@ -973,7 +973,7 @@ $(document).ready(function(){ > [% IF OpenLibraryCovers %]KOHA.OpenLibrary.GetCoverFromIsbn();[% END %] > [% IF OPACLocalCoverImages %]KOHA.LocalCover.GetCoverFromBibnumber(false);[% END %] > [% IF ( GoogleJackets ) %]KOHA.Google.GetCoverFromIsbn();[% END %] >-[% IF ( Koha.Preference('Coce') && Koha.Preference('CoceProviders') ) %] >+[% IF ( Koha.Preference('CoceOPAC') && Koha.Preference('CoceProviders') ) %] > KOHA.coce.getURL('[% Koha.Preference('CoceHost') %]', '[% Koha.Preference('CoceProviders') %]'); > [% END %] > >-- >2.7.4
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 18421
:
71322
|
71977
|
72772
|
73401
|
73495
|
74252
|
77597
|
77598
|
77599
|
77764
|
77765
|
80137
|
80138
|
80139
|
83633
|
83634
|
83635
|
83636
|
91552
|
91553
|
91554
|
91555
|
91786
|
91787
|
91788
|
91789
|
93654
|
93655
|
93656
|
93657