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 1230-1402 sub GetXmlBiblio { Link Here
1230
    return $marcxml;
1227
    return $marcxml;
1231
}
1228
}
1232
1229
1233
=head2 GetCOinSBiblio
1234
1235
  my $coins = GetCOinSBiblio($record);
1236
1237
Returns the COinS (a span) which can be included in a biblio record
1238
1239
=cut
1240
1241
sub GetCOinSBiblio {
1242
    my $record = shift;
1243
1244
    # get the coin format
1245
    if ( ! $record ) {
1246
        carp 'GetCOinSBiblio called with undefined record';
1247
        return;
1248
    }
1249
1250
    my $pos7 = substr $record->leader(), 7, 1;
1251
    my $pos6 = substr $record->leader(), 6, 1;
1252
    my $mtx;
1253
    my $genre;
1254
    my ( $aulast, $aufirst ) = ( '', '' );
1255
    my @authors;
1256
    my $title;
1257
    my $hosttitle;
1258
    my $pubyear   = '';
1259
    my $isbn      = '';
1260
    my $issn      = '';
1261
    my $publisher = '';
1262
    my $pages     = '';
1263
    my $titletype = '';
1264
1265
    # For the purposes of generating COinS metadata, LDR/06-07 can be
1266
    # considered the same for UNIMARC and MARC21
1267
    my $fmts6 = {
1268
        'a' => 'book',
1269
        'b' => 'manuscript',
1270
        'c' => 'book',
1271
        'd' => 'manuscript',
1272
        'e' => 'map',
1273
        'f' => 'map',
1274
        'g' => 'film',
1275
        'i' => 'audioRecording',
1276
        'j' => 'audioRecording',
1277
        'k' => 'artwork',
1278
        'l' => 'document',
1279
        'm' => 'computerProgram',
1280
        'o' => 'document',
1281
        'r' => 'document',
1282
    };
1283
    my $fmts7 = {
1284
        'a' => 'journalArticle',
1285
        's' => 'journal',
1286
    };
1287
1288
    $genre = $fmts6->{$pos6} ? $fmts6->{$pos6} : 'book';
1289
1290
    if ( $genre eq 'book' ) {
1291
            $genre = $fmts7->{$pos7} if $fmts7->{$pos7};
1292
    }
1293
1294
    ##### We must transform mtx to a valable mtx and document type ####
1295
    if ( $genre eq 'book' ) {
1296
            $mtx = 'book';
1297
            $titletype = 'b';
1298
    } elsif ( $genre eq 'journal' ) {
1299
            $mtx = 'journal';
1300
            $titletype = 'j';
1301
    } elsif ( $genre eq 'journalArticle' ) {
1302
            $mtx   = 'journal';
1303
            $genre = 'article';
1304
            $titletype = 'a';
1305
    } else {
1306
            $mtx = 'dc';
1307
    }
1308
1309
    if ( C4::Context->preference("marcflavour") eq "UNIMARC" ) {
1310
1311
        # Setting datas
1312
        $aulast  = $record->subfield( '700', 'a' ) || '';
1313
        $aufirst = $record->subfield( '700', 'b' ) || '';
1314
        push @authors, "$aufirst $aulast" if ($aufirst or $aulast);
1315
1316
        # others authors
1317
        if ( $record->field('200') ) {
1318
            for my $au ( $record->field('200')->subfield('g') ) {
1319
                push @authors, $au;
1320
            }
1321
        }
1322
1323
        $title     = $record->subfield( '200', 'a' );
1324
        my $subfield_210d = $record->subfield('210', 'd');
1325
        if ($subfield_210d and $subfield_210d =~ /(\d{4})/) {
1326
            $pubyear = $1;
1327
        }
1328
        $publisher = $record->subfield( '210', 'c' ) || '';
1329
        $isbn      = $record->subfield( '010', 'a' ) || '';
1330
        $issn      = $record->subfield( '011', 'a' ) || '';
1331
    } else {
1332
1333
        # MARC21 need some improve
1334
1335
        # Setting datas
1336
        if ( $record->field('100') ) {
1337
            push @authors, $record->subfield( '100', 'a' );
1338
        }
1339
1340
        # others authors
1341
        if ( $record->field('700') ) {
1342
            for my $au ( $record->field('700')->subfield('a') ) {
1343
                push @authors, $au;
1344
            }
1345
        }
1346
        $title = $record->subfield( '245', 'a' ) . $record->subfield( '245', 'b' );
1347
        if ($titletype eq 'a') {
1348
            $pubyear   = $record->field('008') || '';
1349
            $pubyear   = substr($pubyear->data(), 7, 4) if $pubyear;
1350
            $isbn      = $record->subfield( '773', 'z' ) || '';
1351
            $issn      = $record->subfield( '773', 'x' ) || '';
1352
            $hosttitle = $record->subfield( '773', 't' ) || $record->subfield( '773', 'a') || q{};
1353
            my @rels = $record->subfield( '773', 'g' );
1354
            $pages = join(', ', @rels);
1355
        } else {
1356
            $pubyear   = $record->subfield( '260', 'c' ) || '';
1357
            $publisher = $record->subfield( '260', 'b' ) || '';
1358
            $isbn      = $record->subfield( '020', 'a' ) || '';
1359
            $issn      = $record->subfield( '022', 'a' ) || '';
1360
        }
1361
1362
    }
1363
1364
    my @params = (
1365
        [ 'ctx_ver', 'Z39.88-2004' ],
1366
        [ 'rft_val_fmt', "info:ofi/fmt:kev:mtx:$mtx" ],
1367
        [ ($mtx eq 'dc' ? 'rft.type' : 'rft.genre'), $genre ],
1368
        [ "rft.${titletype}title", $title ],
1369
    );
1370
1371
    # rft.title is authorized only once, so by checking $titletype
1372
    # we ensure that rft.title is not already in the list.
1373
    if ($hosttitle and $titletype) {
1374
        push @params, [ 'rft.title', $hosttitle ];
1375
    }
1376
1377
    push @params, (
1378
        [ 'rft.isbn', $isbn ],
1379
        [ 'rft.issn', $issn ],
1380
    );
1381
1382
    # If it's a subscription, these informations have no meaning.
1383
    if ($genre ne 'journal') {
1384
        push @params, (
1385
            [ 'rft.aulast', $aulast ],
1386
            [ 'rft.aufirst', $aufirst ],
1387
            (map { [ 'rft.au', $_ ] } @authors),
1388
            [ 'rft.pub', $publisher ],
1389
            [ 'rft.date', $pubyear ],
1390
            [ 'rft.pages', $pages ],
1391
        );
1392
    }
1393
1394
    my $coins_value = join( '&',
1395
        map { $$_[1] ? $$_[0] . '=' . uri_escape_utf8( $$_[1] ) : () } @params );
1396
1397
    return $coins_value;
1398
}
1399
1400
=head2 GetMarcPrice
1230
=head2 GetMarcPrice
1401
1231
1402
return the prices in accordance with the Marc format.
1232
return the prices in accordance with the Marc format.
(-)a/Koha/Biblio.pm (-5 / +168 lines)
Lines 20-25 package Koha::Biblio; Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Carp;
22
use Carp;
23
use URI;
24
use URI::Escape;
23
25
24
use C4::Biblio qw();
26
use C4::Biblio qw();
25
27
Lines 442-460 sub has_items_waiting_or_intransit { Link Here
442
    return 0;
444
    return 0;
443
}
445
}
444
446
447
=head2 get_coins
448
449
my $coins = $biblio->get_coins;
450
451
Returns the COinS (a span) which can be included in a biblio record
452
453
=cut
454
455
sub get_coins {
456
    my ( $self ) = @_;
457
458
    my $record = $self->metadata->record;
459
460
    my $pos7 = substr $record->leader(), 7, 1;
461
    my $pos6 = substr $record->leader(), 6, 1;
462
    my $mtx;
463
    my $genre;
464
    my ( $aulast, $aufirst ) = ( '', '' );
465
    my @authors;
466
    my $title;
467
    my $hosttitle;
468
    my $pubyear   = '';
469
    my $isbn      = '';
470
    my $issn      = '';
471
    my $publisher = '';
472
    my $pages     = '';
473
    my $titletype = '';
474
475
    # For the purposes of generating COinS metadata, LDR/06-07 can be
476
    # considered the same for UNIMARC and MARC21
477
    my $fmts6 = {
478
        'a' => 'book',
479
        'b' => 'manuscript',
480
        'c' => 'book',
481
        'd' => 'manuscript',
482
        'e' => 'map',
483
        'f' => 'map',
484
        'g' => 'film',
485
        'i' => 'audioRecording',
486
        'j' => 'audioRecording',
487
        'k' => 'artwork',
488
        'l' => 'document',
489
        'm' => 'computerProgram',
490
        'o' => 'document',
491
        'r' => 'document',
492
    };
493
    my $fmts7 = {
494
        'a' => 'journalArticle',
495
        's' => 'journal',
496
    };
497
498
    $genre = $fmts6->{$pos6} ? $fmts6->{$pos6} : 'book';
499
500
    if ( $genre eq 'book' ) {
501
            $genre = $fmts7->{$pos7} if $fmts7->{$pos7};
502
    }
503
504
    ##### We must transform mtx to a valable mtx and document type ####
505
    if ( $genre eq 'book' ) {
506
            $mtx = 'book';
507
            $titletype = 'b';
508
    } elsif ( $genre eq 'journal' ) {
509
            $mtx = 'journal';
510
            $titletype = 'j';
511
    } elsif ( $genre eq 'journalArticle' ) {
512
            $mtx   = 'journal';
513
            $genre = 'article';
514
            $titletype = 'a';
515
    } else {
516
            $mtx = 'dc';
517
    }
518
519
    if ( C4::Context->preference("marcflavour") eq "UNIMARC" ) {
520
521
        # Setting datas
522
        $aulast  = $record->subfield( '700', 'a' ) || '';
523
        $aufirst = $record->subfield( '700', 'b' ) || '';
524
        push @authors, "$aufirst $aulast" if ($aufirst or $aulast);
525
526
        # others authors
527
        if ( $record->field('200') ) {
528
            for my $au ( $record->field('200')->subfield('g') ) {
529
                push @authors, $au;
530
            }
531
        }
532
533
        $title     = $record->subfield( '200', 'a' );
534
        my $subfield_210d = $record->subfield('210', 'd');
535
        if ($subfield_210d and $subfield_210d =~ /(\d{4})/) {
536
            $pubyear = $1;
537
        }
538
        $publisher = $record->subfield( '210', 'c' ) || '';
539
        $isbn      = $record->subfield( '010', 'a' ) || '';
540
        $issn      = $record->subfield( '011', 'a' ) || '';
541
    } else {
542
543
        # MARC21 need some improve
544
545
        # Setting datas
546
        if ( $record->field('100') ) {
547
            push @authors, $record->subfield( '100', 'a' );
548
        }
549
550
        # others authors
551
        if ( $record->field('700') ) {
552
            for my $au ( $record->field('700')->subfield('a') ) {
553
                push @authors, $au;
554
            }
555
        }
556
        $title = $record->subfield( '245', 'a' ) . $record->subfield( '245', 'b' );
557
        if ($titletype eq 'a') {
558
            $pubyear   = $record->field('008') || '';
559
            $pubyear   = substr($pubyear->data(), 7, 4) if $pubyear;
560
            $isbn      = $record->subfield( '773', 'z' ) || '';
561
            $issn      = $record->subfield( '773', 'x' ) || '';
562
            $hosttitle = $record->subfield( '773', 't' ) || $record->subfield( '773', 'a') || q{};
563
            my @rels = $record->subfield( '773', 'g' );
564
            $pages = join(', ', @rels);
565
        } else {
566
            $pubyear   = $record->subfield( '260', 'c' ) || '';
567
            $publisher = $record->subfield( '260', 'b' ) || '';
568
            $isbn      = $record->subfield( '020', 'a' ) || '';
569
            $issn      = $record->subfield( '022', 'a' ) || '';
570
        }
571
572
    }
573
574
    my @params = (
575
        [ 'ctx_ver', 'Z39.88-2004' ],
576
        [ 'rft_val_fmt', "info:ofi/fmt:kev:mtx:$mtx" ],
577
        [ ($mtx eq 'dc' ? 'rft.type' : 'rft.genre'), $genre ],
578
        [ "rft.${titletype}title", $title ],
579
    );
580
581
    # rft.title is authorized only once, so by checking $titletype
582
    # we ensure that rft.title is not already in the list.
583
    if ($hosttitle and $titletype) {
584
        push @params, [ 'rft.title', $hosttitle ];
585
    }
586
587
    push @params, (
588
        [ 'rft.isbn', $isbn ],
589
        [ 'rft.issn', $issn ],
590
    );
591
592
    # If it's a subscription, these informations have no meaning.
593
    if ($genre ne 'journal') {
594
        push @params, (
595
            [ 'rft.aulast', $aulast ],
596
            [ 'rft.aufirst', $aufirst ],
597
            (map { [ 'rft.au', $_ ] } @authors),
598
            [ 'rft.pub', $publisher ],
599
            [ 'rft.date', $pubyear ],
600
            [ 'rft.pages', $pages ],
601
        );
602
    }
603
604
    my $coins_value = join( '&',
605
        map { $$_[1] ? $$_[0] . '=' . uri_escape_utf8( $$_[1] ) : () } @params );
606
607
    return $coins_value;
608
}
609
445
=head2 get_openurl
610
=head2 get_openurl
446
611
447
    my $biblio = Koha::Biblios->find( $biblionumber );
