X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=opac%2Fopac-detail.pl;h=0301a5a8960cf790598a0ea9e06bcd6d18d30e8c;hb=9c84f38b3496f32037a97b441aab21e8c2647250;hp=93edc15e8a0cd202410e5d2f0e7c471e51c1ae06;hpb=1e98195b1014f9b0680be9d6ea9e8e8132821158;p=koha_gimpoz diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index 93edc15e8a..0301a5a896 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -1,6 +1,7 @@ #!/usr/bin/perl # Copyright 2000-2002 Katipo Communications +# Copyright 2010 BibLibre # # This file is part of Koha. # @@ -40,6 +41,10 @@ use C4::Members; use C4::VirtualShelves; use C4::XSLT; use C4::ShelfBrowser; +use C4::Charset; +use MARC::Record; +use MARC::Field; +use List::MoreUtils qw/any none/; BEGIN { if (C4::Context->preference('BakerTaylorEnabled')) { @@ -70,6 +75,9 @@ if ( ! $record ) { exit; } $template->param( biblionumber => $biblionumber ); + +SetUTF8Flag($record); + # XSLT processing of some stuff if (C4::Context->preference("OPACXSLTDetailsDisplay") ) { $template->param( 'XSLTBloc' => XSLTParse4Display($biblionumber, $record, 'Detail', 'opac') ); @@ -77,16 +85,50 @@ if (C4::Context->preference("OPACXSLTDetailsDisplay") ) { $template->param('OPACShowCheckoutName' => C4::Context->preference("OPACShowCheckoutName") ); # change back when ive fixed request.pl -my @all_items = &GetItemsInfo( $biblionumber, 'opac' ); +my @all_items = GetItemsInfo( $biblionumber ); + +# adding items linked via host biblios +my $marcflavour = C4::Context->preference("marcflavour"); + +my $analyticfield = '773'; +if ($marcflavour eq 'MARC21' || $marcflavour eq 'NORMARC'){ + $analyticfield = '773'; +} elsif ($marcflavour eq 'UNIMARC') { + $analyticfield = '461'; +} +foreach my $hostfield ( $record->field($analyticfield)) { + my $hostbiblionumber = $hostfield->subfield("0"); + my $linkeditemnumber = $hostfield->subfield("9"); + my @hostitemInfos = GetItemsInfo($hostbiblionumber); + foreach my $hostitemInfo (@hostitemInfos){ + if ($hostitemInfo->{itemnumber} eq $linkeditemnumber){ + push(@all_items, $hostitemInfo); + } + } +} + my @items; -@items = @all_items unless C4::Context->preference('hidelostitems'); -if (C4::Context->preference('hidelostitems')) { - # Hide host items +# Getting items to be hidden +my @hiddenitems = GetHiddenItemnumbers(@all_items); + +# Are there items to hide? +my $hideitems = 1 if C4::Context->preference('hidelostitems') or scalar(@hiddenitems) > 0; + +# Hide items +if ($hideitems) { for my $itm (@all_items) { - push @items, $itm unless $itm->{itemlost}; + if ( C4::Context->preference('hidelostitems') ) { + push @items, $itm unless $itm->{itemlost} or any { $itm->{'itemnumber'} eq $_ } @hiddenitems; + } else { + push @items, $itm unless any { $itm->{'itemnumber'} eq $_ } @hiddenitems; } } +} else { + # Or not + @items = @all_items; +} + my $dat = &GetBiblioData($biblionumber); my $itemtypes = GetItemTypes(); @@ -101,7 +143,7 @@ my $collections = GetKohaAuthorisedValues('items.ccode',$dat->{'frameworkcode'} #coping with subscriptions my $subscriptionsnumber = CountSubscriptionFromBiblionumber($biblionumber); -my @subscriptions = GetSubscriptions( $dat->{title}, $dat->{issn}, $biblionumber ); +my @subscriptions = GetSubscriptions( undef, undef, $biblionumber ); my @subs; $dat->{'serial'}=1 if $subscriptionsnumber; @@ -196,13 +238,13 @@ for my $itm (@items) { ## get notes and subjects from MARC record my $dbh = C4::Context->dbh; -my $marcflavour = C4::Context->preference("marcflavour"); my $marcnotesarray = GetMarcNotes ($record,$marcflavour); my $marcisbnsarray = GetMarcISBN ($record,$marcflavour); my $marcauthorsarray = GetMarcAuthors ($record,$marcflavour); my $marcsubjctsarray = GetMarcSubjects($record,$marcflavour); my $marcseriesarray = GetMarcSeries ($record,$marcflavour); my $marcurlsarray = GetMarcUrls ($record,$marcflavour); +my $marchostsarray = GetMarcHosts($record,$marcflavour); my $subtitle = GetRecordValue('subtitle', $record, GetFrameworkCode($biblionumber)); $template->param( @@ -211,6 +253,7 @@ my $subtitle = GetRecordValue('subtitle', $record, GetFrameworkCode($bib MARCAUTHORS => $marcauthorsarray, MARCSERIES => $marcseriesarray, MARCURLS => $marcurlsarray, + MARCHOSTS => $marchostsarray, norequests => $norequests, RequestOnOpac => C4::Context->preference("RequestOnOpac"), itemdata_ccode => $itemfields{ccode}, @@ -222,6 +265,33 @@ my $subtitle = GetRecordValue('subtitle', $record, GetFrameworkCode($bib subtitle => $subtitle, ); +if (C4::Context->preference("AlternateHoldingsField") && scalar @items == 0) { + my $fieldspec = C4::Context->preference("AlternateHoldingsField"); + my $subfields = substr $fieldspec, 3; + my $holdingsep = C4::Context->preference("AlternateHoldingsSeparator") || ' '; + my @alternateholdingsinfo = (); + my @holdingsfields = $record->field(substr $fieldspec, 0, 3); + + for my $field (@holdingsfields) { + my %holding = ( holding => '' ); + my $havesubfield = 0; + for my $subfield ($field->subfields()) { + if ((index $subfields, $$subfield[0]) >= 0) { + $holding{'holding'} .= $holdingsep if (length $holding{'holding'} > 0); + $holding{'holding'} .= $$subfield[1]; + $havesubfield++; + } + } + if ($havesubfield) { + push(@alternateholdingsinfo, \%holding); + } + } + + $template->param( + ALTERNATEHOLDINGS => \@alternateholdingsinfo, + ); +} + foreach ( keys %{$dat} ) { $template->param( "$_" => defined $dat->{$_} ? $dat->{$_} : '' ); } @@ -233,7 +303,10 @@ my $upc = GetNormalizedUPC($record,$marcflavour); my $ean = GetNormalizedEAN($record,$marcflavour); my $oclc = GetNormalizedOCLCNumber($record,$marcflavour); my $isbn = GetNormalizedISBN(undef,$record,$marcflavour); -my $content_identifier_exists = 1 if ($isbn or $ean or $oclc or $upc); +my $content_identifier_exists; +if ( $isbn or $ean or $oclc or $upc ) { + $content_identifier_exists = 1; +} $template->param( normalized_upc => $upc, normalized_ean => $ean, @@ -247,6 +320,12 @@ $template->param( ocoins => GetCOinSBiblio($biblionumber), ); +my $libravatar_enabled = 0; +eval 'use Libravatar::URL'; +if (!$@ and C4::Context->preference('ShowReviewer') and C4::Context->preference('ShowReviewerPhoto')) { + $libravatar_enabled = 1; +} + my $reviews = getreviews( $biblionumber, 1 ); my $loggedincommenter; foreach ( @$reviews ) { @@ -255,6 +334,9 @@ foreach ( @$reviews ) { $_->{title} = $borrowerData->{'title'}; $_->{surname} = $borrowerData->{'surname'}; $_->{firstname} = $borrowerData->{'firstname'}; + if ($libravatar_enabled and $borrowerData->{'email'}) { + $_->{avatarurl} = libravatar_url(email => $borrowerData->{'email'}, https => $ENV{HTTPS}); + } $_->{userid} = $borrowerData->{'userid'}; $_->{cardnumber} = $borrowerData->{'cardnumber'}; $_->{datereviewed} = format_date($_->{datereviewed}); @@ -434,6 +516,14 @@ $template->param(LibraryThingForLibrariesTabbedView => C4::Context->preference('LibraryThingForLibrariesTabbedView') ); } +# Novelist Select +if( C4::Context->preference('NovelistSelectEnabled') ) +{ +$template->param(NovelistSelectProfile => C4::Context->preference('NovelistSelectProfile') ); +$template->param(NovelistSelectPassword => C4::Context->preference('NovelistSelectPassword') ); +$template->param(NovelistSelectView => C4::Context->preference('NovelistSelectView') ); +} + # Babelthèque if ( C4::Context->preference("Babeltheque") ) { @@ -514,6 +604,7 @@ if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){ $dat->{title} ? $search_for_title =~ s/{TITLE}/$dat->{title}/g : $search_for_title =~ s/{TITLE}//g; $isbn ? $search_for_title =~ s/{ISBN}/$isbn/g : $search_for_title =~ s/{ISBN}//g; $marccontrolnumber ? $search_for_title =~ s/{CONTROLNUMBER}/$marccontrolnumber/g : $search_for_title =~ s/{CONTROLNUMBER}//g; + $search_for_title =~ s/{BIBLIONUMBER}/$biblionumber/g; $template->param('OPACSearchForTitleIn' => $search_for_title); }