Lines 86-95
my $biblionumber = $query->param('biblionumber');
Link Here
|
86 |
$biblionumber = HTML::Entities::encode($biblionumber); |
86 |
$biblionumber = HTML::Entities::encode($biblionumber); |
87 |
# FIXME Special case here |
87 |
# FIXME Special case here |
88 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
88 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
89 |
my $record = $biblio->metadata->record; |
|
|
90 |
$template->param( 'biblio', $biblio ); |
89 |
$template->param( 'biblio', $biblio ); |
91 |
|
90 |
|
92 |
if ( not defined $record ) { |
91 |
unless ( $biblio ) { |
93 |
# biblionumber invalid -> report and exit |
92 |
# biblionumber invalid -> report and exit |
94 |
$template->param( unknownbiblionumber => 1, |
93 |
$template->param( unknownbiblionumber => 1, |
95 |
biblionumber => $biblionumber ); |
94 |
biblionumber => $biblionumber ); |
Lines 98-104
if ( not defined $record ) {
Link Here
|
98 |
} |
97 |
} |
99 |
|
98 |
|
100 |
my $marc_record = eval { $biblio->metadata->record }; |
99 |
my $marc_record = eval { $biblio->metadata->record }; |
101 |
$template->param( decoding_error => $@ ); |
100 |
my $invalid_marc_record = $@ || !$marc_record; |
|
|
101 |
if ($invalid_marc_record) { |
102 |
$template->param( decoding_error => $@ ); |
103 |
my $marc_xml = C4::Charset::StripNonXmlChars( $biblio->metadata->metadata ); |
104 |
|
105 |
$marc_record = eval { |
106 |
MARC::Record::new_from_xml( $marc_xml, 'UTF-8', |
107 |
C4::Context->preference('marcflavour') ); |
108 |
}; |
109 |
} |
102 |
|
110 |
|
103 |
if($query->cookie("holdfor")){ |
111 |
if($query->cookie("holdfor")){ |
104 |
my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") ); |
112 |
my $holdfor_patron = Koha::Patrons->find( $query->cookie("holdfor") ); |
Lines 127-144
my $marcflavour = C4::Context->preference("marcflavour");
Link Here
|
127 |
|
135 |
|
128 |
$template->param( 'SpineLabelShowPrintOnBibDetails' => C4::Context->preference("SpineLabelShowPrintOnBibDetails") ); |
136 |
$template->param( 'SpineLabelShowPrintOnBibDetails' => C4::Context->preference("SpineLabelShowPrintOnBibDetails") ); |
129 |
|
137 |
|
130 |
# Catch the exception as Koha::Biblio::Metadata->record can explode if the MARCXML is invalid |
138 |
$template->param( ocoins => !$invalid_marc_record ? $biblio->get_coins : undef ); |
131 |
# Do not propagate it as we already deal with it previously in this script |
|
|
132 |
my $coins = eval { $biblio->get_coins }; |
133 |
$template->param( ocoins => $coins ); |
134 |
|
139 |
|
135 |
# some useful variables for enhanced content; |
140 |
# some useful variables for enhanced content; |
136 |
# in each case, we're grabbing the first value we find in |
141 |
# in each case, we're grabbing the first value we find in |
137 |
# the record and normalizing it |
142 |
# the record and normalizing it |
138 |
my $upc = GetNormalizedUPC($record,$marcflavour); |
143 |
my $upc = GetNormalizedUPC($marc_record,$marcflavour); |
139 |
my $ean = GetNormalizedEAN($record,$marcflavour); |
144 |
my $ean = GetNormalizedEAN($marc_record,$marcflavour); |
140 |
my $oclc = GetNormalizedOCLCNumber($record,$marcflavour); |
145 |
my $oclc = GetNormalizedOCLCNumber($marc_record,$marcflavour); |
141 |
my $isbn = GetNormalizedISBN(undef,$record,$marcflavour); |
146 |
my $isbn = GetNormalizedISBN(undef,$marc_record,$marcflavour); |
142 |
|
147 |
|
143 |
$template->param( |
148 |
$template->param( |
144 |
normalized_upc => $upc, |
149 |
normalized_upc => $upc, |
Lines 161-167
for my $itm (@all_items) {
Link Here
|
161 |
# flag indicating existence of at least one item linked via a host record |
166 |
# flag indicating existence of at least one item linked via a host record |
162 |
my $hostrecords; |
167 |
my $hostrecords; |
163 |
# adding items linked via host biblios |
168 |
# adding items linked via host biblios |
164 |
my @hostitems = GetHostItemsInfo($record); |
169 |
my @hostitems = GetHostItemsInfo($marc_record); |
165 |
if (@hostitems){ |
170 |
if (@hostitems){ |
166 |
$hostrecords =1; |
171 |
$hostrecords =1; |
167 |
push (@items,@hostitems); |
172 |
push (@items,@hostitems); |
Lines 199-205
foreach my $subscription (@subscriptions) {
Link Here
|
199 |
my $showcomp = C4::Context->preference('ShowComponentRecords'); |
204 |
my $showcomp = C4::Context->preference('ShowComponentRecords'); |
200 |
my $show_analytics; |
205 |
my $show_analytics; |
201 |
if ( $showcomp eq 'both' || $showcomp eq 'staff' ) { |
206 |
if ( $showcomp eq 'both' || $showcomp eq 'staff' ) { |
202 |
if ( my $components = $marc_record ? $biblio->get_marc_components(C4::Context->preference('MaxComponentRecords')) : undef ) { |
207 |
if ( my $components = !$invalid_marc_record ? $biblio->get_marc_components(C4::Context->preference('MaxComponentRecords')) : undef ) { |
203 |
$show_analytics = 1 if @{$components}; # just show link when having results |
208 |
$show_analytics = 1 if @{$components}; # just show link when having results |
204 |
$template->param( analytics_error => 1 ) if grep { $_->message eq 'component_search' } @{$biblio->object_messages}; |
209 |
$template->param( analytics_error => 1 ) if grep { $_->message eq 'component_search' } @{$biblio->object_messages}; |
205 |
my $parts; |
210 |
my $parts; |
Lines 221-227
if ( $showcomp eq 'both' || $showcomp eq 'staff' ) {
Link Here
|
221 |
$template->param( ComponentPartsQuery => $biblio->get_components_query ); |
226 |
$template->param( ComponentPartsQuery => $biblio->get_components_query ); |
222 |
} |
227 |
} |
223 |
} else { # check if we should show analytics anyway |
228 |
} else { # check if we should show analytics anyway |
224 |
$show_analytics = 1 if $marc_record && @{$biblio->get_marc_components(1)}; # count matters here, results does not |
229 |
$show_analytics = 1 if !$invalid_marc_record && @{$biblio->get_marc_components(1)}; # count matters here, results does not |
225 |
$template->param( analytics_error => 1 ) if grep { $_->message eq 'component_search' } @{$biblio->object_messages}; |
230 |
$template->param( analytics_error => 1 ) if grep { $_->message eq 'component_search' } @{$biblio->object_messages}; |
226 |
} |
231 |
} |
227 |
|
232 |
|
Lines 231-237
$template->param(
Link Here
|
231 |
XSLTDetailsDisplay => '1', |
236 |
XSLTDetailsDisplay => '1', |
232 |
XSLTBloc => XSLTParse4Display({ |
237 |
XSLTBloc => XSLTParse4Display({ |
233 |
biblionumber => $biblionumber, |
238 |
biblionumber => $biblionumber, |
234 |
record => $record, |
239 |
record => $marc_record, |
235 |
xsl_syspref => "XSLTDetailsDisplay", |
240 |
xsl_syspref => "XSLTDetailsDisplay", |
236 |
fix_amps => 1, |
241 |
fix_amps => 1, |
237 |
xslt_variables => $xslt_variables, |
242 |
xslt_variables => $xslt_variables, |
Lines 460-466
$template->param(
Link Here
|
460 |
); |
465 |
); |
461 |
|
466 |
|
462 |
$template->param( |
467 |
$template->param( |
463 |
MARCNOTES => $marc_record ? $biblio->get_marc_notes({ marcflavour => $marcflavour }) : (), |
468 |
MARCNOTES => !$invalid_marc_record ? $biblio->get_marc_notes({ marcflavour => $marcflavour }) : (), |
464 |
itemdata_ccode => $itemfields{ccode}, |
469 |
itemdata_ccode => $itemfields{ccode}, |
465 |
itemdata_enumchron => $itemfields{enumchron}, |
470 |
itemdata_enumchron => $itemfields{enumchron}, |
466 |
itemdata_uri => $itemfields{uri}, |
471 |
itemdata_uri => $itemfields{uri}, |
Lines 482-488
if (C4::Context->preference("AlternateHoldingsField") && scalar @items == 0) {
Link Here
|
482 |
my $subfields = substr $fieldspec, 3; |
487 |
my $subfields = substr $fieldspec, 3; |
483 |
my $holdingsep = C4::Context->preference("AlternateHoldingsSeparator") || ' '; |
488 |
my $holdingsep = C4::Context->preference("AlternateHoldingsSeparator") || ' '; |
484 |
my @alternateholdingsinfo = (); |
489 |
my @alternateholdingsinfo = (); |
485 |
my @holdingsfields = $record->field(substr $fieldspec, 0, 3); |
490 |
my @holdingsfields = $marc_record->field(substr $fieldspec, 0, 3); |
486 |
|
491 |
|
487 |
for my $field (@holdingsfields) { |
492 |
for my $field (@holdingsfields) { |
488 |
my %holding = ( holding => '' ); |
493 |
my %holding = ( holding => '' ); |
Lines 555-561
if ( C4::Context->preference("LocalCoverImages") == 1 ) {
Link Here
|
555 |
|
560 |
|
556 |
# HTML5 Media |
561 |
# HTML5 Media |
557 |
if ( (C4::Context->preference("HTML5MediaEnabled") eq 'both') or (C4::Context->preference("HTML5MediaEnabled") eq 'staff') ) { |
562 |
if ( (C4::Context->preference("HTML5MediaEnabled") eq 'both') or (C4::Context->preference("HTML5MediaEnabled") eq 'staff') ) { |
558 |
$template->param( C4::HTML5Media->gethtml5media($record)); |
563 |
$template->param( C4::HTML5Media->gethtml5media($marc_record)); |
559 |
} |
564 |
} |
560 |
|
565 |
|
561 |
# Displaying tags |
566 |
# Displaying tags |
562 |
- |
|
|