612
my $url = $biblio->get_openurl;
448
    my $url = $biblio->get_openurl;
449
613
450
    Takes MARC::Record and return url for OpenURL resolver set in OpenURLResolverURL
614
Returns url for OpenURL resolver set in OpenURLResolverURL system preference
451
615
452
=cut
616
=cut
453
617
454
sub get_openurl {
618
sub get_openurl {
455
    my ( $self ) = @_;
619
    my ( $self ) = @_;
456
620
457
    my $coins = C4::Biblio::GetCOinSBiblio( $self->metadata->record);
458
    my $OpenURLResolverURL = C4::Context->preference('OpenURLResolverURL');
621
    my $OpenURLResolverURL = C4::Context->preference('OpenURLResolverURL');
459
622
460
    if ($OpenURLResolverURL) {
623
    if ($OpenURLResolverURL) {
Lines 465-471 sub get_openurl { Link Here
465
        } else {
628
        } else {
466
            $OpenURLResolverURL .= '&';
629
            $OpenURLResolverURL .= '&';
467
        }
630
        }
468
        $OpenURLResolverURL .= $coins;
631
        $OpenURLResolverURL .= $self->get_coins;
469
    }
632
    }
470
633
471
    return $OpenURLResolverURL;
634
    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 573-604 subtest 'MarcFieldForCreatorAndModifier' => sub { Link Here
573
# Cleanup
573
# Cleanup
574
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
574
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
575
$schema->storage->txn_rollback;
575
$schema->storage->txn_rollback;
576
577
subtest 'GetCOinSBiblio and get_openurl' => sub {
578
    plan tests => 2;
579
580
    $schema->storage->txn_begin;
581
582
    my $builder = t::lib::TestBuilder->new;
583
    my $biblio = $builder->build_sample_biblio({
584
            title => 'Title 1',
585
            author => 'Author 1'
586
        });
587
    my $record = $biblio->metadata->record;
588
589
    t::lib::Mocks::mock_preference("OpenURLResolverURL", "https://koha.example.com/");
590
591
    is(
592
        C4::Biblio::GetCOinSBiblio($record),
593
        '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',
594
        'GetCOinsBiblio returned right metadata'
595
    );
596
597
    is(
598
        $biblio->get_openurl,
599
        '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',
600
        'Koha::Biblio->get_openurl returned right URL'
601
    );
602
603
    $schema->storage->txn_rollback;
604
};
(-)a/t/db_dependent/Koha/Biblio.t (-1 / +32 lines)
Lines 17-27 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 3;
20
use Test::More tests => 4;
21
21
22
use C4::Biblio;
22
use C4::Biblio;
23
use Koha::Database;
23
use Koha::Database;
24
24
25
use t::lib::TestBuilder;
26
use t::lib::Mocks;
27
25
BEGIN {
28
BEGIN {
26
    use_ok('Koha::Biblio');
29
    use_ok('Koha::Biblio');
27
    use_ok('Koha::Biblios');
30
    use_ok('Koha::Biblios');
Lines 55-57 subtest 'metadata() tests' => sub { Link Here
55
58
56
    $schema->storage->txn_rollback;
59
    $schema->storage->txn_rollback;
57
};
60
};
61
62
subtest 'get_coins and get_openurl' => sub {
63
64
    plan tests => 2;
65
66
    $schema->storage->txn_begin;
67
68
    my $builder = t::lib::TestBuilder->new;
69
    my $biblio = $builder->build_sample_biblio({
70
            title => 'Title 1',
71
            author => 'Author 1'
72
        });
73
74
    is(
75
        $biblio->get_coins,
76
        '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',
77
        'GetCOinsBiblio returned right metadata'
78
    );
79
80
    t::lib::Mocks::mock_preference("OpenURLResolverURL", "https://koha.example.com/");
81
    is(
82
        $biblio->get_openurl,
83
        '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',
84
        'Koha::Biblio->get_openurl returned right URL'
85
    );
86
87
    $schema->storage->txn_rollback;
88
};
(-)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