Bugzilla – Attachment 7147 Details for
Bug 1633
Add ability to take book cover images from local img db
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 1633: [SIGNED-OFF] Display local cover images
Bug-1633-SIGNED-OFF-Display-local-cover-images.patch (text/plain), 33.67 KB, created by
Koustubha Kale
on 2012-01-14 08:53:35 UTC
(
hide
)
Description:
Bug 1633: [SIGNED-OFF] Display local cover images
Filename:
MIME Type:
Creator:
Koustubha Kale
Created:
2012-01-14 08:53:35 UTC
Size:
33.67 KB
patch
obsolete
>From acbe2e12f27b9fd41e83a3d4549719580a2efeeb Mon Sep 17 00:00:00 2001 >From: Koustubha Kale <kmkale@anantcorp.com> >Date: Tue, 13 Dec 2011 08:24:23 -0500 >Subject: [PATCH] Bug 1633: [SIGNED-OFF] Display local cover images >Content-Type: text/plain; charset="utf-8" > >This patch adds display of local cover images in the following places: >1. OPAC Results page >2. OPAC Details page >3. Separate image viewer page for the OPAC >4. Intranet Details page >5. Separate image viewer page for the Intranet > >Display in the Details and (OPAC) Results pages is handled via Javascript >rather than via direct embedding, to better handle the situation where most >records have local cover images, but a few do not. > >Local cover images do not currently display in the Intranet Results page > >How to use/test : >Assign user permission to the user Tools > (upload_local_cover_images Upload >local cover images). In order to upload local images, login to the staff >client. Go to Home > Tools > Upload Cover Images. Here you can upload cover >images either singly or in bulk in the form of a zip file. If uploading >singly, click on image file, browse the image from your local disk, type in >the biblio number of the catalogue entry and press upload. If uploading in >bulk as a zip file, the zip file must contain (in addition to cover images) >one text file named either datalink.txt OR idlink.txt. This file should >have mapping of biblionumber to image file name in the zip one per line >with comma or tab as delimiters. For example: > >1, scanned_cover_image_of_bib_no_1.jpg >2, scanned_cover_image_of_bib_no_1.jpg > >Cover images will be resized to a large image of 800x600 and a thumbnail of >200x140. Depending on the setting of AllowMultipleCovers, it is possible to >upload multiple images for a single bibliographic record. However, even if >multiple covers are permitted, you have the option of replacing the existing >covers by checking the "Replace existing covers" option on the upload screen. > >1. The patch adds a menu link in Tools from where you can upload local cover > images >2. It adds a user permission to enable access control to this menu item under > Tools >3. It adds a system preference OPACLocalCoverImages under Enhanced Content. > This needs to be turned on to show local cover images in OPAC. > >Once you have uploaded local images, if you search for the biblio, the local >cover should show up in search as well as search detail pages in the OPAC, and >the details view in the Intranet. > >Koustubha Kale is working on another patch which will allow us to set a cover >image source priority in system preferences, and which will then gracefully >fail over to the next source if image is not available from the first choice >source. > >Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com> >Signed-off-by: Magnus Enger <magnus@enger.priv.no> >Signed-off-by: Koustubha Kale <kmkale@anantcorp.com> >--- > catalogue/detail.pl | 6 + > catalogue/image.pl | 108 ++++++++++++++++++++ > catalogue/imageviewer.pl | 51 +++++++++ > .../intranet-tmpl/prog/en/css/staff-global.css | 3 + > .../prog/en/includes/doc-head-close.inc | 8 ++ > koha-tmpl/intranet-tmpl/prog/en/js/localcovers.js | 44 ++++++++ > .../prog/en/modules/catalogue/detail.tt | 12 ++ > .../prog/en/modules/catalogue/imageviewer.tt | 43 ++++++++ > .../prog/en/modules/tools/upload-images.tt | 2 +- > .../opac-tmpl/prog/en/includes/doc-head-close.inc | 9 ++ > koha-tmpl/opac-tmpl/prog/en/js/localcovers.js | 44 ++++++++ > koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt | 18 ++++ > .../opac-tmpl/prog/en/modules/opac-imageviewer.tt | 43 ++++++++ > .../opac-tmpl/prog/en/modules/opac-results.tt | 2 + > opac/opac-detail.pl | 11 ++ > opac/opac-image.pl | 108 ++++++++++++++++++++ > opac/opac-imageviewer.pl | 51 +++++++++ > opac/opac-search.pl | 4 + > tools/upload-cover-image.pl | 3 +- > 19 files changed, 568 insertions(+), 2 deletions(-) > create mode 100755 catalogue/image.pl > create mode 100755 catalogue/imageviewer.pl > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/js/localcovers.js > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/imageviewer.tt > create mode 100644 koha-tmpl/opac-tmpl/prog/en/js/localcovers.js > create mode 100644 koha-tmpl/opac-tmpl/prog/en/modules/opac-imageviewer.tt > create mode 100755 opac/opac-image.pl > create mode 100755 opac/opac-imageviewer.pl > >diff --git a/catalogue/detail.pl b/catalogue/detail.pl >index 3c95ba2..fcf1f2b 100755 >--- a/catalogue/detail.pl >+++ b/catalogue/detail.pl >@@ -37,6 +37,7 @@ use C4::External::Amazon; > use C4::Search; # enabled_staff_search_views > use C4::VirtualShelves; > use C4::XSLT; >+use C4::Images; > > # use Smart::Comments; > >@@ -384,6 +385,11 @@ if ( C4::Context->preference("AmazonEnabled") == 1 ) { > } > } > >+if ( C4::Context->preference("LocalCoverImages") == 1 ) { >+ my @images = ListImagesForBiblio($biblionumber); >+ $template->{VARS}->{localimages} = \@images; >+} >+ > # Get OPAC URL > if (C4::Context->preference('OPACBaseURL')){ > $template->param( OpacUrl => C4::Context->preference('OPACBaseURL') ); >diff --git a/catalogue/image.pl b/catalogue/image.pl >new file mode 100755 >index 0000000..17621d7 >--- /dev/null >+++ b/catalogue/image.pl >@@ -0,0 +1,108 @@ >+#!/usr/bin/perl >+# >+# based on patronimage.pl >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+# >+# >+# >+ >+use strict; >+use warnings; >+ >+use CGI; #qw(:standard escapeHTML); >+use C4::Context; >+use C4::Images; >+ >+$|=1; >+ >+my $DEBUG = 1; >+my $data = new CGI; >+my $imagenumber; >+ >+=head1 NAME >+ >+image.pl - Script for retrieving and formatting local cover images for display >+ >+=head1 SYNOPSIS >+ >+<img src="image.pl?imagenumber=X" /> >+<img src="image.pl?biblionumber=X" /> >+<img src="image.pl?imagenumber=X&thumbnail=1" /> >+<img src="image.pl?biblionumber=X&thumbnail=1" /> >+ >+=head1 DESCRIPTION >+ >+This script, when called from within HTML and passed a valid imagenumber or >+biblionumber, will retrieve the image data associated with that biblionumber >+if one exists, format it in proper HTML format and pass it back to be displayed. >+If the parameter thumbnail has been provided, a thumbnail will be returned >+rather than the full-size image. When a biblionumber is provided rather than an >+imagenumber, a random image is selected. >+ >+=cut >+ >+if (defined $data->param('imagenumber')) { >+ $imagenumber = $data->param('imagenumber'); >+} elsif (defined $data->param('biblionumber')) { >+ my @imagenumbers = ListImagesForBiblio($data->param('biblionumber')); >+ if (@imagenumbers) { >+ $imagenumber = $imagenumbers[0]; >+ } else { >+ warn "No images for this biblio" if $DEBUG; >+ error(); >+ } >+} else { >+ $imagenumber = shift; >+} >+ >+if ($imagenumber) { >+ warn "imagenumber passed in: $imagenumber" if $DEBUG; >+ my $imagedata = RetrieveImage($imagenumber); >+ >+ error() unless $imagedata; >+ >+ if ($imagedata) { >+ my $image; >+ if ($data->param('thumbnail')) { >+ $image = $imagedata->{'thumbnail'}; >+ } else { >+ $image = $imagedata->{'imagefile'}; >+ } >+ print $data->header (-type => $imagedata->{'mimetype'}, -'Cache-Control' => 'no-store', -expires => 'now', -Content_Length => length ($image)), $image; >+ exit; >+ } else { >+ warn "No image exists for $imagenumber" if $DEBUG; >+ error(); >+ } >+} else { >+ error(); >+} >+ >+error(); >+ >+sub error { >+ print $data->header ( -status=> '404', -expires => 'now' ); >+ exit; >+} >+ >+=head1 AUTHOR >+ >+Chris Nighswonger cnighswonger <at> foundations <dot> edu >+ >+modified for local cover images by Koustubha Kale kmkale <at> anantcorp <dot> com >+ >+=cut >diff --git a/catalogue/imageviewer.pl b/catalogue/imageviewer.pl >new file mode 100755 >index 0000000..395e4b7 >--- /dev/null >+++ b/catalogue/imageviewer.pl >@@ -0,0 +1,51 @@ >+#!/usr/bin/perl >+ >+# Copyright 2011 C & P Bibliography Services >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use strict; >+use warnings; >+ >+use CGI; >+use C4::Auth; >+use C4::Biblio; >+use C4::Output; >+use C4::Images; >+ >+my $query = new CGI; >+my ( $template, $borrowernumber, $cookie ) = get_template_and_user( >+ { >+ template_name => "catalogue/imageviewer.tmpl", >+ query => $query, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => { catalogue => 1 }, >+ } >+); >+ >+my $biblionumber = $query->param('biblionumber') || $query->param('bib'); >+my ($count, $biblio) = GetBiblio($biblionumber); >+ >+if (C4::Context->preference("LocalCoverImages")) { >+ my @images = ListImagesForBiblio($biblionumber); >+ $template->{VARS}->{'LocalCoverImages'} = 1; >+ $template->{VARS}->{'images'} = \@images; >+} >+ >+$template->{VARS}->{'biblio'} = $biblio; >+ >+output_html_with_http_headers $query, $cookie, $template->output; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css >index 9eb7fa2..30334ef 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css >+++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css >@@ -2133,3 +2133,6 @@ div.pager input.pagedisplay { > font-weight: bold; > text-align : center; > } >+.localimage { >+ padding: .3em; >+} >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc >index 6a2dae0..53f6843 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc >@@ -99,3 +99,11 @@ > [% IF ( virtualshelves || intranetbookbag ) %] > <script type="text/javascript" language="javascript" src="[% themelang %]/js/basket.js"></script> > [% END %] >+[% IF LocalCoverImages %] >+<script type="text/javascript" language="javascript" src="[% themelang %]/js/localcovers.js"></script> >+<script type="text/javascript" language="javascript"> >+//<![CDATA[ >+var NO_LOCAL_JACKET = _("No cover image available"); >+//]]> >+</script> >+[% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/localcovers.js b/koha-tmpl/intranet-tmpl/prog/en/js/localcovers.js >new file mode 100644 >index 0000000..981af75 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/js/localcovers.js >@@ -0,0 +1,44 @@ >+if (typeof KOHA == "undefined" || !KOHA) { >+ var KOHA = {}; >+} >+ >+/** >+ * A namespace for local cover related functions. >+ */ >+KOHA.LocalCover = { >+ >+ >+ /** >+ * 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(). >+ */ >+ GetCoverFromBibnumber: function(uselink) { >+ $("div [id^=local-thumbnail]").each(function(i) { >+ var mydiv = this; >+ var message = document.createElement("span"); >+ $(message).attr("class","no-image"); >+ $(message).html(NO_LOCAL_JACKET); >+ $(mydiv).append(message); >+ var img = $("<img />").attr('src', >+ '/cgi-bin/koha/catalogue/image.pl?thumbnail=1&biblionumber=' + $(mydiv).attr("class")) >+ .load(function () { >+ if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth == 0) { >+ } else { >+ if (uselink) { >+ var a = $("<a />").attr('href', '/cgi-bin/koha/catalogue/imageviewer.pl?biblionumber=' + $(mydiv).attr("class")); >+ $(a).append(img); >+ $(mydiv).append(a); >+ } else { >+ $(mydiv).append(img); >+ } >+ $(mydiv).children('.no-image').remove(); >+ } >+ }) >+ }); >+ } >+}; >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 6238f05..3b97b09 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -233,6 +233,7 @@ function verify_images() { > [% IF ( subscriptionsnumber ) %]<li><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber %]#subscriptions">Subscriptions</a></li>[% END %] > [% IF ( FRBRizeEditions ) %][% IF ( XISBNS ) %]<li><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber %]#editions">Editions</a></li>[% END %][% END %] > [% IF ( AmazonSimilarItems ) %]<li><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber %]#related">Related Titles</a></li>[% END %] >+[% IF ( LocalCoverImages ) %]<li><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblionumber %]#images">Images</a></li>[% END %] > </ul> > > <div id="holdings"> >@@ -524,6 +525,17 @@ function verify_images() { > </div> > [% END %][% END %] > >+[% IF ( LocalCoverImages ) %] >+<div id="images"> >+<div>Click on an image to view it in the image viewer</div> >+[% FOREACH image IN localimages %] >+[% IF image %] >+<span class="localimage"><a href="/cgi-bin/koha/catalogue/imageviewer.pl?biblionumber=[% biblionumber %]&imagenumber=[% image %]"><img alt="img" src="/cgi-bin/koha/catalogue/image.pl?thumbnail=1&imagenumber=[% image %]" /></a></span> >+[% END %] >+[% END %] >+</div> >+[% END %] >+ > </div><!-- /bibliodetails --> > > <div class="yui-g" id="export" style="margin-top: 1em;"> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/imageviewer.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/imageviewer.tt >new file mode 100644 >index 0000000..c5ab657 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/imageviewer.tt >@@ -0,0 +1,43 @@ >+[% INCLUDE 'doc-head-open.inc' %] >+[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha Online[% END %] Catalog › Images for: [% biblio.title |html %] >+[% INCLUDE 'doc-head-close.inc' %] >+<script type="text/JavaScript" language="JavaScript"> >+//<![CDATA[ >+ >+$(document).ready(function(){ >+ showCover($('.thumbnail').attr('id')); >+}); >+ >+function showCover(img) { >+ $('.thumbnail').attr('class', 'thumbnail'); >+ $('#largeCoverImg').attr('src', '/cgi-bin/koha/catalogue/image.pl?imagenumber=' + img); >+ $('#' + img + '.thumbnail').attr('class', 'thumbnail selected'); >+} >+//]]> >+</script> >+<style type="text/css"> >+img.thumbnail { >+ border-style: solid; >+ border-width: 3px; >+ border-color: white; >+} >+ >+img.selected { >+ border-color: black; >+} >+</style> >+<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script> >+<body id="imageviewer"> >+<div id="largeCover"><img id="largeCoverImg" alt="Large view" /></div> >+[% IF LocalCoverImages == 1 %] >+[% FOREACH img IN images %] >+[% IF img %] >+<a href='#' onclick='showCover([% img %])'><img class='thumbnail' id='[% img %]' src='/cgi-bin/koha/catalogue/image.pl?imagenumber=[% img %]&thumbnail=1' alt='Image'/></a> >+[% END %] >+[% END %] >+[% biblio.title %] [% biblio.author %] >+[% ELSE %] >+Unfortunately, images are not enabled for this catalog at this time. >+[% END %] >+</body> >+</html> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload-images.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload-images.tt >index 36d6d37..26a1468 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload-images.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload-images.tt >@@ -109,7 +109,7 @@ function CheckForm(f) { > <legend>Options</legend> > <ol> > <li class="checkbox"> >- <input type="checkbox" id="replace" name="replace" [% IF AllowMultipleCovers == 0 %]checked="checked" disabled="disabled"[% END %] /> >+ <input type="checkbox" id="replace" name="replace" [% IF AllowMultipleCovers == 0 %]checked="checked" disabled="disabled"[% END %] value="1" /> > <label for="replace">Replace existing covers</label> > </li> > </ol> >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 15bea79..18e5917 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 >@@ -98,6 +98,15 @@ var NO_OL_JACKET = _("No cover image available"); > </script> > [% END %] > >+[% IF OPACLocalCoverImages %] >+<script type="text/javascript" language="javascript" src="[% themelang %]/js/localcovers.js"></script> >+<script type="text/javascript" language="javascript"> >+//<![CDATA[ >+var NO_LOCAL_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[ >diff --git a/koha-tmpl/opac-tmpl/prog/en/js/localcovers.js b/koha-tmpl/opac-tmpl/prog/en/js/localcovers.js >new file mode 100644 >index 0000000..298a20e >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/prog/en/js/localcovers.js >@@ -0,0 +1,44 @@ >+if (typeof KOHA == "undefined" || !KOHA) { >+ var KOHA = {}; >+} >+ >+/** >+ * A namespace for local cover related functions. >+ */ >+KOHA.LocalCover = { >+ >+ >+ /** >+ * 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(). >+ */ >+ GetCoverFromBibnumber: function(uselink) { >+ $("div [id^=local-thumbnail]").each(function(i) { >+ var mydiv = this; >+ var message = document.createElement("span"); >+ $(message).attr("class","no-image"); >+ $(message).html(NO_LOCAL_JACKET); >+ $(mydiv).append(message); >+ var img = $("<img />").attr('src', >+ '/cgi-bin/koha/opac-image.pl?thumbnail=1&biblionumber=' + $(mydiv).attr("class")) >+ .load(function () { >+ if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth == 0) { >+ } else { >+ if (uselink) { >+ var a = $("<a />").attr('href', '/cgi-bin/koha/opac-imageviewer.pl?biblionumber=' + $(mydiv).attr("class")); >+ $(a).append(img); >+ $(mydiv).append(a); >+ } else { >+ $(mydiv).append(img); >+ } >+ $(mydiv).children('.no-image').remove(); >+ } >+ }) >+ }); >+ } >+}; >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >index 066f4ff..6534d1b 100755 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >@@ -39,6 +39,9 @@ > [% IF OpenLibraryCovers %] > KOHA.OpenLibrary.GetCoverFromIsbn(); > [% END %] >+ [% IF OPACLocalCoverImages %] >+ KOHA.LocalCover.GetCoverFromBibnumber(true); >+ [% END %] > [% IF ( NovelistSelectProfile ) %] > novSelect.loadContentForISBN('[% normalized_isbn %]','[% NovelistSelectProfile %]', '[% NovelistSelectPassword %]', function(d){}); > [% END %] >@@ -224,6 +227,7 @@ YAHOO.util.Event.onContentReady("furtherm", function () { > <div id="catalogue_detail_biblio"> > > <div id="bookcover"> >+ [% IF ( OPACLocalCoverImages ) %]<div style="block" title="[% biblionumber |url %]" class="[% biblionumber %]" id="local-thumbnail-preview"></div>[% END %] > [% IF ( OPACAmazonEnabled ) %][% IF ( OPACAmazonCoverImages ) %][% IF ( OPACurlOpenInNewWindow ) %]<a href="http://www.amazon[% AmazonTld %]/gp/reader/[% normalized_isbn %]/ref=sib_dp_pt/002-7879865-0184864#reader-link" target="_blank"><img border="0" src="http://images.amazon.com/images/P/[% normalized_isbn %].01.MZZZZZZZ.jpg" alt="Cover Image" /></a>[% ELSE %]<a href="http://www.amazon[% AmazonTld %]/gp/reader/[% normalized_isbn %]/ref=sib_dp_pt/002-7879865-0184864#reader-link"><img border="0" src="http://images.amazon.com/images/P/[% normalized_isbn %].01.MZZZZZZZ.jpg" alt="Cover Image" /></a>[% END %][% END %][% END %] > > [% IF ( SyndeticsEnabled ) %][% IF ( SyndeticsCoverImages ) %][% IF ( content_identifier_exists ) %][% IF ( using_https ) %] >@@ -543,6 +547,8 @@ YAHOO.util.Event.onContentReady("furtherm", function () { > [% ELSE %]<li>[% END %] > <a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblionumber %]#serialcollection">Serial Collection</a></li> > [% END %] >+ >+ [% IF ( OPACLocalCoverImages ) %]<li><a href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblionumber %]#images">Images</a></li>[% END %] > </ul> > > [% IF ( serialcollection ) %] >@@ -983,6 +989,18 @@ YAHOO.util.Event.onContentReady("furtherm", function () { > [% END %] > > >+[% IF ( OPACLocalCoverImages ) %] >+<div id="images"> >+<div>Click on an image to view it in the image viewer</div> >+[% FOREACH image IN localimages %] >+[% IF image %] >+<span class="localimage"><a href="/cgi-bin/koha/opac-imageviewer.pl?biblionumber=[% biblionumber %]&imagenumber=[% image %]"><img alt="img" src="/cgi-bin/koha/opac-image.pl?thumbnail=1&imagenumber=[% image %]" /></a></span> >+[% END %] >+[% END %] >+</div> >+[% END %] >+ >+ > </div> > [% IF ( NovelistSelectProfile ) %][% IF ( NovelistSelectView == 'below' ) %] > <div id="NovelistSelect"> >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-imageviewer.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-imageviewer.tt >new file mode 100644 >index 0000000..d6633e1 >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-imageviewer.tt >@@ -0,0 +1,43 @@ >+[% INCLUDE 'doc-head-open.inc' %] >+[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha Online[% END %] Catalog › Images for: [% biblio.title |html %] >+[% INCLUDE 'doc-head-close.inc' %] >+<script type="text/JavaScript" language="JavaScript"> >+//<![CDATA[ >+ >+$(document).ready(function(){ >+ showCover($('.thumbnail').attr('id')); >+}); >+ >+function showCover(img) { >+ $('.thumbnail').attr('class', 'thumbnail'); >+ $('#largeCoverImg').attr('src', '/cgi-bin/koha/opac-image.pl?imagenumber=' + img); >+ $('#' + img + '.thumbnail').attr('class', 'thumbnail selected'); >+} >+//]]> >+</script> >+<style type="text/css"> >+img.thumbnail { >+ border-style: solid; >+ border-width: 3px; >+ border-color: white; >+} >+ >+img.selected { >+ border-color: black; >+} >+</style> >+<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script> >+<body id="opac-imageviewer"> >+<div id="largeCover"><img id="largeCoverImg" alt="Large view" /></div> >+[% IF OPACLocalCoverImages == 1 %] >+[% FOREACH img IN images %] >+[% IF img %] >+<a href='#' onclick='showCover([% img %])'><img class='thumbnail' id='[% img %]' src='/cgi-bin/koha/opac-image.pl?imagenumber=[% img %]&thumbnail=1' alt='Image'/></a> >+[% END %] >+[% END %] >+[% biblio.title %] [% biblio.author %] >+[% ELSE %] >+Unfortunately, images are not enabled for this catalog at this time. >+[% END %] >+</body> >+</html> >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 798e0d8..04cce4c 100755 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >@@ -229,6 +229,7 @@ $(document).ready(function(){ > [% END %] > [% END %][% END %] > [% IF OpenLibraryCovers %]KOHA.OpenLibrary.GetCoverFromIsbn();[% END %] >+ [% IF OPACLocalCoverImages %]KOHA.LocalCover.GetCoverFromBibnumber(false);[% END %] > [% IF ( GoogleJackets ) %]KOHA.Google.GetCoverFromIsbn();[% END %] > }); > //]]> >@@ -528,6 +529,7 @@ $(document).ready(function(){ > </span> > </td><td> > <a class="p1" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]"> >+ [% IF ( OPACLocalCoverImages ) %]<div style="block" title="[% SEARCH_RESULT.biblionumber |url %]" class="[% SEARCH_RESULT.biblionumber %]" id="local-thumbnail[% loop.count %]"></div>[% END %] > [% IF ( OPACAmazonEnabled ) %][% IF ( OPACAmazonCoverImages ) %][% IF ( SEARCH_RESULT.normalized_isbn ) %]<img src="http://images.amazon.com/images/P/[% SEARCH_RESULT.normalized_isbn %].01.TZZZZZZZ.jpg" alt="" class="thumbnail" />[% ELSE %]<span class="no-image">No cover image available</span>[% END %][% END %][% END %] > > [% IF ( SyndeticsEnabled ) %][% IF ( SyndeticsCoverImages ) %][% IF ( using_https ) %] >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index 8949444..c4d8218 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -45,6 +45,7 @@ use C4::Charset; > use MARC::Record; > use MARC::Field; > use List::MoreUtils qw/any none/; >+use C4::Images; > > BEGIN { > if (C4::Context->preference('BakerTaylorEnabled')) { >@@ -690,6 +691,11 @@ if (scalar(@serialcollections) > 0) { > serialcollections => \@serialcollections); > } > >+# Local cover Images stuff >+if (C4::Context->preference("OPACLocalCoverImages")){ >+ $template->param(OPACLocalCoverImages => 1); >+} >+ > # Amazon.com Stuff > if ( C4::Context->preference("OPACAmazonEnabled") ) { > $template->param( AmazonTld => get_amazon_tld() ); >@@ -915,4 +921,9 @@ my $defaulttab = > ? 'serialcollection' : 'subscription'; > $template->param('defaulttab' => $defaulttab); > >+if (C4::Context->preference('OPACLocalCoverImages') == 1) { >+ my @images = ListImagesForBiblio($biblionumber); >+ $template->{VARS}->{localimages} = \@images; >+} >+ > output_html_with_http_headers $query, $cookie, $template->output; >diff --git a/opac/opac-image.pl b/opac/opac-image.pl >new file mode 100755 >index 0000000..1edc0b4 >--- /dev/null >+++ b/opac/opac-image.pl >@@ -0,0 +1,108 @@ >+#!/usr/bin/perl >+# >+# based on patronimage.pl >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+# >+# >+# >+ >+use strict; >+use warnings; >+ >+use CGI; #qw(:standard escapeHTML); >+use C4::Context; >+use C4::Images; >+ >+$|=1; >+ >+my $DEBUG = 1; >+my $data = new CGI; >+my $imagenumber; >+ >+=head1 NAME >+ >+opac-image.pl - Script for retrieving and formatting local cover images for display >+ >+=head1 SYNOPSIS >+ >+<img src="opac-image.pl?imagenumber=X" /> >+<img src="opac-image.pl?biblionumber=X" /> >+<img src="opac-image.pl?imagenumber=X&thumbnail=1" /> >+<img src="opac-image.pl?biblionumber=X&thumbnail=1" /> >+ >+=head1 DESCRIPTION >+ >+This script, when called from within HTML and passed a valid imagenumber or >+biblionumber, will retrieve the image data associated with that biblionumber >+if one exists, format it in proper HTML format and pass it back to be displayed. >+If the parameter thumbnail has been provided, a thumbnail will be returned >+rather than the full-size image. When a biblionumber is provided rather than an >+imagenumber, a random image is selected. >+ >+=cut >+ >+if (defined $data->param('imagenumber')) { >+ $imagenumber = $data->param('imagenumber'); >+} elsif (defined $data->param('biblionumber')) { >+ my @imagenumbers = ListImagesForBiblio($data->param('biblionumber')); >+ if (@imagenumbers) { >+ $imagenumber = $imagenumbers[0]; >+ } else { >+ warn "No images for this biblio" if $DEBUG; >+ error(); >+ } >+} else { >+ $imagenumber = shift; >+} >+ >+if ($imagenumber) { >+ warn "imagenumber passed in: $imagenumber" if $DEBUG; >+ my $imagedata = RetrieveImage($imagenumber); >+ >+ error() unless $imagedata; >+ >+ if ($imagedata) { >+ my $image; >+ if ($data->param('thumbnail')) { >+ $image = $imagedata->{'thumbnail'}; >+ } else { >+ $image = $imagedata->{'imagefile'}; >+ } >+ print $data->header (-type => $imagedata->{'mimetype'}, -'Cache-Control' => 'no-store', -expires => 'now', -Content_Length => length ($image)), $image; >+ exit; >+ } else { >+ warn "No image exists for $imagenumber" if $DEBUG; >+ error(); >+ } >+} else { >+ error(); >+} >+ >+error(); >+ >+sub error { >+ print $data->header ( -status=> '404', -expires => 'now' ); >+ exit; >+} >+ >+=head1 AUTHOR >+ >+Chris Nighswonger cnighswonger <at> foundations <dot> edu >+ >+modified for local cover images by Koustubha Kale kmkale <at> anantcorp <dot> com >+ >+=cut >diff --git a/opac/opac-imageviewer.pl b/opac/opac-imageviewer.pl >new file mode 100755 >index 0000000..c34c58a >--- /dev/null >+++ b/opac/opac-imageviewer.pl >@@ -0,0 +1,51 @@ >+#!/usr/bin/perl >+ >+# Copyright 2011 C & P Bibliography Services >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use strict; >+use warnings; >+ >+use CGI; >+use C4::Auth; >+use C4::Biblio; >+use C4::Output; >+use C4::Images; >+ >+my $query = new CGI; >+my ( $template, $borrowernumber, $cookie ) = get_template_and_user( >+ { >+ template_name => "opac-imageviewer.tmpl", >+ query => $query, >+ type => "opac", >+ authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ), >+ flagsrequired => { borrow => 1 }, >+ } >+); >+ >+my $biblionumber = $query->param('biblionumber') || $query->param('bib'); >+my ($count, $biblio) = GetBiblio($biblionumber); >+ >+if (C4::Context->preference("OPACLocalCoverImages")) { >+ my @images = ListImagesForBiblio($biblionumber); >+ $template->{VARS}->{'OPACLocalCoverImages'} = 1; >+ $template->{VARS}->{'images'} = \@images; >+} >+ >+$template->{VARS}->{'biblio'} = $biblio; >+ >+output_html_with_http_headers $query, $cookie, $template->output; >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index 12baf3b..08a4687 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -616,6 +616,10 @@ for (my $i=0;$i<@servers;$i++) { > $template->param(SEARCH_RESULTS => \@newresults, > OPACItemsResultsDisplay => (C4::Context->preference("OPACItemsResultsDisplay") eq "itemdetails"?1:0), > ); >+ if (C4::Context->preference("OPACLocalCoverImages")){ >+ $template->param(OPACLocalCoverImages => 1); >+ $template->param(OPACLocalCoverImagesPriority => C4::Context->preference("OPACLocalCoverImagesPriority")); >+ } > ## Build the page numbers on the bottom of the page > my @page_numbers; > # total number of pages there will be >diff --git a/tools/upload-cover-image.pl b/tools/upload-cover-image.pl >index ac9661e..f70aefc 100755 >--- a/tools/upload-cover-image.pl >+++ b/tools/upload-cover-image.pl >@@ -66,7 +66,7 @@ my ($template, $loggedinuser, $cookie) > my $filetype = $input->param('filetype'); > my $biblionumber = $input->param('biblionumber'); > my $uploadfilename = $input->param('uploadfile'); >-my $replace = $input->param('replace'); >+my $replace = !C4::Context->preference("AllowMultipleCovers") || $input->param('replace'); > my $op = $input->param('op'); > my %cookies = parse CGI::Cookie($cookie); > my $sessionID = $cookies{'CGISESSID'}->value; >@@ -78,6 +78,7 @@ $template->{VARS}->{'biblionumber'} = $biblionumber; > > my $total = 0; > >+ > if ($fileID) { > my $uploaded_file = C4::UploadedFile->fetch($sessionID, $fileID); > if ($filetype eq 'image') { >-- >1.7.5.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 1633
:
6242
|
6699
|
6706
|
6712
|
6745
|
6746
|
6747
|
6748
|
6749
|
6750
|
6755
|
6756
|
6758
|
6759
|
6764
|
6765
|
6766
|
6785
|
6786
|
6787
|
6788
|
6791
|
6823
|
6973
|
6974
|
6975
|
6976
|
6977
|
6978
|
6979
|
6980
|
6981
|
6982
|
6983
|
7146
|
7147
|
7148
|
7149
|
7150
|
7151
|
7152
|
7153
|
7156
|
7219
|
7267
|
7268
|
7270
|
7271
|
7272
|
7273
|
7274
|
7275
|
7312
|
7315
|
7320
|
7324
|
7325
|
7334