Bug 1633: QA follow-up
* Show the "Upload images" button when OPACLocalCoverImages is enabled but LocalCoverImages (i.e. local cover images on the staff client) is not * Correct copyright and license comments in new files * perltidy and replace tabs by four spaces Signed-off-by: Koustubha Kale <kmkale@anantcorp.com> Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
This commit is contained in:
parent
e901c4f24c
commit
587e2e920e
11 changed files with 321 additions and 218 deletions
|
@ -391,6 +391,7 @@ sub get_template_and_user {
|
|||
NoZebra => C4::Context->preference('NoZebra'),
|
||||
EasyAnalyticalRecords => C4::Context->preference('EasyAnalyticalRecords'),
|
||||
LocalCoverImages => C4::Context->preference('LocalCoverImages'),
|
||||
OPACLocalCoverImages => C4::Context->preference('OPACLocalCoverImages'),
|
||||
AllowMultipleCovers => C4::Context->preference('AllowMultipleCovers'),
|
||||
);
|
||||
}
|
||||
|
|
128
C4/Images.pm
128
C4/Images.pm
|
@ -1,4 +1,23 @@
|
|||
package C4::Images;
|
||||
|
||||
# Copyright (C) 2011 C & P Bibliography Services
|
||||
# Jared Camins-Esakov <jcamins@cpbibliograpy.com>
|
||||
#
|
||||
# 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 5.010;
|
||||
|
@ -9,17 +28,18 @@ use GD;
|
|||
use vars qw($debug $VERSION @ISA @EXPORT);
|
||||
|
||||
BEGIN {
|
||||
# set the version for version checking
|
||||
$VERSION = 3.03;
|
||||
require Exporter;
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(
|
||||
&PutImage
|
||||
&RetrieveImage
|
||||
&ListImagesForBiblio
|
||||
&DelImage
|
||||
|
||||
# set the version for version checking
|
||||
$VERSION = 3.03;
|
||||
require Exporter;
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(
|
||||
&PutImage
|
||||
&RetrieveImage
|
||||
&ListImagesForBiblio
|
||||
&DelImage
|
||||
);
|
||||
$debug = $ENV{KOHA_DEBUG} || $ENV{DEBUG} || 0;
|
||||
$debug = $ENV{KOHA_DEBUG} || $ENV{DEBUG} || 0;
|
||||
}
|
||||
|
||||
=head2 PutImage
|
||||
|
@ -31,27 +51,33 @@ Stores binary image data and thumbnail in database, optionally replacing existin
|
|||
=cut
|
||||
|
||||
sub PutImage {
|
||||
my ($biblionumber, $srcimage, $replace) = @_;
|
||||
my ( $biblionumber, $srcimage, $replace ) = @_;
|
||||
|
||||
return -1 unless defined($srcimage);
|
||||
|
||||
if ($replace) {
|
||||
foreach (ListImagesForBiblio($biblionumber)) {
|
||||
foreach ( ListImagesForBiblio($biblionumber) ) {
|
||||
DelImage($_);
|
||||
}
|
||||
}
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = "INSERT INTO biblioimages (biblionumber, mimetype, imagefile, thumbnail) VALUES (?,?,?,?);";
|
||||
my $query =
|
||||
"INSERT INTO biblioimages (biblionumber, mimetype, imagefile, thumbnail) VALUES (?,?,?,?);";
|
||||
my $sth = $dbh->prepare($query);
|
||||
|
||||
my $mimetype = 'image/png'; # GD autodetects three basic image formats: PNG, JPEG, XPM; we will convert all to PNG which is lossless...
|
||||
# Check the pixel size of the image we are about to import...
|
||||
my $thumbnail = _scale_image($srcimage, 140, 200); # MAX pixel dims are 140 X 200 for thumbnail...
|
||||
my $fullsize = _scale_image($srcimage, 600, 800); # MAX pixel dims are 600 X 800 for full-size image...
|
||||
my $mimetype = 'image/png'
|
||||
; # GD autodetects three basic image formats: PNG, JPEG, XPM; we will convert all to PNG which is lossless...
|
||||
|
||||
# Check the pixel size of the image we are about to import...
|
||||
my $thumbnail = _scale_image( $srcimage, 140, 200 )
|
||||
; # MAX pixel dims are 140 X 200 for thumbnail...
|
||||
my $fullsize = _scale_image( $srcimage, 600, 800 )
|
||||
; # MAX pixel dims are 600 X 800 for full-size image...
|
||||
$debug and warn "thumbnail is " . length($thumbnail) . " bytes.";
|
||||
|
||||
$sth->execute($biblionumber,$mimetype,$fullsize->png(),$thumbnail->png());
|
||||
$sth->execute( $biblionumber, $mimetype, $fullsize->png(),
|
||||
$thumbnail->png() );
|
||||
my $dberror = $sth->errstr;
|
||||
warn "Error returned inserting $biblionumber.$mimetype." if $sth->errstr;
|
||||
undef $thumbnail;
|
||||
|
@ -70,14 +96,16 @@ sub RetrieveImage {
|
|||
my ($imagenumber) = @_;
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = 'SELECT mimetype, imagefile, thumbnail FROM biblioimages WHERE imagenumber = ?';
|
||||
my $query =
|
||||
'SELECT mimetype, imagefile, thumbnail FROM biblioimages WHERE imagenumber = ?';
|
||||
my $sth = $dbh->prepare($query);
|
||||
$sth->execute($imagenumber);
|
||||
my $imagedata = $sth->fetchrow_hashref;
|
||||
if ($sth->err) {
|
||||
if ( $sth->err ) {
|
||||
warn "Database error!";
|
||||
return undef;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return $imagedata;
|
||||
}
|
||||
}
|
||||
|
@ -89,22 +117,22 @@ Gets a list of all images associated with a particular biblio.
|
|||
|
||||
=cut
|
||||
|
||||
|
||||
sub ListImagesForBiblio {
|
||||
my ($biblionumber) = @_;
|
||||
|
||||
my @imagenumbers;
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = 'SELECT imagenumber FROM biblioimages WHERE biblionumber = ?';
|
||||
my $sth = $dbh->prepare($query);
|
||||
my $sth = $dbh->prepare($query);
|
||||
$sth->execute($biblionumber);
|
||||
warn "Database error!" if $sth->errstr;
|
||||
if (!$sth->errstr && $sth->rows > 0) {
|
||||
while (my $row = $sth->fetchrow_hashref) {
|
||||
if ( !$sth->errstr && $sth->rows > 0 ) {
|
||||
while ( my $row = $sth->fetchrow_hashref ) {
|
||||
push @imagenumbers, $row->{'imagenumber'};
|
||||
}
|
||||
return @imagenumbers;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
|
@ -120,9 +148,9 @@ Removes the image with the supplied imagenumber.
|
|||
sub DelImage {
|
||||
my ($imagenumber) = @_;
|
||||
warn "Imagenumber passed to DelImage is $imagenumber" if $debug;
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query = "DELETE FROM biblioimages WHERE imagenumber = ?;";
|
||||
my $sth = $dbh->prepare($query);
|
||||
my $sth = $dbh->prepare($query);
|
||||
$sth->execute($imagenumber);
|
||||
my $dberror = $sth->errstr;
|
||||
warn "Database error!" if $sth->errstr;
|
||||
|
@ -130,24 +158,36 @@ sub DelImage {
|
|||
}
|
||||
|
||||
sub _scale_image {
|
||||
my ($image, $maxwidth, $maxheight) = @_;
|
||||
my ($width, $height) = $image->getBounds();
|
||||
my ( $image, $maxwidth, $maxheight ) = @_;
|
||||
my ( $width, $height ) = $image->getBounds();
|
||||
$debug and warn "image is $width pix X $height pix.";
|
||||
if ($width > $maxwidth || $height > $maxheight) {
|
||||
if ( $width > $maxwidth || $height > $maxheight ) {
|
||||
|
||||
# $debug and warn "$filename exceeds the maximum pixel dimensions of $maxwidth X $maxheight. Resizing...";
|
||||
my $percent_reduce; # Percent we will reduce the image dimensions by...
|
||||
if ($width > $maxwidth) {
|
||||
$percent_reduce = sprintf("%.5f",($maxwidth/$width)); # If the width is oversize, scale based on width overage...
|
||||
} else {
|
||||
$percent_reduce = sprintf("%.5f",($maxheight/$height)); # otherwise scale based on height overage.
|
||||
}
|
||||
my $width_reduce = sprintf("%.0f", ($width * $percent_reduce));
|
||||
my $height_reduce = sprintf("%.0f", ($height * $percent_reduce));
|
||||
$debug and warn "Reducing image by " . ($percent_reduce * 100) . "\% or to $width_reduce pix X $height_reduce pix";
|
||||
my $newimage = GD::Image->new($width_reduce, $height_reduce, 1); #'1' creates true color image...
|
||||
$newimage->copyResampled($image,0,0,0,0,$width_reduce,$height_reduce,$width,$height);
|
||||
my $percent_reduce; # Percent we will reduce the image dimensions by...
|
||||
if ( $width > $maxwidth ) {
|
||||
$percent_reduce =
|
||||
sprintf( "%.5f", ( $maxwidth / $width ) )
|
||||
; # If the width is oversize, scale based on width overage...
|
||||
}
|
||||
else {
|
||||
$percent_reduce =
|
||||
sprintf( "%.5f", ( $maxheight / $height ) )
|
||||
; # otherwise scale based on height overage.
|
||||
}
|
||||
my $width_reduce = sprintf( "%.0f", ( $width * $percent_reduce ) );
|
||||
my $height_reduce = sprintf( "%.0f", ( $height * $percent_reduce ) );
|
||||
$debug
|
||||
and warn "Reducing image by "
|
||||
. ( $percent_reduce * 100 )
|
||||
. "\% or to $width_reduce pix X $height_reduce pix";
|
||||
my $newimage = GD::Image->new( $width_reduce, $height_reduce, 1 )
|
||||
; #'1' creates true color image...
|
||||
$newimage->copyResampled( $image, 0, 0, 0, 0, $width_reduce,
|
||||
$height_reduce, $width, $height );
|
||||
return $newimage;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return $image;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# Copyright (C) 2011 C & P Bibliography Services
|
||||
# Jared Camins-Esakov <jcamins@cpbibliograpy.com>
|
||||
#
|
||||
# based on patronimage.pl
|
||||
#
|
||||
# This file is part of Koha.
|
||||
|
@ -23,14 +26,14 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
|
||||
use CGI; #qw(:standard escapeHTML);
|
||||
use CGI; #qw(:standard escapeHTML);
|
||||
use C4::Context;
|
||||
use C4::Images;
|
||||
|
||||
$|=1;
|
||||
$| = 1;
|
||||
|
||||
my $DEBUG = 0;
|
||||
my $data = new CGI;
|
||||
my $data = new CGI;
|
||||
my $imagenumber;
|
||||
|
||||
=head1 NAME
|
||||
|
@ -57,17 +60,20 @@ imagenumber, a random image is selected.
|
|||
|
||||
error() unless C4::Context->preference("OPACLocalCoverImages");
|
||||
|
||||
if (defined $data->param('imagenumber')) {
|
||||
if ( defined $data->param('imagenumber') ) {
|
||||
$imagenumber = $data->param('imagenumber');
|
||||
} elsif (defined $data->param('biblionumber')) {
|
||||
my @imagenumbers = ListImagesForBiblio($data->param('biblionumber'));
|
||||
}
|
||||
elsif ( defined $data->param('biblionumber') ) {
|
||||
my @imagenumbers = ListImagesForBiblio( $data->param('biblionumber') );
|
||||
if (@imagenumbers) {
|
||||
$imagenumber = $imagenumbers[0];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
warn "No images for this biblio" if $DEBUG;
|
||||
error();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$imagenumber = shift;
|
||||
}
|
||||
|
||||
|
@ -79,25 +85,33 @@ if ($imagenumber) {
|
|||
|
||||
if ($imagedata) {
|
||||
my $image;
|
||||
if ($data->param('thumbnail')) {
|
||||
if ( $data->param('thumbnail') ) {
|
||||
$image = $imagedata->{'thumbnail'};
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$image = $imagedata->{'imagefile'};
|
||||
}
|
||||
print $data->header (-type => $imagedata->{'mimetype'}, -'Cache-Control' => 'no-store', -expires => 'now', -Content_Length => length ($image)), $image;
|
||||
print $data->header(
|
||||
-type => $imagedata->{'mimetype'},
|
||||
-'Cache-Control' => 'no-store',
|
||||
-expires => 'now',
|
||||
-Content_Length => length($image)
|
||||
), $image;
|
||||
exit;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
warn "No image exists for $imagenumber" if $DEBUG;
|
||||
error();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
error();
|
||||
}
|
||||
|
||||
error();
|
||||
|
||||
sub error {
|
||||
print $data->header ( -status=> '404', -expires => 'now' );
|
||||
print $data->header( -status => '404', -expires => 'now' );
|
||||
exit;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,38 +40,42 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
|
|||
);
|
||||
|
||||
my $biblionumber = $query->param('biblionumber') || $query->param('bib');
|
||||
my $imagenumber = $query ->param('imagenumber');
|
||||
my ($count, $biblio) = GetBiblio($biblionumber);
|
||||
my $imagenumber = $query->param('imagenumber');
|
||||
my ( $count, $biblio ) = GetBiblio($biblionumber);
|
||||
my $itemcount = GetItemsCount($biblionumber);
|
||||
|
||||
my @items = GetItemsInfo( $biblionumber );
|
||||
my @items = GetItemsInfo($biblionumber);
|
||||
|
||||
my $norequests = 1;
|
||||
foreach my $item (@items) {
|
||||
|
||||
# can place holds defaults to yes
|
||||
$norequests = 0 unless ( ( $item->{'notforloan_per_itemtype'} > 0 ) || ( $item->{'itemnotforloan'} > 0 ) );
|
||||
$norequests = 0
|
||||
unless ( ( $item->{'notforloan_per_itemtype'} > 0 )
|
||||
|| ( $item->{'itemnotforloan'} > 0 ) );
|
||||
}
|
||||
|
||||
if($query->cookie("holdfor")){
|
||||
my $holdfor_patron = GetMember('borrowernumber' => $query->cookie("holdfor"));
|
||||
if ( $query->cookie("holdfor") ) {
|
||||
my $holdfor_patron =
|
||||
GetMember( 'borrowernumber' => $query->cookie("holdfor") );
|
||||
$template->param(
|
||||
holdfor => $query->cookie("holdfor"),
|
||||
holdfor_surname => $holdfor_patron->{'surname'},
|
||||
holdfor_firstname => $holdfor_patron->{'firstname'},
|
||||
holdfor => $query->cookie("holdfor"),
|
||||
holdfor_surname => $holdfor_patron->{'surname'},
|
||||
holdfor_firstname => $holdfor_patron->{'firstname'},
|
||||
holdfor_cardnumber => $holdfor_patron->{'cardnumber'},
|
||||
);
|
||||
}
|
||||
|
||||
if (C4::Context->preference("LocalCoverImages")) {
|
||||
if ( C4::Context->preference("LocalCoverImages") ) {
|
||||
my @images = ListImagesForBiblio($biblionumber);
|
||||
$template->{VARS}->{'LocalCoverImages'} = 1;
|
||||
$template->{VARS}->{'images'} = \@images;
|
||||
$template->{VARS}->{'imagenumber'} = $imagenumber || $images[0] || '';
|
||||
$template->{VARS}->{'images'} = \@images;
|
||||
$template->{VARS}->{'imagenumber'} = $imagenumber || $images[0] || '';
|
||||
}
|
||||
$template->{VARS}->{'count'} = $itemcount;
|
||||
$template->{VARS}->{'biblionumber'} = $biblionumber;
|
||||
$template->{VARS}->{'norequests'} = $norequests;
|
||||
$template->param( C4::Search::enabled_staff_search_views );
|
||||
$template->{VARS}->{'biblio'} = $biblio;
|
||||
$template->{VARS}->{'count'} = $itemcount;
|
||||
$template->{VARS}->{'biblionumber'} = $biblionumber;
|
||||
$template->{VARS}->{'norequests'} = $norequests;
|
||||
$template->param(C4::Search::enabled_staff_search_views);
|
||||
$template->{VARS}->{'biblio'} = $biblio;
|
||||
|
||||
output_html_with_http_headers $query, $cookie, $template->output;
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
use C4::Context;
|
||||
my $dbh=C4::Context->dbh;
|
||||
my $dbh = C4::Context->dbh;
|
||||
|
||||
$dbh->do( q|CREATE TABLE `biblioimages` (
|
||||
$dbh->do(
|
||||
q|CREATE TABLE `biblioimages` (
|
||||
`imagenumber` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`biblionumber` int(11) NOT NULL,
|
||||
`mimetype` varchar(15) NOT NULL,
|
||||
|
@ -12,9 +13,18 @@ $dbh->do( q|CREATE TABLE `biblioimages` (
|
|||
`thumbnail` mediumblob NOT NULL,
|
||||
PRIMARY KEY (`imagenumber`),
|
||||
CONSTRAINT `bibliocoverimage_fk1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8|);
|
||||
$dbh->do( q|INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OPACLocalCoverImages','0','Display local cover images on OPAC search and details pages.','1','YesNo')|);
|
||||
$dbh->do( q|INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('LocalCoverImages','0','Display local cover images on intranet search and details pages.','1','YesNo')|);
|
||||
$dbh->do( q|INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllowMultipleCovers','0','Allow multiple cover images to be attached to each bibliographic record.','1','YesNo')|);
|
||||
$dbh->do( q|INSERT INTO permissions (module_bit, code, description) VALUES (13, 'upload_local_cover_images', 'Upload local cover images')|);
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8|
|
||||
);
|
||||
$dbh->do(
|
||||
q|INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('OPACLocalCoverImages','0','Display local cover images on OPAC search and details pages.','1','YesNo')|
|
||||
);
|
||||
$dbh->do(
|
||||
q|INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('LocalCoverImages','0','Display local cover images on intranet search and details pages.','1','YesNo')|
|
||||
);
|
||||
$dbh->do(
|
||||
q|INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES ('AllowMultipleCovers','0','Allow multiple cover images to be attached to each bibliographic record.','1','YesNo')|
|
||||
);
|
||||
$dbh->do(
|
||||
q|INSERT INTO permissions (module_bit, code, description) VALUES (13, 'upload_local_cover_images', 'Upload local cover images')|
|
||||
);
|
||||
print "Upgrade done (Added support for local cover images)\n";
|
||||
|
|
|
@ -102,7 +102,7 @@ function confirm_items_deletion() {
|
|||
[% IF ( CAN_user_editcatalogue_edit_items ) %]{ text: _("Edit Items"), url: "/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% biblionumber %]" },[% END %]
|
||||
[% IF ( CAN_user_editcatalogue_edit_items ) %]{ text: _("Attach Item"), url: "/cgi-bin/koha/cataloguing/moveitem.pl?biblionumber=[% biblionumber %]" },[% END %]
|
||||
[% IF ( EasyAnalyticalRecords ) %][% IF ( CAN_user_editcatalogue_edit_items ) %]{ text: _("Link to Host Item"), url: "/cgi-bin/koha/cataloguing/linkitem.pl?biblionumber=[% biblionumber %]" },[% END %][% END %]
|
||||
[% IF ( LocalCoverImages ) %][% IF ( CAN_user_tools_upload_local_cover_images ) %]{ text: _("Upload Image"), url: "/cgi-bin/koha/tools/upload-cover-image.pl?biblionumber=[% biblionumber %]&filetype=image" },[% END %][% END %]
|
||||
[% IF ( LocalCoverImages || OPACLocalCoverImages) %][% IF ( CAN_user_tools_upload_local_cover_images ) %]{ text: _("Upload Image"), url: "/cgi-bin/koha/tools/upload-cover-image.pl?biblionumber=[% biblionumber %]&filetype=image" },[% END %][% END %]
|
||||
[% IF ( CAN_user_editcatalogue_edit_catalogue ) %]{ text: _("Edit as New (Duplicate)"), url: "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% biblionumber %]&frameworkcode=&op=duplicate" },[% END %]
|
||||
[% IF ( CAN_user_editcatalogue_edit_catalogue ) %]{ text: _("Replace Record via Z39.50"), onclick: {fn: PopupZ3950 } },[% END %]
|
||||
[% IF ( CAN_user_editcatalogue_edit_catalogue ) %]{ text: _("Delete Record"), onclick: {fn: confirm_deletion }[% IF ( count ) %],id:'disabled'[% END %] },[% END %]
|
||||
|
|
|
@ -18,19 +18,19 @@ function showCover(img) {
|
|||
</script>
|
||||
<style type="text/css">
|
||||
#largeCoverImg {
|
||||
border : 1px solid #CCCCCC;
|
||||
display : block;
|
||||
margin : auto;
|
||||
padding : 1em;
|
||||
border : 1px solid #CCCCCC;
|
||||
display : block;
|
||||
margin : auto;
|
||||
padding : 1em;
|
||||
}
|
||||
#thumbnails {
|
||||
text-align : center;
|
||||
text-align : center;
|
||||
}
|
||||
#thumbnails a img {
|
||||
border : 1px solid #0000CC;
|
||||
border : 1px solid #0000CC;
|
||||
}
|
||||
img.thumbnail {
|
||||
display : block;
|
||||
display : block;
|
||||
float : none;
|
||||
margin: 0 5px 5px 0;
|
||||
padding : .5em;
|
||||
|
@ -40,7 +40,7 @@ img.thumbnail {
|
|||
border-color: black;
|
||||
cursor : default;
|
||||
opacity:0.4;
|
||||
filter:alpha(opacity=40); /* For IE8 and earlier */
|
||||
filter:alpha(opacity=40); /* For IE8 and earlier */
|
||||
}
|
||||
</style>[% END %]
|
||||
</head>
|
||||
|
@ -55,9 +55,9 @@ img.thumbnail {
|
|||
<div id="doc3" class="yui-t1">
|
||||
|
||||
<div id="bd">
|
||||
<div id="yui-main">
|
||||
<div class="yui-b">
|
||||
<div class="yui-ge">
|
||||
<div id="yui-main">
|
||||
<div class="yui-b">
|
||||
<div class="yui-ge">
|
||||
|
||||
[% INCLUDE 'cat-toolbar.inc' %]
|
||||
|
||||
|
@ -65,32 +65,32 @@ img.thumbnail {
|
|||
<h4>[% biblio.author %]</h4>
|
||||
|
||||
[% IF ( LocalCoverImages == 1 ) %]
|
||||
[% IF ( images.size > 0 ) %]
|
||||
<div class="yui-u first">
|
||||
<div id="largeCover">
|
||||
<img id="largeCoverImg" alt="" src="/cgi-bin/koha/catalogue/image.pl?imagenumber=[% imagenumber %]" />
|
||||
</div></div>
|
||||
[% IF ( images.size > 0 ) %]
|
||||
<div class="yui-u first">
|
||||
<div id="largeCover">
|
||||
<img id="largeCoverImg" alt="" src="/cgi-bin/koha/catalogue/image.pl?imagenumber=[% imagenumber %]" />
|
||||
</div></div>
|
||||
|
||||
<div class="yui-u"><div id="thumbnails">
|
||||
<div class="yui-u"><div id="thumbnails">
|
||||
|
||||
[% FOREACH img IN images %]
|
||||
[% IF img %]
|
||||
<a href="/cgi-bin/koha/catalogue/imageviewer.pl?biblionumber=[% biblionumber %]&imagenumber=[% img %]" onclick="showCover([% img %]); return false;">
|
||||
[% IF ( imagenumber == img ) %]
|
||||
<img class="thumbnail selected" id="[% img %]" src="/cgi-bin/koha/catalogue/image.pl?imagenumber=[% img %]&thumbnail=1" alt="Thumbnail" />
|
||||
[% ELSE %]
|
||||
<img class="thumbnail" id="[% img %]" src="/cgi-bin/koha/catalogue/image.pl?imagenumber=[% img %]&thumbnail=1" alt="Thumbnail" />
|
||||
[% END %]
|
||||
</a>
|
||||
[% END %]
|
||||
[% END %]
|
||||
</div></div>
|
||||
[% FOREACH img IN images %]
|
||||
[% IF img %]
|
||||
<a href="/cgi-bin/koha/catalogue/imageviewer.pl?biblionumber=[% biblionumber %]&imagenumber=[% img %]" onclick="showCover([% img %]); return false;">
|
||||
[% IF ( imagenumber == img ) %]
|
||||
<img class="thumbnail selected" id="[% img %]" src="/cgi-bin/koha/catalogue/image.pl?imagenumber=[% img %]&thumbnail=1" alt="Thumbnail" />
|
||||
[% ELSE %]
|
||||
<img class="thumbnail" id="[% img %]" src="/cgi-bin/koha/catalogue/image.pl?imagenumber=[% img %]&thumbnail=1" alt="Thumbnail" />
|
||||
[% END %]
|
||||
</a>
|
||||
[% END %]
|
||||
[% END %]
|
||||
</div></div>
|
||||
|
||||
[% ELSE %]
|
||||
<div class="dialog message">There are no images for this record.</div>
|
||||
[% END %]
|
||||
[% ELSE %]
|
||||
<div class="dialog message">There are no images for this record.</div>
|
||||
[% END %]
|
||||
[% ELSE %]
|
||||
<div class="dialog message">Local images have not been enabled by your system administrator.</div>
|
||||
<div class="dialog message">Local images have not been enabled by your system administrator.</div>
|
||||
[% END %]
|
||||
|
||||
</div>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
//<![CDATA[
|
||||
|
||||
$(document).ready(function(){
|
||||
$("#largeCoverImg").attr("src","/opac-tmpl/prog/images/loading.gif");
|
||||
$("#largeCoverImg").attr("src","/opac-tmpl/prog/images/loading.gif");
|
||||
showCover([% imagenumber %]);
|
||||
});
|
||||
|
||||
|
@ -18,19 +18,19 @@ function showCover(img) {
|
|||
</script>
|
||||
<style type="text/css">
|
||||
#largeCoverImg {
|
||||
border : 1px solid #CCCCCC;
|
||||
display : block;
|
||||
margin : auto;
|
||||
padding : 1em;
|
||||
border : 1px solid #CCCCCC;
|
||||
display : block;
|
||||
margin : auto;
|
||||
padding : 1em;
|
||||
}
|
||||
#thumbnails {
|
||||
text-align : center;
|
||||
text-align : center;
|
||||
}
|
||||
#thumbnails a img {
|
||||
border : 2px solid #8EB3E7;
|
||||
border : 2px solid #8EB3E7;
|
||||
}
|
||||
img.thumbnail {
|
||||
display : block;
|
||||
display : block;
|
||||
float : none;
|
||||
padding : .5em;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ img.thumbnail {
|
|||
border-color: black;
|
||||
cursor : default;
|
||||
opacity:0.4;
|
||||
filter:alpha(opacity=40); /* For IE8 and earlier */
|
||||
filter:alpha(opacity=40); /* For IE8 and earlier */
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
@ -47,34 +47,34 @@ img.thumbnail {
|
|||
[% IF ( OpacNav ) %]<div id="doc3" class="yui-t1">[% ELSE %]<div id="doc3" class="yui-t7">[% END %]
|
||||
<div id="bd">
|
||||
[% INCLUDE 'masthead.inc' %]
|
||||
<div id="yui-main">
|
||||
<div class="yui-b">
|
||||
<div class="yui-ge">
|
||||
<div class="container">
|
||||
<h1 class="title">Images for [% IF ( BiblioDefaultViewmarc ) %]<a class="title" href="/cgi-bin/koha/opac-MARCdetail.pl?biblionumber=[% biblionumber |url %]" title="View details for this title">
|
||||
<div id="yui-main">
|
||||
<div class="yui-b">
|
||||
<div class="yui-ge">
|
||||
<div class="container">
|
||||
<h1 class="title">Images for [% IF ( BiblioDefaultViewmarc ) %]<a class="title" href="/cgi-bin/koha/opac-MARCdetail.pl?biblionumber=[% biblionumber |url %]" title="View details for this title">
|
||||
[% ELSE %]
|
||||
[% IF ( BiblioDefaultViewisbd ) %]<a class="title" href="/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber=[% biblionumber |url %]" title="View details for this title">
|
||||
[% ELSE %]<a class="title" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% biblionumber |url %]" title="View details for this title">
|
||||
[% END %]
|
||||
[% END %][% biblio.title %]</a> [% biblio.author %]</h1>
|
||||
<div class="yui-u first">
|
||||
<div class="yui-u first">
|
||||
|
||||
<div id="largeCover"><img id="largeCoverImg" alt="" src="/cgi-bin/koha/opac-image.pl?imagenumber=[% imagenumber %]" /></div></div>
|
||||
<div id="largeCover"><img id="largeCoverImg" alt="" src="/cgi-bin/koha/opac-image.pl?imagenumber=[% imagenumber %]" /></div></div>
|
||||
|
||||
[% IF OPACLocalCoverImages == 1 %]
|
||||
<div class="yui-u"><div id="thumbnails">
|
||||
[% FOREACH img IN images %]
|
||||
[% IF img %]
|
||||
<a href="/cgi-bin/koha/opac-imageviewer.pl?biblionumber=[% biblionumber %]&imagenumber=[% img %]" onclick="showCover([% img %]); return false;">
|
||||
[% IF ( imagenumber == img ) %]<img class="thumbnail selected" id="[% img %]" src="/cgi-bin/koha/opac-image.pl?imagenumber=[% img %]&thumbnail=1" alt="Thumbnail"/>
|
||||
[% ELSE %]
|
||||
<img class="thumbnail" id="[% img %]" src="/cgi-bin/koha/opac-image.pl?imagenumber=[% img %]&thumbnail=1" alt="Thumbnail"/>
|
||||
[% END %]
|
||||
</a>
|
||||
[% END %]
|
||||
[% END %]
|
||||
</div></div>
|
||||
</div>
|
||||
[% IF OPACLocalCoverImages == 1 %]
|
||||
<div class="yui-u"><div id="thumbnails">
|
||||
[% FOREACH img IN images %]
|
||||
[% IF img %]
|
||||
<a href="/cgi-bin/koha/opac-imageviewer.pl?biblionumber=[% biblionumber %]&imagenumber=[% img %]" onclick="showCover([% img %]); return false;">
|
||||
[% IF ( imagenumber == img ) %]<img class="thumbnail selected" id="[% img %]" src="/cgi-bin/koha/opac-image.pl?imagenumber=[% img %]&thumbnail=1" alt="Thumbnail"/>
|
||||
[% ELSE %]
|
||||
<img class="thumbnail" id="[% img %]" src="/cgi-bin/koha/opac-image.pl?imagenumber=[% img %]&thumbnail=1" alt="Thumbnail"/>
|
||||
[% END %]
|
||||
</a>
|
||||
[% END %]
|
||||
[% END %]
|
||||
</div></div>
|
||||
</div>
|
||||
[% ELSE %]
|
||||
Unfortunately, images are not enabled for this catalog at this time.
|
||||
[% END %]
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# Copyright (C) 2011 C & P Bibliography Services
|
||||
# Jared Camins-Esakov <jcamins@cpbibliograpy.com>
|
||||
#
|
||||
# based on patronimage.pl
|
||||
#
|
||||
# This file is part of Koha.
|
||||
|
@ -23,14 +26,14 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
|
||||
use CGI; #qw(:standard escapeHTML);
|
||||
use CGI;
|
||||
use C4::Context;
|
||||
use C4::Images;
|
||||
|
||||
$|=1;
|
||||
$| = 1;
|
||||
|
||||
my $DEBUG = 0;
|
||||
my $data = new CGI;
|
||||
my $data = new CGI;
|
||||
my $imagenumber;
|
||||
|
||||
=head1 NAME
|
||||
|
@ -57,17 +60,20 @@ imagenumber, a random image is selected.
|
|||
|
||||
error() unless C4::Context->preference("OPACLocalCoverImages");
|
||||
|
||||
if (defined $data->param('imagenumber')) {
|
||||
if ( defined $data->param('imagenumber') ) {
|
||||
$imagenumber = $data->param('imagenumber');
|
||||
} elsif (defined $data->param('biblionumber')) {
|
||||
my @imagenumbers = ListImagesForBiblio($data->param('biblionumber'));
|
||||
}
|
||||
elsif ( defined $data->param('biblionumber') ) {
|
||||
my @imagenumbers = ListImagesForBiblio( $data->param('biblionumber') );
|
||||
if (@imagenumbers) {
|
||||
$imagenumber = $imagenumbers[0];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
warn "No images for this biblio" if $DEBUG;
|
||||
error();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$imagenumber = shift;
|
||||
}
|
||||
|
||||
|
@ -79,25 +85,33 @@ if ($imagenumber) {
|
|||
|
||||
if ($imagedata) {
|
||||
my $image;
|
||||
if ($data->param('thumbnail')) {
|
||||
if ( $data->param('thumbnail') ) {
|
||||
$image = $imagedata->{'thumbnail'};
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$image = $imagedata->{'imagefile'};
|
||||
}
|
||||
print $data->header (-type => $imagedata->{'mimetype'}, -'Cache-Control' => 'no-store', -expires => 'now', -Content_Length => length ($image)), $image;
|
||||
print $data->header(
|
||||
-type => $imagedata->{'mimetype'},
|
||||
-'Cache-Control' => 'no-store',
|
||||
-expires => 'now',
|
||||
-Content_Length => length($image)
|
||||
), $image;
|
||||
exit;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
warn "No image exists for $imagenumber" if $DEBUG;
|
||||
error();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
error();
|
||||
}
|
||||
|
||||
error();
|
||||
|
||||
sub error {
|
||||
print $data->header ( -status=> '404', -expires => 'now' );
|
||||
print $data->header( -status => '404', -expires => 'now' );
|
||||
exit;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,19 +33,19 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
|
|||
query => $query,
|
||||
type => "opac",
|
||||
authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ),
|
||||
flagsrequired => { borrow => 1 },
|
||||
flagsrequired => { borrow => 1 },
|
||||
}
|
||||
);
|
||||
|
||||
my $biblionumber = $query->param('biblionumber') || $query->param('bib');
|
||||
my $imagenumber = $query->param('imagenumber');
|
||||
my ($count, $biblio) = GetBiblio($biblionumber);
|
||||
my ( $count, $biblio ) = GetBiblio($biblionumber);
|
||||
|
||||
if (C4::Context->preference("OPACLocalCoverImages")) {
|
||||
if ( C4::Context->preference("OPACLocalCoverImages") ) {
|
||||
my @images = ListImagesForBiblio($biblionumber);
|
||||
$template->{VARS}->{'OPACLocalCoverImages'} = 1;
|
||||
$template->{VARS}->{'images'} = \@images;
|
||||
$template->{VARS}->{'biblionumber'} = $biblionumber;
|
||||
$template->{VARS}->{'images'} = \@images;
|
||||
$template->{VARS}->{'biblionumber'} = $biblionumber;
|
||||
$template->{VARS}->{'imagenumber'} = $imagenumber || $images[0] || '';
|
||||
}
|
||||
|
||||
|
|
|
@ -13,12 +13,13 @@
|
|||
# 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., 59 Temple Place,
|
||||
# Suite 330, Boston, MA 02111-1307 USA
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
=head1 NAME
|
||||
|
||||
upload-cover-image.pl - Script for handling uploading of both single and bulk coverimages and importing them into the database.
|
||||
|
@ -36,7 +37,6 @@ resized, maintaining aspect ratio.
|
|||
|
||||
=cut
|
||||
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
|
@ -53,107 +53,127 @@ my $debug = 1;
|
|||
|
||||
my $input = new CGI;
|
||||
|
||||
my $fileID=$input->param('uploadedfileid');
|
||||
my ($template, $loggedinuser, $cookie)
|
||||
= get_template_and_user({template_name => "tools/upload-images.tmpl",
|
||||
query => $input,
|
||||
type => "intranet",
|
||||
authnotrequired => 0,
|
||||
flagsrequired => { tools => 'upload_cover_images'},
|
||||
debug => 0,
|
||||
});
|
||||
my $fileID = $input->param('uploadedfileid');
|
||||
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
|
||||
{
|
||||
template_name => "tools/upload-images.tmpl",
|
||||
query => $input,
|
||||
type => "intranet",
|
||||
authnotrequired => 0,
|
||||
flagsrequired => { tools => 'upload_cover_images' },
|
||||
debug => 0,
|
||||
}
|
||||
);
|
||||
|
||||
my $filetype = $input->param('filetype');
|
||||
my $biblionumber = $input->param('biblionumber');
|
||||
my $uploadfilename = $input->param('uploadfile');
|
||||
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;
|
||||
my $filetype = $input->param('filetype');
|
||||
my $biblionumber = $input->param('biblionumber');
|
||||
my $uploadfilename = $input->param('uploadfile');
|
||||
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;
|
||||
|
||||
my $error;
|
||||
|
||||
$template->{VARS}->{'filetype'} = $filetype;
|
||||
$template->{VARS}->{'filetype'} = $filetype;
|
||||
$template->{VARS}->{'biblionumber'} = $biblionumber;
|
||||
|
||||
my $total = 0;
|
||||
|
||||
|
||||
if ($fileID) {
|
||||
my $uploaded_file = C4::UploadedFile->fetch($sessionID, $fileID);
|
||||
if ($filetype eq 'image') {
|
||||
my $fh = $uploaded_file->fh();
|
||||
my $uploaded_file = C4::UploadedFile->fetch( $sessionID, $fileID );
|
||||
if ( $filetype eq 'image' ) {
|
||||
my $fh = $uploaded_file->fh();
|
||||
my $srcimage = GD::Image->new($fh);
|
||||
if (defined $srcimage) {
|
||||
my $dberror = PutImage($biblionumber, $srcimage, $replace);
|
||||
if ( defined $srcimage ) {
|
||||
my $dberror = PutImage( $biblionumber, $srcimage, $replace );
|
||||
if ($dberror) {
|
||||
$error = 'DBERR';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$total = 1;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$error = 'OPNIMG';
|
||||
}
|
||||
undef $srcimage;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
my $filename = $uploaded_file->filename();
|
||||
my $dirname = File::Temp::tempdir( CLEANUP => 1);
|
||||
unless (system("unzip", $filename, '-d', $dirname) == 0) {
|
||||
my $dirname = File::Temp::tempdir( CLEANUP => 1 );
|
||||
unless ( system( "unzip", $filename, '-d', $dirname ) == 0 ) {
|
||||
$error = 'UZIPFAIL';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
my @directories;
|
||||
push @directories, "$dirname";
|
||||
foreach my $recursive_dir ( @directories ) {
|
||||
foreach my $recursive_dir (@directories) {
|
||||
my $dir;
|
||||
opendir $dir, $recursive_dir;
|
||||
while ( my $entry = readdir $dir ) {
|
||||
push @directories, "$recursive_dir/$entry" if ( -d "$recursive_dir/$entry" and $entry !~ /^[._]/ );
|
||||
push @directories, "$recursive_dir/$entry"
|
||||
if ( -d "$recursive_dir/$entry" and $entry !~ /^[._]/ );
|
||||
}
|
||||
closedir $dir;
|
||||
}
|
||||
foreach my $dir ( @directories ) {
|
||||
foreach my $dir (@directories) {
|
||||
my $file;
|
||||
if ( -e "$dir/idlink.txt" ) {
|
||||
$file = "$dir/idlink.txt";
|
||||
} elsif ( -e "$dir/datalink.txt" ) {
|
||||
}
|
||||
elsif ( -e "$dir/datalink.txt" ) {
|
||||
$file = "$dir/datalink.txt";
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
next;
|
||||
}
|
||||
if (open (FILE, $file)) {
|
||||
while (my $line = <FILE>) {
|
||||
my $delim = ($line =~ /\t/) ? "\t" : ($line =~ /,/) ? "," : "";
|
||||
if ( open( FILE, $file ) ) {
|
||||
while ( my $line = <FILE> ) {
|
||||
my $delim =
|
||||
( $line =~ /\t/ ) ? "\t"
|
||||
: ( $line =~ /,/ ) ? ","
|
||||
: "";
|
||||
|
||||
#$debug and warn "Delimeter is \'$delim\'";
|
||||
unless ( $delim eq "," || $delim eq "\t" ) {
|
||||
warn "Unrecognized or missing field delimeter. Please verify that you are using either a ',' or a 'tab'";
|
||||
warn
|
||||
"Unrecognized or missing field delimeter. Please verify that you are using either a ',' or a 'tab'";
|
||||
$error = 'DELERR';
|
||||
} else {
|
||||
($biblionumber, $filename) = split $delim, $line;
|
||||
$biblionumber =~ s/[\"\r\n]//g; # remove offensive characters
|
||||
$filename =~ s/[\"\r\n\s]//g;
|
||||
}
|
||||
else {
|
||||
( $biblionumber, $filename ) = split $delim, $line;
|
||||
$biblionumber =~
|
||||
s/[\"\r\n]//g; # remove offensive characters
|
||||
$filename =~ s/[\"\r\n\s]//g;
|
||||
my $srcimage = GD::Image->new("$dir/$filename");
|
||||
if (defined $srcimage) {
|
||||
if ( defined $srcimage ) {
|
||||
$total++;
|
||||
my $dberror = PutImage($biblionumber, $srcimage, $replace);
|
||||
my $dberror =
|
||||
PutImage( $biblionumber, $srcimage,
|
||||
$replace );
|
||||
if ($dberror) {
|
||||
$error = 'DBERR';
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$error = 'OPNIMG';
|
||||
}
|
||||
undef $srcimage;
|
||||
}
|
||||
}
|
||||
close(FILE);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$error = 'OPNLINK';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$template->{VARS}->{'total'} = $total;
|
||||
$template->{VARS}->{'uploadimage'} = 1;
|
||||
$template->{VARS}->{'error'} = $error;
|
||||
$template->{VARS}->{'total'} = $total;
|
||||
$template->{VARS}->{'uploadimage'} = 1;
|
||||
$template->{VARS}->{'error'} = $error;
|
||||
$template->{VARS}->{'biblionumber'} = $biblionumber;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue