diff --git a/C4/Items.pm b/C4/Items.pm index a0d2a4bac4..d785dc5e7e 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -1419,7 +1419,7 @@ sub get_authorised_value_images { && $authorised_values->{ $this_authorised_value->{'category'} } eq $this_authorised_value->{'authorised_value'} ) { # warn ( Data::Dumper->Dump( [ $this_authorised_value ], [ 'this_authorised_value' ] ) ); if ( defined $this_authorised_value->{'imageurl'} ) { - push @imagelist, { imageurl => C4::Koha::getitemtypeimagesrc( 'intranet' ) . '/' . $this_authorised_value->{'imageurl'}, + push @imagelist, { imageurl => C4::Koha::getitemtypeimagelocation( 'intranet', $this_authorised_value->{'imageurl'} ), label => $this_authorised_value->{'lib'}, category => $this_authorised_value->{'category'}, value => $this_authorised_value->{'authorised_value'}, }; diff --git a/C4/Koha.pm b/C4/Koha.pm index 687448dd00..a32062a2f2 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -21,6 +21,7 @@ package C4::Koha; use strict; use C4::Context; use C4::Output; +use URI::Split qw(uri_split); use vars qw($VERSION @ISA @EXPORT $DEBUG); @@ -47,6 +48,7 @@ BEGIN { &get_notforloan_label_of &getitemtypeimagedir &getitemtypeimagesrc + &getitemtypeimagelocation &GetAuthorisedValues &GetAuthorisedValueCategories &GetKohaAuthorisedValues @@ -493,6 +495,18 @@ sub getitemtypeimagesrc { } } +sub getitemtypeimagelocation($$) { + my ( $src, $image ) = @_; + + return if ( !$image ); + + my $scheme = ( uri_split( $image ) )[0]; + + return $image if ( $scheme ); + + return getitemtypeimagesrc( $src ) . '/' . $image; +} + =head3 _getImagesFromDirectory Find all of the image files in a directory in the filesystem diff --git a/C4/Search.pm b/C4/Search.pm index 1509f49099..8e0a6b0521 100755 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1262,15 +1262,8 @@ sub searchResults { $oldbiblio->{result_number} = $i + 1; # add imageurl to itemtype if there is one - if ( $itemtypes{ $oldbiblio->{itemtype} }->{imageurl} =~ /^http:/ ) { - $oldbiblio->{imageurl} = - $itemtypes{ $oldbiblio->{itemtype} }->{imageurl}; - } else { - $oldbiblio->{imageurl} = - getitemtypeimagesrc() . "/" - . $itemtypes{ $oldbiblio->{itemtype} }->{imageurl} - if ( $itemtypes{ $oldbiblio->{itemtype} }->{imageurl} ); - } + $oldbiblio->{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes{ $oldbiblio->{itemtype} }->{imageurl} ); + my $biblio_authorised_value_images = C4::Items::get_authorised_value_images( C4::Biblio::get_biblio_authorised_values( $oldbiblio->{biblionumber} ) ); $oldbiblio->{authorised_value_images} = $biblio_authorised_value_images; my $aisbn = $oldbiblio->{'isbn'}; @@ -1404,7 +1397,7 @@ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g; $onloan_items->{$key}->{branchname} = $item->{branchname}; $onloan_items->{$key}->{location} = $shelflocations->{ $item->{location} }; $onloan_items->{$key}->{itemcallnumber} = $item->{itemcallnumber}; - $onloan_items->{$key}->{imageurl} = getitemtypeimagesrc() . "/" . $itemtypes{ $item->{itype} }->{imageurl}; + $onloan_items->{$key}->{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes{ $item->{itype} }->{imageurl} ); # if something's checked out and lost, mark it as 'long overdue' if ( $item->{itemlost} ) { $onloan_items->{$prefix}->{longoverdue}++; @@ -1469,7 +1462,7 @@ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g; $other_items->{$key}->{notforloan} = GetAuthorisedValueDesc('','',$item->{notforloan},'','',$notforloan_authorised_value) if $notforloan_authorised_value; $other_items->{$key}->{count}++ if $item->{homebranch}; $other_items->{$key}->{location} = $shelflocations->{ $item->{location} }; - $other_items->{$key}->{imageurl} = getitemtypeimagesrc() . "/" . $itemtypes{ $item->{itype} }->{imageurl}; + $other_items->{$key}->{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes{ $item->{itype} }->{imageurl} ); } # item is available else { @@ -1480,7 +1473,7 @@ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g; $available_items->{$prefix}->{$_} = $item->{$_}; } $available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} }; - $available_items->{$prefix}->{imageurl} = getitemtypeimagesrc() . "/" . $itemtypes{ $item->{itype} }->{imageurl}; + $available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes{ $item->{itype} }->{imageurl} ); } } } # notforloan, item level and biblioitem level diff --git a/admin/authorised_values.pl b/admin/authorised_values.pl index 49e68b0ae6..ee57abd5bf 100755 --- a/admin/authorised_values.pl +++ b/admin/authorised_values.pl @@ -247,7 +247,7 @@ sub default_form { $row_data{category} = $results->[$i]{'category'}; $row_data{authorised_value} = $results->[$i]{'authorised_value'}; $row_data{lib} = $results->[$i]{'lib'}; - $row_data{imageurl} = getitemtypeimagesrc('intranet') . '/' . $results->[$i]{'imageurl'}; + $row_data{imageurl} = getitemtypeimagelocation( 'intranet', $results->[$i]{'imageurl'} ); $row_data{edit} = "$script_name?op=add_form&id=".$results->[$i]{'id'}; $row_data{delete} = "$script_name?op=delete_confirm&searchfield=$searchfield&id=".$results->[$i]{'id'}; push(@loop_data, \%row_data); diff --git a/admin/itemtypes.pl b/admin/itemtypes.pl index f7d8d8912b..345e172299 100755 --- a/admin/itemtypes.pl +++ b/admin/itemtypes.pl @@ -244,7 +244,7 @@ else { # DEFAULT my @loop; foreach my $itemtype ( @{$results}[ $first .. $last ] ) { $itemtype->{toggle} = ($toggle++ % 2) ? 0 : 1 ; - $itemtype->{imageurl} = getitemtypeimagesrc('intranet') . "/$itemtype->{imageurl}"; + $itemtype->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtype->{imageurl} ); $itemtype->{rentalcharge} = sprintf( '%.2f', $itemtype->{rentalcharge} ); push( @loop, $itemtype ); } diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 7dd96dd377..7d1be059af 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -93,7 +93,7 @@ foreach my $subscription (@subscriptions) { GetLatestSerials( $subscription->{subscriptionid}, 3 ); push @subs, \%cell; } -$dat->{imageurl} = getitemtypeimagesrc() . "/".$itemtypes->{ $dat->{itemtype} }{imageurl}; +$dat->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $dat->{itemtype} }{imageurl} ); $dat->{'count'} = scalar @items; my $shelflocations = GetKohaAuthorisedValues('items.location', $fw); my $collections = GetKohaAuthorisedValues('items.ccode' , $fw); @@ -106,7 +106,7 @@ foreach my $item (@items) { # format some item fields for display $item->{ $item->{'publictype'} } = 1; - $item->{imageurl} = getitemtypeimagesrc() . "/".$itemtypes->{ $item->{itype} }{imageurl}; + $item->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $item->{itype} }{imageurl} ); foreach (qw(datedue datelastseen onloan)) { $item->{$_} = format_date($item->{$_}); } diff --git a/catalogue/search.pl b/catalogue/search.pl index d6f6788376..af541d010f 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -224,12 +224,11 @@ my $itype_or_itemtype = (C4::Context->preference("item-level_itypes"))?'itype':' my @itemtypesloop; my $selected=1; my $cnt; -my $imgdir = getitemtypeimagesrc('intranet'); my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes"); if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') { foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) { my %row =( number=>$cnt++, - imageurl=> $itemtypes->{$thisitemtype}->{'imageurl'}?($imgdir."/".$itemtypes->{$thisitemtype}->{'imageurl'}):"", + imageurl=> getitemtypeimagelocation( 'intranet', $itemtypes->{$thisitemtype}->{'imageurl'} ), ccl => $itype_or_itemtype, code => $thisitemtype, selected => $selected, @@ -245,7 +244,7 @@ if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') { for my $thisitemtype (@$advsearchtypes) { my %row =( number=>$cnt++, - imageurl=> $thisitemtype->{'imageurl'}?($imgdir."/".$thisitemtype->{'imageurl'}):"", + imageurl=> getitemtypeimagelocation( 'intranet', $thisitemtype->{'imageurl'} ), ccl => $advanced_search_types, code => $thisitemtype->{authorised_value}, selected => $selected, diff --git a/members/moremember.pl b/members/moremember.pl index 3919eb1b45..e2e25cf3e2 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -240,7 +240,7 @@ for ( my $i = 0 ; $i < $count ; $i++ ) { my $itemtypeinfo = getitemtypeinfo($itemtype); $row{'itemtype_description'} = $itemtypeinfo->{description}; - $row{'itemtype_image'} = $itemtypeinfo->{imageurl}; + $row{'itemtype_image'} = getitemtypelocation( 'opac', $itemtypeinfo->{imageurl} ); $row{'charge'} = sprintf( "%.2f", $charge ); diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 4370ec3284..c2909f22ff 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -81,12 +81,11 @@ if (!$dat) { print $query->redirect("/cgi-bin/koha/errors/404.pl"); exit; } -my $imgdir = getitemtypeimagesrc(); my $itemtypes = GetItemTypes(); # imageurl: my $itemtype = $dat->{'itemtype'}; if ( $itemtype ) { - $dat->{'imageurl'} = $imgdir."/".$itemtypes->{$itemtype}->{'imageurl'}; + $dat->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{$itemtype}->{'imageurl'} ); $dat->{'description'} = $itemtypes->{$itemtype}->{'description'}; } my $shelflocations =GetKohaAuthorisedValues('items.location',$dat->{'frameworkcode'}); @@ -139,7 +138,7 @@ for my $itm (@items) { my $ccode= $itm->{'ccode'}; $itm->{'ccode'} = $collections->{$ccode} if(defined($collections) && exists($collections->{$ccode})); $itm->{'location_description'} = $shelflocations->{$itm->{'location'} }; - $itm->{'imageurl'} = $imgdir."/".$itemtypes->{ $itm->{itype} }->{'imageurl'}; + $itm->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{ $itm->{itype} }->{'imageurl'} ); $itm->{'description'} = $itemtypes->{$itemtype}->{'description'}; $itemfields{ccode} = 1 if($itm->{ccode}); $itemfields{enumchron} = 1 if($itm->{enumchron}); diff --git a/opac/opac-readingrecord.pl b/opac/opac-readingrecord.pl index 7a9abbea3d..648532b275 100755 --- a/opac/opac-readingrecord.pl +++ b/opac/opac-readingrecord.pl @@ -45,7 +45,6 @@ my ( $borr ) = GetMemberDetails( $borrowernumber ); $template->param($borr); -my $imgdir = getitemtypeimagesrc(); my $itemtypes = GetItemTypes(); # get the record @@ -116,7 +115,7 @@ for ( my $i = 0 ; $i < $count ; $i++ ) { $line{volumeddesc} = $issues->[$i]->{'volumeddesc'}; $line{counter} = $i + 1; $line{'description'} = $itemtypes->{ $issues->[$i]->{'itemtype'} }->{'description'}; - $line{imageurl} = $imgdir."/".$itemtypes->{ $issues->[$i]->{'itemtype'} }->{'imageurl'}; + $line{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes->{ $issues->[$i]->{'itemtype'} }->{'imageurl'} ); push( @loop_reading, \%line ); } diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index 30342a13e6..bfd6a2f517 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -423,7 +423,7 @@ foreach my $biblioitemnumber (@biblioitemnumbers) { while (my $wait_hashref = $sth2->fetchrow_hashref) { $item->{waitingdate} = format_date($wait_hashref->{waitingdate}); } - $item->{imageurl} = getitemtypeimagesrc() . "/".$itemtypes->{ $item->{itype} }{imageurl}; + $item->{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes->{ $item->{itype} }{imageurl} ); push @{ $biblioitem->{itemloop} }, $item; } diff --git a/opac/opac-search.pl b/opac/opac-search.pl index ed8c358cbb..5f5086127b 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -133,13 +133,12 @@ my $itype_or_itemtype = (C4::Context->preference("item-level_itypes"))?'itype':' my @itemtypesloop; my $selected=1; my $cnt; -my $imgdir = getitemtypeimagesrc('opac'); my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes"); if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') { foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) { my %row =( number=>$cnt++, - imageurl=> $itemtypes->{$thisitemtype}->{'imageurl'}?($imgdir."/".$itemtypes->{$thisitemtype}->{'imageurl'}):"", + imageurl=> getitemtypeimagelocation( 'opac', $itemtypes->{$thisitemtype}->{'imageurl'} ), ccl => $itype_or_itemtype, code => $thisitemtype, selected => $selected, @@ -155,7 +154,7 @@ if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') { for my $thisitemtype (@$advsearchtypes) { my %row =( number=>$cnt++, - imageurl=> $thisitemtype->{'imageurl'}?($imgdir."/".$thisitemtype->{'imageurl'}):"", + imageurl=> getitemtypeimagelocation( 'opac', $thisitemtype->{'imageurl'} ), ccl => $advanced_search_types, code => $thisitemtype->{authorised_value}, selected => $selected, diff --git a/opac/opac-user.pl b/opac/opac-user.pl index 13ebb1ee66..6aefc6d19d 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -88,7 +88,6 @@ my $toggle = 0; my $overdues_count = 0; my @overdues; my @issuedat; -my $imgdir = getitemtypeimagesrc(); my $itemtypes = GetItemTypes(); foreach my $issue ( @$issues ) { if($count%2 eq 0){ $issue->{'toggle'} = 1; } else { $issue->{'toggle'} = 0; } @@ -132,7 +131,7 @@ foreach my $issue ( @$issues ) { # imageurl: my $itemtype = $issue->{'itemtype'}; if ( $itemtype ) { - $issue->{'imageurl'} = $imgdir."/".$itemtypes->{$itemtype}->{'imageurl'}; + $issue->{'imageurl'} = getitemtypeimagelocation( 'opac', $itemtypes->{$itemtype}->{'imageurl'} ); $issue->{'description'} = $itemtypes->{$itemtype}->{'description'}; } $issue->{date_due} = format_date($issue->{date_due}); diff --git a/reserve/request.pl b/reserve/request.pl index a2abe4aad3..c6438b8460 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -255,7 +255,7 @@ foreach my $biblioitemnumber (@biblioitemnumbers) { { my $item = $iteminfos_of->{$itemnumber}; $item->{itypename} = $itemtypes->{ $item->{itype} }{description}; - $item->{imageurl} = getitemtypeimagesrc() . "/".$itemtypes->{ $item->{itype} }{imageurl}; + $item->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $item->{itype} }{imageurl} ); $item->{homebranchname} = $branches->{ $item->{homebranch} }{branchname}; diff --git a/serials/subscription-bib-search.pl b/serials/subscription-bib-search.pl index fa203f3c1a..2a83d3e2e2 100755 --- a/serials/subscription-bib-search.pl +++ b/serials/subscription-bib-search.pl @@ -180,7 +180,6 @@ if ($op eq "do_search" && $query) { my @itemtypesloop; my $selected=1; my $cnt; - my $imgdir = getitemtypeimagesrc('intranet'); foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) { my %row =( code => $thisitemtype, @@ -207,7 +206,6 @@ if ($op eq "do_search" && $query) { my @itemtypesloop; my $selected=1; my $cnt; - my $imgdir = getitemtypeimagesrc('intranet'); foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) { my %row =( code => $thisitemtype,