From: Chris Cormack <ch...@bigballofwax.co.nz>

Signed-off-by: Nicole C. Engard <neng...@bywatersolutions.com>
---
 C4/Auth.pm                                         |    1 +
 installer/data/mysql/de-DE/mandatory/sysprefs.sql  |    1 +
 installer/data/mysql/en/mandatory/sysprefs.sql     |    1 +
 .../1-Obligatoire/unimarc_standard_systemprefs.sql |    1 +
 installer/data/mysql/it-IT/necessari/sysprefs.sql  |    1 +
 .../data/mysql/nb-NO/1-Obligatorisk/sysprefs.sql   |    1 +
 installer/data/mysql/pl-PL/mandatory/sysprefs.sql  |    1 +
 ...m_preferences_full_optimal_for_install_only.sql |    1 +
 ...m_preferences_full_optimal_for_install_only.sql |    1 +
 .../admin/preferences/enhanced_content.pref        |    7 ++
 .../opac-tmpl/prog/en/includes/doc-head-close.inc  |   12 +++-
 koha-tmpl/opac-tmpl/prog/en/js/openlibrary.js      |   70 ++++++++++++++++++++
 .../opac-tmpl/prog/en/modules/opac-results.tt      |    2 +
 13 files changed, 99 insertions(+), 1 deletions(-)
 create mode 100644 koha-tmpl/opac-tmpl/prog/en/js/openlibrary.js

diff --git a/C4/Auth.pm b/C4/Auth.pm
index f580e53..495f04c 100644
--- a/C4/Auth.pm
+++ b/C4/Auth.pm
@@ -338,6 +338,7 @@ sub get_template_and_user {
             "BiblioDefaultView".C4::Context->preference("BiblioDefaultView")   
      => 1,
             EnhancedMessagingPreferences => 
C4::Context->preference('EnhancedMessagingPreferences'),
             GoogleJackets                => 
C4::Context->preference("GoogleJackets"),
+           OpenLibraryCovers            => 
C4::Context->preference("OpenLibraryCovers"),
             KohaAdminEmailAddress        => "" . 
C4::Context->preference("KohaAdminEmailAddress"),
             LoginBranchcode              => 
(C4::Context->userenv?C4::Context->userenv->{"branch"}:"insecure"),
             LoginFirstname               => 
(C4::Context->userenv?C4::Context->userenv->{"firstname"}:"Bel"),
diff --git a/installer/data/mysql/de-DE/mandatory/sysprefs.sql 
b/installer/data/mysql/de-DE/mandatory/sysprefs.sql
index 6eb67a3..dcee089 100755
--- a/installer/data/mysql/de-DE/mandatory/sysprefs.sql
+++ b/installer/data/mysql/de-DE/mandatory/sysprefs.sql
@@ -314,3 +314,4 @@ INSERT INTO `systempreferences` 
(variable,value,explanation,options,type) VALUES
 INSERT INTO systempreferences (variable,value,explanation,options,type) 
VALUES('OpacHiddenItems' ,'','This syspref allows to define custom rules for 
hiding specific items at opac. See docs/opac/O    pacHiddenItems.txt for more 
informations.','','Textarea');
 INSERT INTO systempreferences (variable,value,explanation,options,type) 
VALUES('numSearchRSSResults',50,'Specify the maximum number of results to 
display on a RSS page of results',NULL,'Integer');
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES 
('OpacRenewalBranch','checkoutbranch','Choose how the branch for an OPAC 
renewal is recorded in 
statistics','itemhomebranch|patronhomebranch|checkoutbranch|null','Choice');
+INSERT INTO systempreferences (variable,value,explanation,options,type) 
VALUES('OpenLibraryCovers',0, 'If ON Openlibrary book covers will be 
show',NULL,'YesNo');
diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql 
b/installer/data/mysql/en/mandatory/sysprefs.sql
index 0abf9d8..97b86ca 100755
--- a/installer/data/mysql/en/mandatory/sysprefs.sql
+++ b/installer/data/mysql/en/mandatory/sysprefs.sql
@@ -314,3 +314,4 @@ INSERT INTO `systempreferences` 
(variable,value,explanation,options,type) VALUES
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) 
VALUES('OpacHiddenItems','','This syspref allows to define custom rules for 
hiding specific items at opac. See docs/opac/OpacHiddenItems.txt for more 
informations.','','Textarea');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) 
VALUES('numSearchRSSResults',50,'Specify the maximum number of results to 
display on a RSS page of results',NULL,'Integer');
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES 
('OpacRenewalBranch','checkoutbranch','Choose how the branch for an OPAC 
renewal is recorded in 
statistics','itemhomebranch|patronhomebranch|checkoutbranch|null','Choice');
+INSERT INTO systempreferences (variable,value,explanation,options,type) 
VALUES('OpenLibraryCovers',0,'If ON Openlibrary book covers will be 
show',NULL,'YesNo');
diff --git 
a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql 
b/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
index 59a258f..1cda1bc 100755
--- a/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
+++ b/installer/data/mysql/fr-FR/1-Obligatoire/unimarc_standard_systemprefs.sql
@@ -315,3 +315,4 @@ INSERT INTO `systempreferences` 
(variable,value,explanation,options,type) VALUES
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) 
VALUES('OpacHiddenItems','','This syspref allows to define custom rules for 
hiding specific items at opac. See docs/opac/OpacHiddenItems.txt for more 
informations.','','Textarea');
 INSERT INTO systempreferences (variable,value,explanation,options,type) 
VALUES('numSearchRSSResults',50,'Specify the maximum number of results to 
display on a RSS page of results',NULL,'Integer');
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES 
('OpacRenewalBranch','checkoutbranch','Choose how the branch for an OPAC 
renewal is recorded in 
statistics','itemhomebranch|patronhomebranch|checkoutbranch|null','Choice');
+INSERT INTO systempreferences (variable,value,explanation,options,type) 
VALUES('OpenLibraryCovers',0,'If ON Openlibrary book covers will be 
show',NULL,'YesNo');
diff --git a/installer/data/mysql/it-IT/necessari/sysprefs.sql 
b/installer/data/mysql/it-IT/necessari/sysprefs.sql
index dcdf0ee..87c8a36 100755
--- a/installer/data/mysql/it-IT/necessari/sysprefs.sql
+++ b/installer/data/mysql/it-IT/necessari/sysprefs.sql
@@ -301,3 +301,4 @@ INSERT INTO `systempreferences` 
(variable,value,explanation,options,type) VALUES
 INSERT INTO systempreferences (variable,value,explanation,options,type) 
VALUES('OpacHiddenItems','','This syspref allows to define custom rules for 
hiding specific items at opac. See docs/opac/O    pacHiddenItems.txt for more 
informations.','','Textarea');
 INSERT INTO systempreferences (variable,value,explanation,options,type) 
VALUES('numSearchRSSResults',50,'Specify the maximum number of results to 
display on a RSS page of results',NULL,'Integer');
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES 
('OpacRenewalBranch','checkoutbranch','Choose how the branch for an OPAC 
renewal is recorded in 
statistics','itemhomebranch|patronhomebranch|checkoutbranch|null','Choice');
+INSERT INTO systempreferences (variable,value,explanation,options,type) 
VALUES('OpenLibraryCovers',0,'If ON Openlibrary book covers will be 
show',NULL,'YesNo');
diff --git a/installer/data/mysql/nb-NO/1-Obligatorisk/sysprefs.sql 
b/installer/data/mysql/nb-NO/1-Obligatorisk/sysprefs.sql
index ca71769..f9beccc 100644
--- a/installer/data/mysql/nb-NO/1-Obligatorisk/sysprefs.sql
+++ b/installer/data/mysql/nb-NO/1-Obligatorisk/sysprefs.sql
@@ -321,3 +321,4 @@ INSERT INTO systempreferences 
(variable,value,explanation,options,type) VALUES (
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) 
VALUES('OpacFavicon','','Enter a complete URL to an image to replace the 
default Koha favicon on the OPAC','','free');
 INSERT INTO `systempreferences` (variable,value,explanation,options,type) 
VALUES('IntranetFavicon','','Enter a complete URL to an image to replace the 
default Koha favicon on the Staff client','','free');
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES 
('TraceSubjectSubdivisions', '0', 'Create searches on all subdivisions for 
subject tracings.','1','YesNo');
+INSERT INTO systempreferences (variable,value,explanation,options,type) 
VALUES('OpenLibraryCovers',0,'If ON Openlibrary book covers will be 
show',NULL,'YesNo');
diff --git a/installer/data/mysql/pl-PL/mandatory/sysprefs.sql 
b/installer/data/mysql/pl-PL/mandatory/sysprefs.sql
index 58ba035..5ffba65 100755
--- a/installer/data/mysql/pl-PL/mandatory/sysprefs.sql
+++ b/installer/data/mysql/pl-PL/mandatory/sysprefs.sql
@@ -313,3 +313,4 @@ INSERT INTO `systempreferences` 
(variable,value,explanation,options,type) VALUES
 INSERT INTO systempreferences (variable,value,explanation,options,type) 
VALUES('OpacHiddenItems','','This syspref allows to define custom rules for 
hiding specific items at opac. See docs/opac/OpacHiddenItems.txt for more 
informations.','','Textarea');
 INSERT INTO systempreferences (variable,value,explanation,options,type) 
VALUES('numSearchRSSResults',50,'Specify the maximum number of results to 
display on a RSS page of results',NULL,'Integer');
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES 
('OpacRenewalBranch','checkoutbranch','Choose how the branch for an OPAC 
renewal is recorded in 
statistics','itemhomebranch|patronhomebranch|checkoutbranch|null','Choice');
+INSERT INTO systempreferences (variable,value,explanation,options,type) 
VALUES('OpenLibraryCovers',0, 'If ON Openlibrary book covers will be 
show',NULL,'YesNo');
diff --git 
a/installer/data/mysql/ru-RU/mandatory/system_preferences_full_optimal_for_install_only.sql
 
b/installer/data/mysql/ru-RU/mandatory/system_preferences_full_optimal_for_install_only.sql
index 54c533c..6e18599 100755
--- 
a/installer/data/mysql/ru-RU/mandatory/system_preferences_full_optimal_for_install_only.sql
+++ 
b/installer/data/mysql/ru-RU/mandatory/system_preferences_full_optimal_for_install_only.sql
@@ -368,3 +368,4 @@ INSERT INTO `systempreferences` 
(variable,value,explanation,options,type) VALUES
 INSERT INTO systempreferences (variable,value,explanation,options,type) 
VALUES('OpacHiddenItems','','This syspref allows to define custom rules for 
hiding specific items at opac. See docs/opac/OpacHiddenItems.txt for more 
informations.','','Textarea');
 INSERT INTO systempreferences (variable,value,explanation,options,type) 
VALUES('numSearchRSSResults',50,'Specify the maximum number of results to 
display on a RSS page of results',NULL,'Integer');
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES 
('OpacRenewalBranch','checkoutbranch','Choose how the branch for an OPAC 
renewal is recorded in 
statistics','itemhomebranch|patronhomebranch|checkoutbranch|null','Choice');
+INSERT INTO systempreferences (variable,value,explanation,options,type) 
VALUES('OpenLibraryCovers',0,'If ON Openlibrary book covers will be 
show',NULL,'YesNo');
\ No newline at end of file
diff --git 
a/installer/data/mysql/uk-UA/mandatory/system_preferences_full_optimal_for_install_only.sql
 
b/installer/data/mysql/uk-UA/mandatory/system_preferences_full_optimal_for_install_only.sql
index 9f095ab..7284490 100755
--- 
a/installer/data/mysql/uk-UA/mandatory/system_preferences_full_optimal_for_install_only.sql
+++ 
b/installer/data/mysql/uk-UA/mandatory/system_preferences_full_optimal_for_install_only.sql
@@ -393,3 +393,4 @@ INSERT INTO `systempreferences` 
(variable,value,explanation,options,type) VALUES
 INSERT INTO systempreferences (variable,value,explanation,options,type) 
VALUES('OpacHiddenItems','','This syspref allows to define custom rules for 
hiding specific items at opac. See docs/opac/O    pacHiddenItems.txt for more 
informations.','','Textarea');
 INSERT INTO systempreferences (variable,value,explanation,options,type) 
VALUES('numSearchRSSResults',50,'Specify the maximum number of results to 
display on a RSS page of results',NULL,'Integer');
 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES 
('OpacRenewalBranch','checkoutbranch','Choose how the branch for an OPAC 
renewal is recorded in 
statistics','itemhomebranch|patronhomebranch|checkoutbranch|null','Choice');
+INSERT INTO systempreferences (variable,value,explanation,options,type) 
VALUES('OpenLibraryCovers',0, 'If ON Openlibrary book covers will be 
show',NULL,'YesNo');
\ No newline at end of file
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 5367a42..3c334a7 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
@@ -130,6 +130,13 @@ Enhanced Content:
                   yes: Add
                   no: "Don't add"
             - cover images from Google Books to search results and item detail 
pages on the OPAC.
+    OpenLibrary:
+        -
+            - pref: OpenLibraryCovers
+              choices:
+                  yes: Add
+                  no: "Don't add"
+            - cover images from OpenLibrary to search results and item detail 
pages on the OPAC.
     Library Thing:
         # Awkward syntax below, due to quoting conflicts
         -
diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc 
b/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc
index 1ace917..083d0b9 100644
--- a/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc
+++ b/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc
@@ -84,7 +84,17 @@
        var NO_GOOGLE_JACKET = _("No cover image available");
        //]]>
 </script>
-[% END %][% IF ( BakerTaylorEnabled ) %]<script type="text/javascript" 
language="javascript" src="[% themelang %]/js/bakertaylorimages.js"></script>
+[% END %]
+[% IF OpenLibraryCovers %]
+<script type="text/javascript" language="javascript" src="[% themelang 
%]/js/openlibrary.js"></script>
+<script type="text/javascript" language="javascript">
+//<![CDATA[
+var NO_OL_JACKET = _("No cover image available");
+//]]>
+</script>
+[% END %]
+
+[% IF ( BakerTaylorEnabled ) %]<script type="text/javascript" 
language="javascript" src="[% themelang %]/js/bakertaylorimages.js"></script>
 <script type="text/javascript" language="javascript">
        //<![CDATA[
        var NO_BAKERTAYLOR_IMAGE = _("No cover image available");
diff --git a/koha-tmpl/opac-tmpl/prog/en/js/openlibrary.js 
b/koha-tmpl/opac-tmpl/prog/en/js/openlibrary.js
new file mode 100644
index 0000000..1c62e6c
--- /dev/null
+++ b/koha-tmpl/opac-tmpl/prog/en/js/openlibrary.js
@@ -0,0 +1,70 @@
+if (typeof KOHA == "undefined" || !KOHA) {
+    var KOHA = {};
+}
+
+/**
+ * A namespace for OpenLibrary related functions.
+ */
+KOHA.OpenLibrary = {
+
+
+    /**
+     * Search all:
+     *    <div title="biblionumber" id="isbn" 
class="openlibrary-thumbnail"></div>
+     * or
+     *    <div title="biblionumber" id="isbn" 
class="openlibrary-thumbnail-preview"></div>
+     * and run a search with all collected isbns to Open Library Book Search.
+     * The result is asynchronously returned by OpenLibrary and catched by
+     * olCallBack().
+     */
+    GetCoverFromIsbn: function() {
+        var bibkeys = [];
+        $("div [id^=openlibrary-thumbnail]").each(function(i) {
+            bibkeys.push("ISBN:" + $(this).attr("class")); // id=isbn
+        });
+        bibkeys = bibkeys.join(',');
+        var scriptElement = document.createElement("script");
+        scriptElement.setAttribute("id", "jsonScript");
+        scriptElement.setAttribute("src",
+            "http://openlibrary.org/api/books?bibkeys="; + escape(bibkeys) +
+            "&callback=KOHA.OpenLibrary.olCallBack");
+        scriptElement.setAttribute("type", "text/javascript");
+        document.documentElement.firstChild.appendChild(scriptElement);
+
+    },
+
+    /**
+     * Add cover pages <div
+     * and link to preview if div id is gbs-thumbnail-preview
+     */
+    olCallBack: function(booksInfo) {
+       for (id in booksInfo) {
+          var book = booksInfo[id];
+          var isbn = book.bib_key.substring(5);
+          
+          $("."+isbn).each(function() {
+              var a = document.createElement("a");
+              a.href = book.info_url;
+                                     if (typeof(book.thumbnail_url) != 
"undefined") {
+                       var img = document.createElement("img");
+                       img.src = book.thumbnail_url;
+                                               $(this).append(img);
+                  var re = /^openlibrary-thumbnail-preview/;
+                  if ( re.exec($(this).attr("id")) ) {
+                      $(this).append(
+                        '<div style="margin-bottom:5px; 
margin-top:-5px;font-size:9px">' +
+                        '<a href="' + 
+                        book.info_url + 
+                        '">Preview</a></div>' 
+                      );
+                  }
+                               } else {
+                                       var message = 
document.createElement("span");
+                                           $(message).attr("class","no-image");
+                                           $(message).html(NO_OL_JACKET);
+                                           $(this).append(message);
+                                   }
+        });
+      }
+    }
+};
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt 
b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt
index 2047a1b..263201c 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt
@@ -228,6 +228,7 @@ $(document).ready(function(){
         [% END %]
         [% END %]
     [% END %][% END %]
+    [% IF OpenLibraryCovers %]KOHA.OpenLibrary.GetCoverFromIsbn();[% END %]
     [% IF ( GoogleJackets ) %]KOHA.Google.GetCoverFromIsbn();[% END %]
 });
 //]]>
@@ -535,6 +536,7 @@ $(document).ready(function(){
                 <img src="http://www.syndetics.com/index.aspx?isbn=[% 
SEARCH_RESULT.normalized_isbn %]/SC.GIF&amp;client=[% 
SEARCH_RESULT.SyndeticsClientCode %]&amp;type=xw10&amp;upc=[% 
SEARCH_RESULT.normalized_upc %]&amp;oclc=[% SEARCH_RESULT.normalized_oclc %]" 
alt="" class="thumbnail" />[% END %][% END %][% END %]
 
                 [% IF ( GoogleJackets ) %][% IF ( 
SEARCH_RESULT.normalized_isbn ) %]<div style="block" title="[% 
SEARCH_RESULT.biblionumber |url %]" class="[% SEARCH_RESULT.normalized_isbn %]" 
id="gbs-thumbnail[% loop.count %]"></div>[% ELSE %]<span class="no-image">No 
cover image available</span>[% END %][% END %]
+               [% IF OpenLibraryCovers %][% IF SEARCH_RESULT.normalized_isbn 
%]<div style="block" title="[% SEARCH_RESULT.biblionumber %]" class="[% 
SEARCH_RESULT.normalized_isbn %]" id="openlibrary-thumbnail[% loop.count 
%]"></div>[% ELSE %]<span class="no-image">No cover image available</span>[% 
END %][% END %]
                 </a>
                 [% IF ( BakerTaylorEnabled ) %][% IF ( 
SEARCH_RESULT.normalized_isbn ) %]<a href="https://[% BakerTaylorBookstoreURL 
|html %][% SEARCH_RESULT.normalized_isbn %]"><img alt="See Baker &amp; Taylor" 
src="[% BakerTaylorImageURL |html %][% SEARCH_RESULT.normalized_isbn %]" 
/></a>[% ELSE %]<span class="no-image">No cover image available</span>[% END 
%][% END %]
                                </td>
-- 
1.7.2.3

_______________________________________________
Koha-patches mailing list
Koha-patches@lists.koha-community.org
http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-patches
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to