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

(-)a/C4/Biblio.pm (-29 lines)
Lines 1399-1433 sub GetCOinSBiblio { Link Here
1399
    return $coins_value;
1399
    return $coins_value;
1400
}
1400
}
1401
1401
1402
=head2 GetOpenURLResolverURL
1403
1404
    my $url = C4::Biblio::GetOpenURLResolverURL($record);
1405
1406
    Takes MARC::Record and return url for OpenURL resolver set in OpenURLResolverURL
1407
1408
=cut
1409
1410
sub GetOpenURLResolverURL {
1411
    my ($record) = @_;
1412
1413
    my $coins = GetCOinSBiblio($record);
1414
    my $OpenURLResolverURL = C4::Context->preference('OpenURLResolverURL');
1415
1416
    if ($OpenURLResolverURL) {
1417
        my $uri = URI->new($OpenURLResolverURL);
1418
1419
        if (not defined $uri->query) {
1420
            $OpenURLResolverURL .= '?';
1421
        } else {
1422
            $OpenURLResolverURL .= '&';
1423
        }
1424
        $OpenURLResolverURL .= $coins;
1425
    }
1426
1427
    return $OpenURLResolverURL;
1428
}
1429
1430
1431
=head2 GetMarcPrice
1402
=head2 GetMarcPrice
1432
1403
1433
return the prices in accordance with the Marc format.
1404
return the prices in accordance with the Marc format.
(-)a/C4/XSLT.pm (-2 / +1 lines)
Lines 251-258 sub XSLTParse4Display { Link Here
251
        my $biblio = $biblio_object->biblioitem->unblessed;
251
        my $biblio = $biblio_object->biblioitem->unblessed;
252
        my @itypes = split( /\s/, C4::Context->preference('OPACOpenURLItemTypes') );
252
        my @itypes = split( /\s/, C4::Context->preference('OPACOpenURLItemTypes') );
253
        if (grep /^$biblio->{itemtype}$/, @itypes) {
253
        if (grep /^$biblio->{itemtype}$/, @itypes) {
254
            $variables->{OpenURLResolverURL} =
254
            $variables->{OpenURLResolverURL} = $biblio_object->get_openurl;
255
              C4::Biblio::GetOpenURLResolverURL($orig_record);
256
        }
255
        }
257
    }
256
    }
258
    my $varxml = "<variables>\n";
257
    my $varxml = "<variables>\n";
(-)a/Koha/Biblio.pm (+29 lines)
Lines 469-474 sub has_items_waiting_or_intransit { Link Here
469
    return 0;
469
    return 0;
470
}
470
}
471
471
472
=head2 get_openurl
473
474
    my $biblio = Koha::Biblios->find( $biblionumber );
475
    my $url = $biblio->get_openurl;
476
477
    Takes MARC::Record and return url for OpenURL resolver set in OpenURLResolverURL
478
479
=cut
480
481
sub get_openurl {
482
    my ( $self ) = @_;
483
484
    my $coins = C4::Biblio::GetCOinSBiblio( $self->metadata->record);
485
    my $OpenURLResolverURL = C4::Context->preference('OpenURLResolverURL');
486
487
    if ($OpenURLResolverURL) {
488
        my $uri = URI->new($OpenURLResolverURL);
489
490
        if (not defined $uri->query) {
491
            $OpenURLResolverURL .= '?';
492
        } else {
493
            $OpenURLResolverURL .= '&amp;';
494
        }
495
        $OpenURLResolverURL .= $coins;
496
    }
497
498
    return $OpenURLResolverURL;
499
}
500
472
=head3 type
501
=head3 type
473
502
474
=cut
503
=cut
(-)a/t/db_dependent/Biblio.t (-4 / +3 lines)
Lines 591-597 subtest 'ModBiblio called from linker test' => sub { Link Here
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
593
594
subtest 'GetCOinSBiblio and GetOpenURLResolverURL' => sub {
594
subtest 'GetCOinSBiblio and get_openurl' => sub {
595
    plan tests => 2;
595
    plan tests => 2;
596
596
597
    $schema->storage->txn_begin;
597
    $schema->storage->txn_begin;
Lines 612-620 subtest 'GetCOinSBiblio and GetOpenURLResolverURL' => sub { Link Here
612
    );
612
    );
613
613
614
    is(
614
    is(
615
        C4::Biblio::GetOpenURLResolverURL($record),
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',
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
        'GetOpenURLResolverURL returned right URL'
617
        'Koha::Biblio->get_openurl returned right URL'
618
    );
618
    );
619
619
620
    $schema->storage->txn_rollback;
620
    $schema->storage->txn_rollback;
621
- 

Return to bug 8995