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

(-)a/C4/Biblio.pm (-191 lines)
Lines 43-49 BEGIN { Link Here
43
        GetMarcUrls
43
        GetMarcUrls
44
        GetUsedMarcStructure
44
        GetUsedMarcStructure
45
        GetXmlBiblio
45
        GetXmlBiblio
46
        GetCOinSBiblio
47
        GetMarcPrice
46
        GetMarcPrice
48
        MungeMarcPrice
47
        MungeMarcPrice
49
        GetMarcQuantity
48
        GetMarcQuantity
Lines 88-95 use MARC::File::USMARC; Link Here
88
use MARC::File::XML;
87
use MARC::File::XML;
89
use POSIX qw(strftime);
88
use POSIX qw(strftime);
90
use Module::Load::Conditional qw(can_load);
89
use Module::Load::Conditional qw(can_load);
91
use URI;
92
use URI::Escape; # GetCOinSBiblio
93
90
94
use C4::Koha;
91
use C4::Koha;
95
use C4::Log;    # logaction
92
use C4::Log;    # logaction
Lines 1232-1425 sub GetXmlBiblio { Link Here
1232
    return $marcxml;
1229
    return $marcxml;
1233
}
1230
}
1234
1231
1235
=head2 GetCOinSBiblio
1236
1237
  my $coins = GetCOinSBiblio($record);
