View | Details | Raw Unified | Return to bug 29697
Collapse All | Expand All

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

Return to bug 29697