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 (-20 / +24 lines)
Lines 88-97 if ( C4::Context->config('enable_plugins') ) { Link Here
88
my $biblionumber = $query->param('biblionumber');
88
my $biblionumber = $query->param('biblionumber');
89
$biblionumber = HTML::Entities::encode($biblionumber);
89
$biblionumber = HTML::Entities::encode($biblionumber);
90
my $biblio = Koha::Biblios->find( $biblionumber );
90
my $biblio = Koha::Biblios->find( $biblionumber );
91
my $record = $biblio->metadata->record;
92
$template->param( 'biblio', $biblio );
91
$template->param( 'biblio', $biblio );
93
92
94
if ( not defined $record ) {
93
unless ( $biblio ) {
95
    # biblionumber invalid -> report and exit
94
    # biblionumber invalid -> report and exit
96
    $template->param( unknownbiblionumber => 1,
95
    $template->param( unknownbiblionumber => 1,
97
                      biblionumber => $biblionumber );
96
                      biblionumber => $biblionumber );
Lines 100-106 if ( not defined $record ) { Link Here
100
}
99
}
101
100
102
my $marc_record = eval { $biblio->metadata->record };
101
my $marc_record = eval { $biblio->metadata->record };
103
$template->param( decoding_error => $@ );
102
my $invalid_marc_record = $@ || !$marc_record;
103
if ($invalid_marc_record) {
104
    $template->param( decoding_error => $@ );
105
    my $marc_xml = C4::Charset::StripNonXmlChars( $biblio->metadata->metadata );
106
107
    $marc_record = eval {
108
        MARC::Record::new_from_xml( $marc_xml, 'UTF-8',
109
            C4::Context->preference('marcflavour') );
110
    };
111
}
104
112
105
my $op = $query->param('op') || q{};
113
my $op = $query->param('op') || q{};
106
if ( $op eq 'set_item_group' ) {
114
if ( $op eq 'set_item_group' ) {
Lines 159-176 my $marcflavour = C4::Context->preference("marcflavour"); Link Here
159
167
160
$template->param( 'SpineLabelShowPrintOnBibDetails' => C4::Context->preference("SpineLabelShowPrintOnBibDetails") );
168
$template->param( 'SpineLabelShowPrintOnBibDetails' => C4::Context->preference("SpineLabelShowPrintOnBibDetails") );
161
169
162
# Catch the exception as Koha::Biblio::Metadata->record can explode if the MARCXML is invalid
170
$template->param( ocoins => !$invalid_marc_record ? $biblio->get_coins : undef );
163
# Do not propagate it as we already deal with it previously in this script
164
my $coins = eval { $biblio->get_coins };
165
$template->param( ocoins => $coins );
166
171
167
# some useful variables for enhanced content;
172
# some useful variables for enhanced content;
168
# in each case, we're grabbing the first value we find in
173
# in each case, we're grabbing the first value we find in
169
# the record and normalizing it
174
# the record and normalizing it
170
my $upc = GetNormalizedUPC($record,$marcflavour);
175
my $upc = GetNormalizedUPC($marc_record,$marcflavour);
171
my $ean = GetNormalizedEAN($record,$marcflavour);
176
my $ean = GetNormalizedEAN($marc_record,$marcflavour);
172
my $oclc = GetNormalizedOCLCNumber($record,$marcflavour);
177
my $oclc = GetNormalizedOCLCNumber($marc_record,$marcflavour);
173
my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
178
my $isbn = GetNormalizedISBN(undef,$marc_record,$marcflavour);
174
my $content_identifier_exists;
179
my $content_identifier_exists;
175
if ( $isbn or $ean or $oclc or $upc ) {
180
if ( $isbn or $ean or $oclc or $upc ) {
176
    $content_identifier_exists = 1;
181
    $content_identifier_exists = 1;
Lines 198-204 for my $itm (@all_items) { Link Here
198
# flag indicating existence of at least one item linked via a host record
203
# flag indicating existence of at least one item linked via a host record
199
my $hostrecords;
204
my $hostrecords;
200
# adding items linked via host biblios
205
# adding items linked via host biblios
201
my @hostitems = GetHostItemsInfo($record);
206
my @hostitems = GetHostItemsInfo($marc_record);
202
if (@hostitems){
207
if (@hostitems){
203
    $hostrecords =1;
208
    $hostrecords =1;
204
    push (@items,@hostitems);
209
    push (@items,@hostitems);
Lines 207-213 if (@hostitems){ Link Here
207
my $dat = &GetBiblioData($biblionumber);
212
my $dat = &GetBiblioData($biblionumber);
208
213
209
#is biblio a collection and are bundles enabled
214
#is biblio a collection and are bundles enabled
210
my $leader = $record->leader();
215
my $leader = $marc_record->leader();
211
$dat->{bundlesEnabled} = ( ( substr( $leader, 7, 1 ) eq 'c' )
216
$dat->{bundlesEnabled} = ( ( substr( $leader, 7, 1 ) eq 'c' )
212
      && C4::Context->preference('BundleNotLoanValue') ) ? 1 : 0;
217
      && C4::Context->preference('BundleNotLoanValue') ) ? 1 : 0;
213
218
Lines 241-247 foreach my $subscription (@subscriptions) { Link Here
241
my $showcomp = C4::Context->preference('ShowComponentRecords');
246
my $showcomp = C4::Context->preference('ShowComponentRecords');
242
my $show_analytics;
247
my $show_analytics;
243
if ( $showcomp eq 'both' || $showcomp eq 'staff' ) {
248
if ( $showcomp eq 'both' || $showcomp eq 'staff' ) {
244
    if ( my $components = $marc_record ? $biblio->get_marc_components(C4::Context->preference('MaxComponentRecords')) : undef ) {
249
    if ( my $components = !$invalid_marc_record ? $biblio->get_marc_components(C4::Context->preference('MaxComponentRecords')) : undef ) {
245
        $show_analytics = 1 if @{$components}; # just show link when having results
250
        $show_analytics = 1 if @{$components}; # just show link when having results
246
        $template->param( analytics_error => 1 ) if grep { $_->message eq 'component_search' } @{$biblio->object_messages};
251
        $template->param( analytics_error => 1 ) if grep { $_->message eq 'component_search' } @{$biblio->object_messages};
247
        my $parts;
252
        my $parts;
Lines 265-271 if ( $showcomp eq 'both' || $showcomp eq 'staff' ) { Link Here
265
        $template->param( ComponentPartsQuery => $cpq );
270
        $template->param( ComponentPartsQuery => $cpq );
266
    }
271
    }
267
} else { # check if we should show analytics anyway
272
} else { # check if we should show analytics anyway
268
    $show_analytics = 1 if $marc_record && @{$biblio->get_marc_components(1)}; # count matters here, results does not
273
    $show_analytics = 1 if !$invalid_marc_record && @{$biblio->get_marc_components(1)}; # count matters here, results does not
269
    $template->param( analytics_error => 1 ) if grep { $_->message eq 'component_search' } @{$biblio->object_messages};
274
    $template->param( analytics_error => 1 ) if grep { $_->message eq 'component_search' } @{$biblio->object_messages};
270
}
275
}
271
276
Lines 275-281 $template->param( Link Here
275
    XSLTDetailsDisplay => '1',
280
    XSLTDetailsDisplay => '1',
276
    XSLTBloc => XSLTParse4Display({
281
    XSLTBloc => XSLTParse4Display({
277
        biblionumber   => $biblionumber,
282
        biblionumber   => $biblionumber,
278
        record         => $record,
283
        record         => $marc_record,
279
        xsl_syspref    => "XSLTDetailsDisplay",
284
        xsl_syspref    => "XSLTDetailsDisplay",
280
        fix_amps       => 1,
285
        fix_amps       => 1,
281
        xslt_variables => $xslt_variables,
286
        xslt_variables => $xslt_variables,
Lines 518-524 $template->param( Link Here
518
);
523
);
519
524
520
$template->param(
525
$template->param(
521
    MARCNOTES               => $marc_record ? $biblio->get_marc_notes() : undef,
526
    MARCNOTES               => !$invalid_marc_record ? $biblio->get_marc_notes() : undef,
522
    itemdata_ccode          => $itemfields{ccode},
527
    itemdata_ccode          => $itemfields{ccode},
523
    itemdata_enumchron      => $itemfields{enumchron},
528
    itemdata_enumchron      => $itemfields{enumchron},
524
    itemdata_uri            => $itemfields{uri},
529
    itemdata_uri            => $itemfields{uri},
Lines 540-546 if (C4::Context->preference("AlternateHoldingsField") && scalar @items == 0) { Link Here
540
    my $subfields = substr $fieldspec, 3;
545
    my $subfields = substr $fieldspec, 3;
541
    my $holdingsep = C4::Context->preference("AlternateHoldingsSeparator") || ' ';
546
    my $holdingsep = C4::Context->preference("AlternateHoldingsSeparator") || ' ';
542
    my @alternateholdingsinfo = ();
547
    my @alternateholdingsinfo = ();
543
    my @holdingsfields = $record->field(substr $fieldspec, 0, 3);
548
    my @holdingsfields = $marc_record->field(substr $fieldspec, 0, 3);
544
549
545
    for my $field (@holdingsfields) {
550
    for my $field (@holdingsfields) {
546
        my %holding = ( holding => '' );
551
        my %holding = ( holding => '' );
Lines 617-623 if ( C4::Context->preference("LocalCoverImages") == 1 ) { Link Here
617
622
618
# HTML5 Media
623
# HTML5 Media
619
if ( (C4::Context->preference("HTML5MediaEnabled") eq 'both') or (C4::Context->preference("HTML5MediaEnabled") eq 'staff') ) {
624
if ( (C4::Context->preference("HTML5MediaEnabled") eq 'both') or (C4::Context->preference("HTML5MediaEnabled") eq 'staff') ) {
620
    $template->param( C4::HTML5Media->gethtml5media($record));
625
    $template->param( C4::HTML5Media->gethtml5media($marc_record));
621
}
626
}
622
627
623
# Displaying tags
628
# Displaying tags
624
- 

Return to bug 29697