From 30950409865df8d782dc34ec431e15cee7646041 Mon Sep 17 00:00:00 2001 From: Jesse Weaver Date: Wed, 20 Aug 2008 13:21:50 -0500 Subject: [PATCH] fix for bug 1771: Template errors with remote itemtype image This adds a new function, getitemtypeimagelocation, that returns the image unmodified for absolute urls and returns the proper intranet or opac path otherwise. It also updates all of the relevant files to use that function. Signed-off-by: Galen Charlton --- C4/Koha.pm | 2 +- C4/Search.pm | 3 +-- catalogue/detail.pl | 6 +++--- catalogue/search.pl | 2 ++ members/moremember.pl | 2 +- opac/opac-search.pl | 24 +++++++++++++----------- 6 files changed, 21 insertions(+), 18 deletions(-) diff --git a/C4/Koha.pm b/C4/Koha.pm index 3589010b0f..eb14e6dac8 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -485,7 +485,7 @@ sub getitemtypeimagesrc { sub getitemtypeimagelocation($$) { my ( $src, $image ) = @_; - return '' if ( !$image ); + return if ( !$image ); my $scheme = ( uri_split( $image ) )[0]; diff --git a/C4/Search.pm b/C4/Search.pm index bef20e6017..56e50a091a 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1266,7 +1266,7 @@ sub searchResults { (my $aisbn) = $oldbiblio->{isbn} =~ /([\d-]*[X]*)/; $aisbn =~ s/-//g; $oldbiblio->{amazonisbn} = $aisbn; - $oldbiblio->{description} = $itemtypes{ $oldbiblio->{itemtype} }->{description}; + $oldbiblio->{description} = $itemtypes{ $oldbiblio->{itemtype} }->{description}; # Build summary if there is one (the summary is defined in the itemtypes table) # FIXME: is this used anywhere, I think it can be commented out? -- JF if ( $itemtypes{ $oldbiblio->{itemtype} }->{summary} ) { @@ -1469,7 +1469,6 @@ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g; $other_items->{$key}->{$_} = $item->{$_}; } } - if($item->{notforloan} == 1){ $notforloan_count++; diff --git a/catalogue/detail.pl b/catalogue/detail.pl index d21b8a7a4d..a0b1529336 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -115,9 +115,9 @@ foreach my $item (@items) { $item->{imageurl} = defined $item->{itype} ? getitemtypeimagelocation('intranet', $itemtypes->{ $item->{itype} }{imageurl}) : ''; - foreach (qw(datedue datelastseen onloan)) { - $item->{$_} = format_date($item->{$_}); - } + foreach (qw(datedue datelastseen onloan)) { + $item->{$_} = format_date($item->{$_}); + } # item damaged, lost, withdrawn loops $item->{itemlostloop} = GetAuthorisedValues($authvalcode_items_itemlost, $item->{itemlost}) if $authvalcode_items_itemlost; if ($item->{damaged}) { diff --git a/catalogue/search.pl b/catalogue/search.pl index a5beb6d0b4..2a761d4a9d 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -228,6 +228,7 @@ 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=> getitemtypeimagelocation( 'intranet', $itemtypes->{$thisitemtype}->{'imageurl'} ), ccl => $itype_or_itemtype, code => $thisitemtype, selected => $selected, @@ -244,6 +245,7 @@ if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') { for my $thisitemtype (@$advsearchtypes) { my %row =( number=>$cnt++, + 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 151f9c2a30..fe9ecf4785 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -243,7 +243,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-search.pl b/opac/opac-search.pl index 1a8d07cb49..72fa0af09e 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -147,7 +147,8 @@ 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++, - ccl => $itype_or_itemtype, + imageurl=> getitemtypeimagelocation( 'opac', $itemtypes->{$thisitemtype}->{'imageurl'} ), + ccl => $itype_or_itemtype, code => $thisitemtype, selected => $selected, description => $itemtypes->{$thisitemtype}->{'description'}, @@ -161,16 +162,17 @@ if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') { } else { my $advsearchtypes = GetAuthorisedValues($advanced_search_types); for my $thisitemtype (@$advsearchtypes) { - my %row =( - number=>$cnt++, - ccl => $advanced_search_types, - code => $thisitemtype->{authorised_value}, - selected => $selected, - description => $thisitemtype->{'lib'}, - count5 => $cnt % 4, - imageurl=> getitemtypeimagelocation( 'opac', $thisitemtype->{'imageurl'} ), - ); - push @itemtypesloop, \%row; + my %row =( + number=>$cnt++, + imageurl=> getitemtypeimagelocation( 'opac', $thisitemtype->{'imageurl'} ), + ccl => $advanced_search_types, + code => $thisitemtype->{authorised_value}, + selected => $selected, + description => $thisitemtype->{'lib'}, + count5 => $cnt % 4, + imageurl=> getitemtypeimagelocation( 'opac', $thisitemtype->{'imageurl'} ), + ); + push @itemtypesloop, \%row; } $template->param(itemtypeloop => \@itemtypesloop); } -- 2.39.5