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 |
my $content_identifier_exists; |
147 |
my $content_identifier_exists; |
143 |
if ( $isbn or $ean or $oclc or $upc ) { |
148 |
if ( $isbn or $ean or $oclc or $upc ) { |
144 |
$content_identifier_exists = 1; |
149 |
$content_identifier_exists = 1; |
Lines 166-172
for my $itm (@all_items) {
Link Here
|
166 |
# flag indicating existence of at least one item linked via a host record |
171 |
# flag indicating existence of at least one item linked via a host record |
167 |
my $hostrecords; |
172 |
my $hostrecords; |
168 |
# adding items linked via host biblios |
173 |
# adding items linked via host biblios |
169 |
my @hostitems = GetHostItemsInfo($record); |
174 |
my @hostitems = GetHostItemsInfo($marc_record); |
170 |
if (@hostitems){ |
175 |
if (@hostitems){ |
171 |
$hostrecords =1; |
176 |
$hostrecords =1; |
172 |
push (@items,@hostitems); |
177 |
push (@items,@hostitems); |
Lines 204-210
foreach my $subscription (@subscriptions) {
Link Here
|
204 |
my $showcomp = C4::Context->preference('ShowComponentRecords'); |
209 |
my $showcomp = C4::Context->preference('ShowComponentRecords'); |
205 |
my $show_analytics; |
210 |
my $show_analytics; |
206 |
if ( $showcomp eq 'both' || $showcomp eq 'staff' ) { |
211 |
if ( $showcomp eq 'both' || $showcomp eq 'staff' ) { |
207 |
if ( my $components = $marc_record ? $biblio->get_marc_components(C4::Context->preference('MaxComponentRecords')) : undef ) { |
212 |
if ( my $components = !$invalid_marc_record ? $biblio->get_marc_components(C4::Context->preference('MaxComponentRecords')) : undef ) { |
208 |
$show_analytics = 1 if @{$components}; # just show link when having results |
213 |
$show_analytics = 1 if @{$components}; # just show link when having results |
209 |
$template->param( analytics_error => 1 ) if grep { $_->message eq 'component_search' } @{$biblio->object_messages}; |
214 |
$template->param( analytics_error => 1 ) if grep { $_->message eq 'component_search' } @{$biblio->object_messages}; |
210 |
my $parts; |
215 |
my $parts; |
Lines 226-232
if ( $showcomp eq 'both' || $showcomp eq 'staff' ) {
Link Here
|
226 |
$template->param( ComponentPartsQuery => $biblio->get_components_query ); |
231 |
$template->param( ComponentPartsQuery => $biblio->get_components_query ); |
227 |
} |
232 |
} |
228 |
} else { # check if we should show analytics anyway |
233 |
} else { # check if we should show analytics anyway |
229 |
$show_analytics = 1 if $marc_record && @{$biblio->get_marc_components(1)}; # count matters here, results does not |
234 |
$show_analytics = 1 if !$invalid_marc_record && @{$biblio->get_marc_components(1)}; # count matters here, results does not |
230 |
$template->param( analytics_error => 1 ) if grep { $_->message eq 'component_search' } @{$biblio->object_messages}; |
235 |
$template->param( analytics_error => 1 ) if grep { $_->message eq 'component_search' } @{$biblio->object_messages}; |
231 |
} |
236 |
} |
232 |
|
237 |
|
Lines 236-242
$template->param(
Link Here
|
236 |
XSLTDetailsDisplay => '1', |
241 |
XSLTDetailsDisplay => '1', |
237 |
XSLTBloc => XSLTParse4Display({ |
242 |
XSLTBloc => XSLTParse4Display({ |
238 |
biblionumber => $biblionumber, |
243 |
biblionumber => $biblionumber, |
239 |
record => $record, |
244 |
record => $marc_record, |
240 |
xsl_syspref => "XSLTDetailsDisplay", |
245 |
xsl_syspref => "XSLTDetailsDisplay", |
241 |
fix_amps => 1, |
246 |
fix_amps => 1, |
242 |
xslt_variables => $xslt_variables, |
247 |
xslt_variables => $xslt_variables, |
Lines 465-471
$template->param(
Link Here
|
465 |
); |
470 |
); |
466 |
|
471 |
|
467 |
$template->param( |
472 |
$template->param( |
468 |
MARCNOTES => $marc_record ? $biblio->get_marc_notes({ marcflavour => $marcflavour }) : undef, |
473 |
MARCNOTES => !$invalid_marc_record ? $biblio->get_marc_notes({ marcflavour => $marcflavour }) : undef, |
469 |
itemdata_ccode => $itemfields{ccode}, |
474 |
itemdata_ccode => $itemfields{ccode}, |
470 |
itemdata_enumchron => $itemfields{enumchron}, |
475 |
itemdata_enumchron => $itemfields{enumchron}, |
471 |
itemdata_uri => $itemfields{uri}, |
476 |
itemdata_uri => $itemfields{uri}, |
Lines 487-493
if (C4::Context->preference("AlternateHoldingsField") && scalar @items == 0) {
Link Here
|
487 |
my $subfields = substr $fieldspec, 3; |
492 |
my $subfields = substr $fieldspec, 3; |
488 |
my $holdingsep = C4::Context->preference("AlternateHoldingsSeparator") || ' '; |
493 |
my $holdingsep = C4::Context->preference("AlternateHoldingsSeparator") || ' '; |
489 |
my @alternateholdingsinfo = (); |
494 |
my @alternateholdingsinfo = (); |
490 |
my @holdingsfields = $record->field(substr $fieldspec, 0, 3); |
495 |
my @holdingsfields = $marc_record->field(substr $fieldspec, 0, 3); |
491 |
|
496 |
|
492 |
for my $field (@holdingsfields) { |
497 |
for my $field (@holdingsfields) { |
493 |
my %holding = ( holding => '' ); |
498 |
my %holding = ( holding => '' ); |
Lines 560-566
if ( C4::Context->preference("LocalCoverImages") == 1 ) {
Link Here
|
560 |
|
565 |
|
561 |
# HTML5 Media |
566 |
# HTML5 Media |
562 |
if ( (C4::Context->preference("HTML5MediaEnabled") eq 'both') or (C4::Context->preference("HTML5MediaEnabled") eq 'staff') ) { |
567 |
if ( (C4::Context->preference("HTML5MediaEnabled") eq 'both') or (C4::Context->preference("HTML5MediaEnabled") eq 'staff') ) { |
563 |
$template->param( C4::HTML5Media->gethtml5media($record)); |
568 |
$template->param( C4::HTML5Media->gethtml5media($marc_record)); |
564 |
} |
569 |
} |
565 |
|
570 |
|
566 |
# Displaying tags |
571 |
# Displaying tags |
567 |
- |
|
|