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

(-)a/C4/Biblio.pm (-29 lines)
Lines 1397-1431 sub GetCOinSBiblio { Link Here
1397
    return $coins_value;
1397
    return $coins_value;
1398
}
1398
}
1399
1399
1400
=head2 GetOpenURLResolverURL
1401
1402
    my $url = C4::Biblio::GetOpenURLResolverURL($record);
1403
1404
    Takes MARC::Record and return url for OpenURL resolver set in OpenURLResolverURL
1405
1406
=cut
1407
1408
sub GetOpenURLResolverURL {
1409
    my ($record) = @_;
1410
1411
    my $coins = GetCOinSBiblio($record);
1412
    my $OpenURLResolverURL = C4::Context->preference('OpenURLResolverURL');
1413
1414
    if ($OpenURLResolverURL) {
1415
        my $uri = URI->new($OpenURLResolverURL);
1416
1417
        if (not defined $uri->query) {
1418
            $OpenURLResolverURL .= '?';
1419
        } else {
1420
            $OpenURLResolverURL .= '&';
1421
        }
1422
        $OpenURLResolverURL .= $coins;
1423
    }
1424
1425
    return $OpenURLResolverURL;
1426
}
1427
1428
1429
=head2 GetMarcPrice
1400
=head2 GetMarcPrice
1430
1401
1431
return the prices in accordance with the Marc format.
1402
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 442-447 sub has_items_waiting_or_intransit { Link Here
442
    return 0;
442
    return 0;
443
}
443
}
444
444
445
=head2 get_openurl
446
447
    my $biblio = Koha::Biblios->find( $biblionumber );
448
    my $url = $biblio->get_openurl;
449
450
    Takes MARC::Record and return url for OpenURL resolver set in OpenURLResolverURL
451
452
=cut
453
454
sub get_openurl {
455
    my ( $self ) = @_;
456
457
    my $coins = C4::Biblio::GetCOinSBiblio( $self->metadata->record);
458
    my $OpenURLResolverURL = C4::Context->preference('OpenURLResolverURL');
459
460
    if ($OpenURLResolverURL) {
461
        my $uri = URI->new($OpenURLResolverURL);
462
463
        if (not defined $uri->query) {
464
            $OpenURLResolverURL .= '?';
465
        } else {
466
            $OpenURLResolverURL .= '&amp;';
467
        }
468
        $OpenURLResolverURL .= $coins;
469
    }
470
471
    return $OpenURLResolverURL;
472
}
473
445
=head3 type
474
=head3 type
446
475
447
=cut
476
=cut
(-)a/t/db_dependent/Biblio.t (-4 / +3 lines)
Lines 574-580 subtest 'MarcFieldForCreatorAndModifier' => sub { Link Here
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
576
577
subtest 'GetCOinSBiblio and GetOpenURLResolverURL' => sub {
577
subtest 'GetCOinSBiblio and get_openurl' => sub {
578
    plan tests => 2;
578
    plan tests => 2;
579
579
580
    $schema->storage->txn_begin;
580
    $schema->storage->txn_begin;
Lines 595-603 subtest 'GetCOinSBiblio and GetOpenURLResolverURL' => sub { Link Here
595
    );
595
    );
596
596
597
    is(
597
    is(
598
        C4::Biblio::GetOpenURLResolverURL($record),
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',
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
        'GetOpenURLResolverURL returned right URL'
600
        'Koha::Biblio->get_openurl returned right URL'
601
    );
601
    );
602
602
603
    $schema->storage->txn_rollback;
603
    $schema->storage->txn_rollback;
604
- 

Return to bug 8995