1238
1239
Returns the COinS (a span) which can be included in a biblio record
1240
1241
=cut
1242
1243
sub GetCOinSBiblio {
1244
    my $record = shift;
1245
1246
    # get the coin format
1247
    if ( ! $record ) {
1248
        carp 'GetCOinSBiblio called with undefined record';
1249
        return;
1250
    }
1251
1252
    my $pos7 = substr $record->leader(), 7, 1;
1253
    my $pos6 = substr $record->leader(), 6, 1;
1254
    my $mtx;
1255
    my $genre;
1256
    my ( $aulast, $aufirst ) = ( '', '' );
1257
    my @authors;
1258
    my $title;
1259
    my $hosttitle;
1260
    my $pubyear   = '';
1261
    my $isbn      = '';
1262
    my $issn      = '';
1263
    my $publisher = '';
1264
    my $pages     = '';
1265
    my $titletype = '';
1266
1267
    # For the purposes of generating COinS metadata, LDR/06-07 can be
1268
    # considered the same for UNIMARC and MARC21
1269
    my $fmts6 = {
1270
        'a' => 'book',
1271
        'b' => 'manuscript',
1272
        'c' => 'book',
1273
        'd' => 'manuscript',
1274
        'e' => 'map',
1275
        'f' => 'map',
1276
        'g' => 'film',
1277
        'i' => 'audioRecording',
1278
        'j' => 'audioRecording',
1279
        'k' => 'artwork',
1280
        'l' => 'document',
1281
        'm' => 'computerProgram',
1282
        'o' => 'document',
1283
        'r' => 'document',
1284
    };
1285
    my $fmts7 = {
1286
        'a' => 'journalArticle',
1287
        's' => 'journal',
1288
    };
1289
1290
    $genre = $fmts6->{$pos6} ? $fmts6->{$pos6} : 'book';
1291
1292
    if ( $genre eq 'book' ) {
1293
            $genre = $fmts7->{$pos7} if $fmts7->{$pos7};
1294
    }
1295
1296
    ##### We must transform mtx to a valable mtx and document type ####
1297
    if ( $genre eq 'book' ) {
1298
            $mtx = 'book';
1299
            $titletype = 'b';
1300
    } elsif ( $genre eq 'journal' ) {
1301
            $mtx = 'journal';
1302
            $titletype = 'j';
1303
    } elsif ( $genre eq 'journalArticle' ) {
1304
            $mtx   = 'journal';
1305
            $genre = 'article';
1306
            $titletype = 'a';
1307
    } else {
1308
            $mtx = 'dc';
1309
    }
1310
1311
    if ( C4::Context->preference("marcflavour") eq "UNIMARC" ) {
1312
1313
        # Setting datas
1314
        $aulast  = $record->subfield( '700', 'a' ) || '';
1315
        $aufirst = $record->subfield( '700', 'b' ) || '';
1316
        push @authors, "$aufirst $aulast" if ($aufirst or $aulast);
1317
1318
        # others authors
1319
        if ( $record->field('200') ) {
1320
            for my $au ( $record->field('200')->subfield('g') ) {
1321
                push @authors, $au;
1322
            }
1323
        }
1324
1325
        $title     = $record->subfield( '200', 'a' );
1326
        my $subfield_210d = $record->subfield('210', 'd');
1327
        if ($subfield_210d and $subfield_210d =~ /(\d{4})/) {
1328
            $pubyear = $1;
1329
        }
1330
        $publisher = $record->subfield( '210', 'c' ) || '';
1331
        $isbn      = $record->subfield( '010', 'a' ) || '';
1332
        $issn      = $record->subfield( '011', 'a' ) || '';
1333
    } else {
1334
1335
        # MARC21 need some improve
1336
1337
        # Setting datas
1338
        if ( $record->field('100') ) {
1339
            push @authors, $record->subfield( '100', 'a' );
1340
        }
1341
1342
        # others authors
1343
        if ( $record->field('700') ) {
1344
            for my $au ( $record->field('700')->subfield('a') ) {
1345
                push @authors, $au;
1346
            }
1347
        }
1348
        $title = $record->subfield( '245', 'a' ) . $record->subfield( '245', 'b' );
1349
        if ($titletype eq 'a') {
1350
            $pubyear   = $record->field('008') || '';
1351
            $pubyear   = substr($pubyear->data(), 7, 4) if $pubyear;
1352
            $isbn      = $record->subfield( '773', 'z' ) || '';
1353
            $issn      = $record->subfield( '773', 'x' ) || '';
1354
            $hosttitle = $record->subfield( '773', 't' ) || $record->subfield( '773', 'a') || q{};
1355
            my @rels = $record->subfield( '773', 'g' );
1356
            $pages = join(', ', @rels);
1357
        } else {
1358
            $pubyear   = $record->subfield( '260', 'c' ) || '';
1359
            $publisher = $record->subfield( '260', 'b' ) || '';
1360
            $isbn      = $record->subfield( '020', 'a' ) || '';
1361
            $issn      = $record->subfield( '022', 'a' ) || '';
1362
        }
1363
1364
    }
1365
1366
    my @params = (
1367
        [ 'ctx_ver', 'Z39.88-2004' ],
1368
        [ 'rft_val_fmt', "info:ofi/fmt:kev:mtx:$mtx" ],
1369
        [ ($mtx eq 'dc' ? 'rft.type' : 'rft.genre'), $genre ],
1370
        [ "rft.${titletype}title", $title ],
1371
    );
1372
1373
    # rft.title is authorized only once, so by checking $titletype
1374
    # we ensure that rft.title is not already in the list.
1375
    if ($hosttitle and $titletype) {
1376
        push @params, [ 'rft.title', $hosttitle ];
1377
    }
1378
1379
    push @params, (
1380
        [ 'rft.isbn', $isbn ],
1381
        [ 'rft.issn', $issn ],
1382
    );
1383
1384
    # If it's a subscription, these informations have no meaning.
1385
    if ($genre ne 'journal') {
1386
        push @params, (
1387
            [ 'rft.aulast', $aulast ],
1388
            [ 'rft.aufirst', $aufirst ],
1389
            (map { [ 'rft.au', $_ ] } @authors),
1390
            [ 'rft.pub', $publisher ],
1391
            [ 'rft.date', $pubyear ],
1392
            [ 'rft.pages', $pages ],
1393
        );
1394
    }
1395
1396
    my $coins_value = join( '&',
1397
        map { $$_[1] ? $$_[0] . '=' . uri_escape_utf8( $$_[1] ) : () } @params );
1398
1399
    return $coins_value;
1400
}
1401
1402
sub GetOpenURLResolverURL {
1403
    my ($record) = @_;
1404
1405
    my $coins = GetCOinSBiblio($record);
1406
    my $OpenURLResolverURL = C4::Context->preference('OpenURLResolverURL');
1407
1408
    if ($OpenURLResolverURL) {
1409
        my $uri = URI->new($OpenURLResolverURL);
1410
1411
        if (not defined $uri->query) {
1412
            $OpenURLResolverURL .= '?';
1413
        } else {
1414
            $OpenURLResolverURL .= '&';
1415
        }
1416
        $OpenURLResolverURL .= $coins;
1417
    }
1418
1419
    return $OpenURLResolverURL;
1420
}
1421
1422
1423
=head2 GetMarcPrice
1232
=head2 GetMarcPrice
1424
1233
1425
return the prices in accordance with the Marc format.
1234
return the prices in accordance with the Marc format.
(-)a/C4/XSLT.pm (-4 / +11 lines)
Lines 247-257 sub XSLTParse4Display { Link Here
247
247
248
    $variables ||= {};
248
    $variables ||= {};
249
    if (C4::Context->preference('OPACShowOpenURL')) {
249
    if (C4::Context->preference('OPACShowOpenURL')) {
250
        my ($biblio) = GetBiblioItemByBiblioNumber($biblionumber);
250
        my @biblio_itemtypes;
251
        my $biblio = Koha::Biblios->find($biblionumber);
252
        if (C4::Context->preference('item-level_itypes')) {
253
            @biblio_itemtypes = $biblio->items->get_column("itype");
254
        } else {
255
            push @biblio_itemtypes, $biblio->biblioitem->itemtype;
256
        }
251
        my @itypes = split( /\s/, C4::Context->preference('OPACOpenURLItemTypes') );
257
        my @itypes = split( /\s/, C4::Context->preference('OPACOpenURLItemTypes') );
252
        if (grep /^$biblio->{itemtype}$/, @itypes) {
258
        my %original = ();
253
            $variables->{OpenURLResolverURL} =
259
        map { $original{$_} = 1 } @biblio_itemtypes;
254
              C4::Biblio::GetOpenURLResolverURL($orig_record);
260
        if ( grep { $original{$_} } @itypes ) {
261
            $variables->{OpenURLResolverURL} = $biblio->get_openurl;
255
        }
262
        }
256
    }
263
    }
257
    my $varxml = "<variables>\n";
264
    my $varxml = "<variables>\n";
(-)a/Koha/Biblio.pm (+192 lines)
Lines 21-26 use Modern::Perl; Link Here
21
21
22
use Carp;
22
use Carp;
23
use List::MoreUtils qw(any);
23
use List::MoreUtils qw(any);
24
use URI;
25
use URI::Escape;
24
26
25
use C4::Biblio qw();
27
use C4::Biblio qw();
26
28
Lines 464-469 sub has_items_waiting_or_intransit { Link Here
464
    return 0;
466
    return 0;
465
}
467
}
466
468
469
=head2 get_coins
470
471
my $coins = $biblio->get_coins;
472
473
Returns the COinS (a span) which can be included in a biblio record
474
475
=cut
476
477
sub get_coins {
478
    my ( $self ) = @_;
479
480
    my $record = $self->metadata->record;
481
482
    my $pos7 = substr $record->leader(), 7, 1;
483
    my $pos6 = substr $record->leader(), 6, 1;
484
    my $mtx;
485
    my $genre;
486
    my ( $aulast, $aufirst ) = ( '', '' );
487
    my @authors;
488
    my $title;
489
    my $hosttitle;
490
    my $pubyear   = '';
491
    my $isbn      = '';
492
    my $issn      = '';
493
    my $publisher = '';
494
    my $pages     = '';
495
    my $titletype = '';
496
497
    # For the purposes of generating COinS metadata, LDR/06-07 can be
498
    # considered the same for UNIMARC and MARC21
499
    my $fmts6 = {
500
        'a' => 'book',
501
        'b' => 'manuscript',
502
        'c' => 'book',
503
        'd' => 'manuscript',
504
        'e' => 'map',
505
        'f' => 'map',
506
        'g' => 'film',
507
        'i' => 'audioRecording',
508
        'j' => 'audioRecording',
509
        'k' => 'artwork',
510
        'l' => 'document',
511
        'm' => 'computerProgram',
512
        'o' => 'document',
513
        'r' => 'document',
514
    };
515
    my $fmts7 = {
516
        'a' => 'journalArticle',
517
        's' => 'journal',
518
    };
519
520
    $genre = $fmts6->{$pos6} ? $fmts6->{$pos6} : 'book';
521
522
    if ( $genre eq 'book' ) {
523
            $genre = $fmts7->{$pos7} if $fmts7->{$pos7};
524
    }
525
526
    ##### We must transform mtx to a valable mtx and document type ####
527
    if ( $genre eq 'book' ) {
528
            $mtx = 'book';
529
            $titletype = 'b';
530
    } elsif ( $genre eq 'journal' ) {
531
            $mtx = 'journal';
532
            $titletype = 'j';
533
    } elsif ( $genre eq 'journalArticle' ) {
534
            $mtx   = 'journal';
535
            $genre = 'article';
536
            $titletype = 'a';
537
    } else {
538
            $mtx = 'dc';
539
    }
540
541
    if ( C4::Context->preference("marcflavour") eq "UNIMARC" ) {
542
543
        # Setting datas
544
        $aulast  = $record->subfield( '700', 'a' ) || '';
545
        $aufirst = $record->subfield( '700', 'b' ) || '';
546
        push @authors, "$aufirst $aulast" if ($aufirst or $aulast);
547
548
        # others authors
549
        if ( $record->field('200') ) {
550
            for my $au ( $record->field('200')->subfield('g') ) {
551
                push @authors, $au;
552
            }
553
        }
554
555
        $title     = $record->subfield( '200', 'a' );
556
        my $subfield_210d = $record->subfield('210', 'd');
557
        if ($subfield_210d and $subfield_210d =~ /(\d{4})/) {
558
            $pubyear = $1;
559
        }
560
        $publisher = $record->subfield( '210', 'c' ) || '';
561
        $isbn      = $record->subfield( '010', 'a' ) || '';
562
        $issn      = $record->subfield( '011', 'a' ) || '';
563
    } else {
564
565
        # MARC21 need some improve
566
567
        # Setting datas
568
        if ( $record->field('100') ) {
569
            push @authors, $record->subfield( '100', 'a' );
570
        }
571
572
        # others authors
573
        if ( $record->field('700') ) {
574
            for my $au ( $record->field('700')->subfield('a') ) {
575
                push @authors, $au;
576
            }
577
        }
578
        $title = $record->subfield( '245', 'a' ) . $record->subfield( '245', 'b' );
579
        if ($titletype eq 'a') {
580
            $pubyear   = $record->field('008') || '';
581
            $pubyear   = substr($pubyear->data(), 7, 4) if $pubyear;
582
            $isbn      = $record->subfield( '773', 'z' ) || '';
583
            $issn      = $record->subfield( '773', 'x' ) || '';
584
            $hosttitle = $record->subfield( '773', 't' ) || $record->subfield( '773', 'a') || q{};
585
            my @rels = $record->subfield( '773', 'g' );
586
            $pages = join(', ', @rels);
587
        } else {
588
            $pubyear   = $record->subfield( '260', 'c' ) || '';
589
            $publisher = $record->subfield( '260', 'b' ) || '';
590
            $isbn      = $record->subfield( '020', 'a' ) || '';
591
            $issn      = $record->subfield( '022', 'a' ) || '';
592
        }
593
594
    }
595
596
    my @params = (
597
        [ 'ctx_ver', 'Z39.88-2004' ],
598
        [ 'rft_val_fmt', "info:ofi/fmt:kev:mtx:$mtx" ],
599
        [ ($mtx eq 'dc' ? 'rft.type' : 'rft.genre'), $genre ],
600
        [ "rft.${titletype}title", $title ],
601
    );
602
603
    # rft.title is authorized only once, so by checking $titletype
604
    # we ensure that rft.title is not already in the list.
605
    if ($hosttitle and $titletype) {
606
        push @params, [ 'rft.title', $hosttitle ];
607
    }
608
609
    push @params, (
610
        [ 'rft.isbn', $isbn ],
611
        [ 'rft.issn', $issn ],
612
    );
613
614
    # If it's a subscription, these informations have no meaning.
615
    if ($genre ne 'journal') {
616
        push @params, (
617
            [ 'rft.aulast', $aulast ],
618
            [ 'rft.aufirst', $aufirst ],
619
            (map { [ 'rft.au', $_ ] } @authors),
620
            [ 'rft.pub', $publisher ],
621
            [ 'rft.date', $pubyear ],
622
            [ 'rft.pages', $pages ],
623
        );
624
    }
625
626
    my $coins_value = join( '&amp;',
627
        map { $$_[1] ? $$_[0] . '=' . uri_escape_utf8( $$_[1] ) : () } @params );
628
629
    return $coins_value;
630
}
631
632
=head2 get_openurl
633
634
my $url = $biblio->get_openurl;
635
636
Returns url for OpenURL resolver set in OpenURLResolverURL system preference
637
638
=cut
639
640
sub get_openurl {
641
    my ( $self ) = @_;
642
643
    my $OpenURLResolverURL = C4::Context->preference('OpenURLResolverURL');
644
645
    if ($OpenURLResolverURL) {
646
        my $uri = URI->new($OpenURLResolverURL);
647
648
        if (not defined $uri->query) {
649
            $OpenURLResolverURL .= '?';
650
        } else {
651
            $OpenURLResolverURL .= '&amp;';
652
        }
653
        $OpenURLResolverURL .= $self->get_coins;
654
    }
655
656
    return $OpenURLResolverURL;
657
}
658
467
=head3 type
659
=head3 type
468
660
469
=cut
661
=cut
(-)a/catalogue/ISBDdetail.pl (-1 / +1 lines)
Lines 137-143 $template->param ( Link Here
137
    biblionumber        => $biblionumber,
137
    biblionumber        => $biblionumber,
138
    isbdview            => 1,
138
    isbdview            => 1,
139
    z3950_search_params => C4::Search::z3950_search_args(GetBiblioData($biblionumber)),
139
    z3950_search_params => C4::Search::z3950_search_args(GetBiblioData($biblionumber)),
140
    ocoins => GetCOinSBiblio($record),
140
    ocoins => $biblio->get_coins,
141
    C4::Search::enabled_staff_search_views,
141
    C4::Search::enabled_staff_search_views,
142
    searchid            => scalar $query->param('searchid'),
142
    searchid            => scalar $query->param('searchid'),
143
);
143
);
(-)a/catalogue/MARCdetail.pl (-2 / +2 lines)
Lines 99-106 if ( not defined $record ) { Link Here
99
    exit;
99
    exit;
100
}
100
}
101
101
102
$template->param( ocoins => GetCOinSBiblio($record) );
103
104
my $biblio_object = Koha::Biblios->find( $biblionumber ); # FIXME Should replace $biblio
102
my $biblio_object = Koha::Biblios->find( $biblionumber ); # FIXME Should replace $biblio
105
my $tagslib = &GetMarcStructure(1,$frameworkcode);
103
my $tagslib = &GetMarcStructure(1,$frameworkcode);
106
my $biblio = GetBiblioData($biblionumber);
104
my $biblio = GetBiblioData($biblionumber);
Lines 115-120 if($query->cookie("holdfor")){ Link Here
115
    );
