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

(-)a/C4/Biblio.pm (-170 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-1404 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
=head2 GetMarcPrice
1232
=head2 GetMarcPrice
1403
1233
1404
return the prices in accordance with the Marc format.
1234
return the prices in accordance with the Marc format.
(-)a/Koha/Biblio.pm (-5 / +168 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 469-487 sub has_items_waiting_or_intransit { Link Here
469
    return 0;
471
    return 0;
470
}
472
}
471
473
474
=head2 get_coins
475
476
my $coins = $biblio->get_coins;
477
478
Returns the COinS (a span) which can be included in a biblio record
479
480
=cut
481
482
sub get_coins {
483
    my ( $self ) = @_;
484
485
    my $record = $self->metadata->record;
486
487
    my $pos7 = substr $record->leader(), 7, 1;
488
    my $pos6 = substr $record->leader(), 6, 1;
489
    my $mtx;
490
    my $genre;
491
    my ( $aulast, $aufirst ) = ( '', '' );
492
    my @authors;
493
    my $title;
494
    my $hosttitle;
495
    my $pubyear   = '';
496
    my $isbn      = '';
497
    my $issn      = '';
498
    my $publisher = '';
499
    my $pages     = '';
500
    my $titletype = '';
501
502
    # For the purposes of generating COinS metadata, LDR/06-07 can be
503
    # considered the same for UNIMARC and MARC21
504
    my $fmts6 = {
505
        'a' => 'book',
506
        'b' => 'manuscript',
507
        'c' => 'book',
508
        'd' => 'manuscript',
509
        'e' => 'map',
510
        'f' => 'map',
511
        'g' => 'film',
512
        'i' => 'audioRecording',
513
        'j' => 'audioRecording',
514
        'k' => 'artwork',
515
        'l' => 'document',
516
        'm' => 'computerProgram',
517
        'o' => 'document',
518
        'r' => 'document',
519
    };
520
    my $fmts7 = {
521
        'a' => 'journalArticle',
522
        's' => 'journal',
523
    };
524
525
    $genre = $fmts6->{$pos6} ? $fmts6->{$pos6} : 'book';
526
527
    if ( $genre eq 'book' ) {
528
            $genre = $fmts7->{$pos7} if $fmts7->{$pos7};
529
    }
530
531
    ##### We must transform mtx to a valable mtx and document type ####
532
    if ( $genre eq 'book' ) {
533
            $mtx = 'book';
534
            $titletype = 'b';
535
    } elsif ( $genre eq 'journal' ) {
536
            $mtx = 'journal';
537
            $titletype = 'j';
538
    } elsif ( $genre eq 'journalArticle' ) {
539
            $mtx   = 'journal';
540
            $genre = 'article';
541
            $titletype = 'a';
542
    } else {
543
            $mtx = 'dc';
544
    }
545
546
    if ( C4::Context->preference("marcflavour") eq "UNIMARC" ) {
547
548
        # Setting datas
549
        $aulast  = $record->subfield( '700', 'a' ) || '';
550
        $aufirst = $record->subfield( '700', 'b' ) || '';
551
        push @authors, "$aufirst $aulast" if ($aufirst or $aulast);
552
553
        # others authors
554
        if ( $record->field('200') ) {
555
            for my $au ( $record->field('200')->subfield('g') ) {
556
                push @authors, $au;
557
            }
558
        }
559
560
        $title     = $record->subfield( '200', 'a' );
561
        my $subfield_210d = $record->subfield('210', 'd');
562
        if ($subfield_210d and $subfield_210d =~ /(\d{4})/) {
563
            $pubyear = $1;
564
        }
565
        $publisher = $record->subfield( '210', 'c' ) || '';
566
        $isbn      = $record->subfield( '010', 'a' ) || '';
567
        $issn      = $record->subfield( '011', 'a' ) || '';
568
    } else {
569
570
        # MARC21 need some improve
571
572
        # Setting datas
573
        if ( $record->field('100') ) {
574
            push @authors, $record->subfield( '100', 'a' );
575
        }
576
577
        # others authors
578
        if ( $record->field('700') ) {
579
            for my $au ( $record->field('700')->subfield('a') ) {
580
                push @authors, $au;
581
            }
582
        }
583
        $title = $record->subfield( '245', 'a' ) . $record->subfield( '245', 'b' );
584
        if ($titletype eq 'a') {
585
            $pubyear   = $record->field('008') || '';
586
            $pubyear   = substr($pubyear->data(), 7, 4) if $pubyear;
587
            $isbn      = $record->subfield( '773', 'z' ) || '';
588
            $issn      = $record->subfield( '773', 'x' ) || '';
589
            $hosttitle = $record->subfield( '773', 't' ) || $record->subfield( '773', 'a') || q{};
590
            my @rels = $record->subfield( '773', 'g' );
591
            $pages = join(', ', @rels);
592
        } else {
593
            $pubyear   = $record->subfield( '260', 'c' ) || '';
594
            $publisher = $record->subfield( '260', 'b' ) || '';
595
            $isbn      = $record->subfield( '020', 'a' ) || '';
596
            $issn      = $record->subfield( '022', 'a' ) || '';
597
        }
598
599
    }
600
601
    my @params = (
602
        [ 'ctx_ver', 'Z39.88-2004' ],
603
        [ 'rft_val_fmt', "info:ofi/fmt:kev:mtx:$mtx" ],
604
        [ ($mtx eq 'dc' ? 'rft.type' : 'rft.genre'), $genre ],
605
        [ "rft.${titletype}title", $title ],
606
    );
607
608
    # rft.title is authorized only once, so by checking $titletype
609
    # we ensure that rft.title is not already in the list.
610
    if ($hosttitle and $titletype) {
611
        push @params, [ 'rft.title', $hosttitle ];
612
    }
613
614
    push @params, (
615
        [ 'rft.isbn', $isbn ],
616
        [ 'rft.issn', $issn ],
617
    );
618
619
    # If it's a subscription, these informations have no meaning.
620
    if ($genre ne 'journal') {
621
        push @params, (
622
            [ 'rft.aulast', $aulast ],
623
            [ 'rft.aufirst', $aufirst ],
624
            (map { [ 'rft.au', $_ ] } @authors),
625
            [ 'rft.pub', $publisher ],
626
            [ 'rft.date', $pubyear ],
627
            [ 'rft.pages', $pages ],
628
        );
629
    }
630
631
    my $coins_value = join( '&',
632
        map { $$_[1] ? $$_[0] . '=' . uri_escape_utf8( $$_[1] ) : () } @params );
633
634
    return $coins_value;
635
}
636
472
=head2 get_openurl
637
=head2 get_openurl
473
638
474
    my $biblio = Koha::Biblios->find( $biblionumber );
639
my $url = $biblio->get_openurl;
475
    my $url = $biblio->get_openurl;
476
640
477
    Takes MARC::Record and return url for OpenURL resolver set in OpenURLResolverURL
641
Returns url for OpenURL resolver set in OpenURLResolverURL system preference
478
642
479
=cut
643
=cut
480
644
481
sub get_openurl {
645
sub get_openurl {
482
    my ( $self ) = @_;
646
    my ( $self ) = @_;
483
647
484
    my $coins = C4::Biblio::GetCOinSBiblio( $self->metadata->record);
485
    my $OpenURLResolverURL = C4::Context->preference('OpenURLResolverURL');
648
    my $OpenURLResolverURL = C4::Context->preference('OpenURLResolverURL');
486
649
487
    if ($OpenURLResolverURL) {
650
    if ($OpenURLResolverURL) {
Lines 492-498 sub get_openurl { Link Here
492
        } else {
655
        } else {
493
            $OpenURLResolverURL .= '&';
656
            $OpenURLResolverURL .= '&';
494
        }
657
        }
495
        $OpenURLResolverURL .= $coins;
658
        $OpenURLResolverURL .= $self->get_coins;
496
    }
659
    }
497
660
498
    return $OpenURLResolverURL;
661
    return $OpenURLResolverURL;
(-)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 (-30 / +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;
Lines 590-621 subtest 'ModBiblio called from linker test' => sub { Link Here
590
# Cleanup
590
# Cleanup
591
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
591
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
592
$schema->storage->txn_rollback;
592
$schema->storage->txn_rollback;
593
594
subtest 'GetCOinSBiblio and get_openurl' => sub {
595
    plan tests => 2;
596
597
    $schema->storage->txn_begin;
598
599
    my $builder = t::lib::TestBuilder->new;
600
    my $biblio = $builder->build_sample_biblio({
601
            title => 'Title 1',
602
            author => 'Author 1'
603
        });
604
    my $record = $biblio->metadata->record;
605
606
    t::lib::Mocks::mock_preference("OpenURLResolverURL", "https://koha.example.com/");
607
608
    is(
609
        C4::Biblio::GetCOinSBiblio($record),
610
        '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',
611
        'GetCOinsBiblio returned right metadata'
612
    );
613
614
    is(
615
        $biblio->get_openurl,
616
        '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',
617
        'Koha::Biblio->get_openurl returned right URL'
618
    );
619
620
    $schema->storage->txn_rollback;
621
};
(-)a/t/db_dependent/Koha/Biblio.t (-3 / +32 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 => 2;
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
    $schema->storage->txn_rollback;
138
};
(-)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