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; |