113
    );
116
}
114
}
117
115
116
$template->param( ocoins => $biblio_object->get_coins );
117
118
#count of item linked
118
#count of item linked
119
my $itemcount = $biblio_object->items->count;
119
my $itemcount = $biblio_object->items->count;
120
$template->param( count => $itemcount,
120
$template->param( count => $itemcount,
(-)a/catalogue/detail.pl (-2 / +2 lines)
Lines 77-82 if ( C4::Context->preference('UseKohaPlugins') && Link Here
77
my $biblionumber = $query->param('biblionumber');
77
my $biblionumber = $query->param('biblionumber');
78
$biblionumber = HTML::Entities::encode($biblionumber);
78
$biblionumber = HTML::Entities::encode($biblionumber);
79
my $record       = GetMarcBiblio({ biblionumber => $biblionumber });
79
my $record       = GetMarcBiblio({ biblionumber => $biblionumber });
80
my $biblio = Koha::Biblios->find( $biblionumber );
80
81
81
if ( not defined $record ) {
82
if ( not defined $record ) {
82
    # biblionumber invalid -> report and exit
83
    # biblionumber invalid -> report and exit
Lines 117-123 if ( $xslfile ) { Link Here
117
}
118
}
118
119
119
$template->param( 'SpineLabelShowPrintOnBibDetails' => C4::Context->preference("SpineLabelShowPrintOnBibDetails") );
120
$template->param( 'SpineLabelShowPrintOnBibDetails' => C4::Context->preference("SpineLabelShowPrintOnBibDetails") );
120
$template->param( ocoins => GetCOinSBiblio($record) );
121
$template->param( ocoins => $biblio->get_coins );
121
122
122
# some useful variables for enhanced content;
123
# some useful variables for enhanced content;
123
# in each case, we're grabbing the first value we find in
124
# in each case, we're grabbing the first value we find in
Lines 489-495 if (C4::Context->preference('TagsEnabled') and $tag_quantity = C4::Context->pref Link Here
489
}
490
}
490
491
491
#we only need to pass the number of holds to the template
492
#we only need to pass the number of holds to the template
492
my $biblio = Koha::Biblios->find( $biblionumber );
493
my $holds = $biblio->holds;
493
my $holds = $biblio->holds;
494
$template->param( holdcount => $holds->count );
494
$template->param( holdcount => $holds->count );
495
495
(-)a/opac/opac-detail.pl (-3 / +1 lines)
Lines 847-855 $template->param( Link Here
847
);
847
);
848
848
849
# COinS format FIXME: for books Only
849
# COinS format FIXME: for books Only
850
$template->param(
850
$template->param( ocoins => $biblio->get_coins );
851
    ocoins => GetCOinSBiblio($record),
852
);
853
851
854
my ( $loggedincommenter, $reviews );
852
my ( $loggedincommenter, $reviews );
855
if ( C4::Context->preference('reviewson') ) {
853
if ( C4::Context->preference('reviewson') ) {
(-)a/opac/opac-search.pl (-2 / +2 lines)
Lines 682-689 for (my $i=0;$i<@servers;$i++) { Link Here
682
            }
682
            }
683
683
684
            if (C4::Context->preference('COinSinOPACResults')) {
684
            if (C4::Context->preference('COinSinOPACResults')) {
685
                my $record = GetMarcBiblio({ biblionumber => $res->{'biblionumber'} });
685
                my $biblio = Koha::Biblios->find( $res->{'biblionumber'} );
686
                $res->{coins} = GetCOinSBiblio($record);
686
                $res->{coins} = $biblio->get_coins;
687
            }
687
            }
688
            if ( C4::Context->preference( "Babeltheque" ) and $res->{normalized_isbn} ) {
688
            if ( C4::Context->preference( "Babeltheque" ) and $res->{normalized_isbn} ) {
689
                if( my $isbn = Business::ISBN->new( $res->{normalized_isbn} ) ) {
689
                if( my $isbn = Business::ISBN->new( $res->{normalized_isbn} ) ) {
(-)a/opac/opac-shelves.pl (-1 / +1 lines)
Lines 294-300 if ( $op eq 'view' ) { Link Here
294
                    $this_item->{description}       = $itemtype->description; #FIXME Should not it be translated_description?
294
                    $this_item->{description}       = $itemtype->description; #FIXME Should not it be translated_description?
295
                    $this_item->{notforloan}        = $itemtype->notforloan;
295
                    $this_item->{notforloan}        = $itemtype->notforloan;
296
                }
296
                }
297
                $this_item->{'coins'}           = GetCOinSBiblio($record);
297
                $this_item->{'coins'}           = $biblio->get_coins;
298
                $this_item->{'subtitle'}        = GetRecordValue( 'subtitle', $record, GetFrameworkCode( $biblionumber ) );
298
                $this_item->{'subtitle'}        = GetRecordValue( 'subtitle', $record, GetFrameworkCode( $biblionumber ) );
299
                $this_item->{'normalized_upc'}  = GetNormalizedUPC( $record, $marcflavour );
299
                $this_item->{'normalized_upc'}  = GetNormalizedUPC( $record, $marcflavour );
300
                $this_item->{'normalized_ean'}  = GetNormalizedEAN( $record, $marcflavour );
300
                $this_item->{'normalized_ean'}  = GetNormalizedEAN( $record, $marcflavour );
(-)a/t/Biblio.t (-7 / +1 lines)
Lines 21-27 use Test::More; Link Here
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Warn;
22
use Test::Warn;
23
23
24
plan tests => 47;
24
plan tests => 45;
25
25
26
use_ok('C4::Biblio');
26
use_ok('C4::Biblio');
27
27
Lines 63-74 warning_is { @arr = LinkBibHeadingsToAuthorities(q{}, q{}) } Link Here
63
63
64
is($arr[0], 0, 'LinkBibHeadingsToAuthorities correct error return');
64
is($arr[0], 0, 'LinkBibHeadingsToAuthorities correct error return');
65
65
66
warning_is { $ret = GetCOinSBiblio() }
67
           { carped => 'GetCOinSBiblio called with undefined record'},
68
           "GetCOinSBiblio returns carped warning on undef record";
69
70
ok( !defined $ret, 'GetCOinSBiblio returns undef if not passed rec');
71
72
warning_is { $ret = GetMarcPrice(undef, 'MARC21') }
66
warning_is { $ret = GetMarcPrice(undef, 'MARC21') }
73
           { carped => 'GetMarcPrice called on undefined record'},
67
           { carped => 'GetMarcPrice called on undefined record'},
74
           "GetMarcPrice returns carped warning on undef record";
68
           "GetMarcPrice returns carped warning on undef record";
(-)a/t/db_dependent/Biblio.t (-1 / +1 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 12;
20
use Test::More tests => 11;
21
use Test::MockModule;
21
use Test::MockModule;
22
use List::MoreUtils qw( uniq );
22
use List::MoreUtils qw( uniq );
23
use MARC::Record;
23
use MARC::Record;
(-)a/t/db_dependent/Koha/Biblio.t (-3 / +39 lines)
Lines 17-29 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 5;
20
use Test::More tests => 6;
21
22
use t::lib::TestBuilder;
23
21
24
use C4::Biblio;
22
use C4::Biblio;
25
use Koha::Database;
23
use Koha::Database;
26
24
25
use t::lib::TestBuilder;
26
use t::lib::Mocks;
27
27
BEGIN {
28
BEGIN {
28
    use_ok('Koha::Biblio');
29
    use_ok('Koha::Biblio');
29
    use_ok('Koha::Biblios');
30
    use_ok('Koha::Biblios');
Lines 107-109 subtest 'items() tests' => sub { Link Here
107
    $schema->storage->txn_rollback;
108
    $schema->storage->txn_rollback;
108
109
109
};
110
};
111
112
subtest 'get_coins and get_openurl' => sub {
113
114
    plan tests => 3;
115
116
    $schema->storage->txn_begin;
117
118
    my $builder = t::lib::TestBuilder->new;
119
    my $biblio = $builder->build_sample_biblio({
120
            title => 'Title 1',
121
            author => 'Author 1'
122
        });
123
124
    is(
125
        $biblio->get_coins,
126
        'ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Title%201&amp;rft.au=Author%201',
127
        'GetCOinsBiblio returned right metadata'
128
    );
129
130
    t::lib::Mocks::mock_preference("OpenURLResolverURL", "https://koha.example.com/");
131
    is(
132
        $biblio->get_openurl,
133
        'https://koha.example.com/?ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Title%201&amp;rft.au=Author%201',
134
        'Koha::Biblio->get_openurl returned right URL'
135
    );
136
137
    t::lib::Mocks::mock_preference("OpenURLResolverURL", "https://koha.example.com/?client_id=ci1");
138
    is(
139
        $biblio->get_openurl,
140
        'https://koha.example.com/?client_id=ci1&amp;ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Abook&amp;rft.genre=book&amp;rft.btitle=Title%201&amp;rft.au=Author%201',
141
        'Koha::Biblio->get_openurl returned right URL'
142
    );
143
144
    $schema->storage->txn_rollback;
145
};
(-)a/virtualshelves/shelves.pl (-2 / +1 lines)
Lines 279-285 if ( $op eq 'view' ) { Link Here
279
                $this_item->{imageurl}          = $itemtype ? C4::Koha::getitemtypeimagelocation( 'intranet', $itemtype->imageurl ) : q{};
279
                $this_item->{imageurl}          = $itemtype ? C4::Koha::getitemtypeimagelocation( 'intranet', $itemtype->imageurl ) : q{};
280
                $this_item->{description}       = $itemtype ? $itemtype->description : q{}; #FIXME Should this be translated_description ?
280
                $this_item->{description}       = $itemtype ? $itemtype->description : q{}; #FIXME Should this be translated_description ?
281
                $this_item->{notforloan}        = $itemtype->notforloan if $itemtype;
281
                $this_item->{notforloan}        = $itemtype->notforloan if $itemtype;
282
                $this_item->{'coins'}           = GetCOinSBiblio($record);
282
                $this_item->{'coins'}           = $biblio->get_coins;
283
                $this_item->{'subtitle'}        = GetRecordValue( 'subtitle', $record, GetFrameworkCode( $biblionumber ) );
283
                $this_item->{'subtitle'}        = GetRecordValue( 'subtitle', $record, GetFrameworkCode( $biblionumber ) );
284
                $this_item->{'normalized_upc'}  = GetNormalizedUPC( $record, $marcflavour );
284
                $this_item->{'normalized_upc'}  = GetNormalizedUPC( $record, $marcflavour );
285
                $this_item->{'normalized_ean'}  = GetNormalizedEAN( $record, $marcflavour );
285
                $this_item->{'normalized_ean'}  = GetNormalizedEAN( $record, $marcflavour );
286
- 

Return to bug 8995