Lines 35-41
BEGIN {
Link Here
|
35 |
GetMarcNotes |
35 |
GetMarcNotes |
36 |
GetMarcISBN |
36 |
GetMarcISBN |
37 |
GetMarcISSN |
37 |
GetMarcISSN |
38 |
GetMarcSubjects |
|
|
39 |
GetMarcAuthors |
38 |
GetMarcAuthors |
40 |
GetMarcSeries |
39 |
GetMarcSeries |
41 |
GetMarcUrls |
40 |
GetMarcUrls |
Lines 1605-1699
sub GetMarcNotes {
Link Here
|
1605 |
return \@marcnotes; |
1604 |
return \@marcnotes; |
1606 |
} |
1605 |
} |
1607 |
|
1606 |
|
1608 |
=head2 GetMarcSubjects |
|
|
1609 |
|
1610 |
$marcsubjcts = GetMarcSubjects($record,$marcflavour); |
1611 |
|
1612 |
Get all subjects from the MARC record and returns them in an array. |
1613 |
The subjects are stored in different fields depending on MARC flavour |
1614 |
|
1615 |
=cut |
1616 |
|
1617 |
sub GetMarcSubjects { |
1618 |
my ( $record, $marcflavour ) = @_; |
1619 |
if (!$record) { |
1620 |
carp 'GetMarcSubjects called on undefined record'; |
1621 |
return; |
1622 |
} |
1623 |
my ( $mintag, $maxtag, $fields_filter ); |
1624 |
if ( $marcflavour eq "UNIMARC" ) { |
1625 |
$mintag = "600"; |
1626 |
$maxtag = "611"; |
1627 |
$fields_filter = '6..'; |
1628 |
} else { # marc21/normarc |
1629 |
$mintag = "600"; |
1630 |
$maxtag = "699"; |
1631 |
$fields_filter = '6..'; |
1632 |
} |
1633 |
|
1634 |
my @marcsubjects; |
1635 |
|
1636 |
my $subject_limit = C4::Context->preference("TraceCompleteSubfields") ? 'su,complete-subfield' : 'su'; |
1637 |
my $AuthoritySeparator = C4::Context->preference('AuthoritySeparator'); |
1638 |
|
1639 |
foreach my $field ( $record->field($fields_filter) ) { |
1640 |
next unless ($field->tag() >= $mintag && $field->tag() <= $maxtag); |
1641 |
my @subfields_loop; |
1642 |
my @subfields = $field->subfields(); |
1643 |
my @link_loop; |
1644 |
|
1645 |
# if there is an authority link, build the links with an= subfield9 |
1646 |
my $subfield9 = $field->subfield('9'); |
1647 |
my $authoritylink; |
1648 |
if ($subfield9) { |
1649 |
my $linkvalue = $subfield9; |
1650 |
$linkvalue =~ s/(\(|\))//g; |
1651 |
@link_loop = ( { limit => 'an', 'link' => $linkvalue } ); |
1652 |
$authoritylink = $linkvalue |
1653 |
} |
1654 |
|
1655 |
# other subfields |
1656 |
for my $subject_subfield (@subfields) { |
1657 |
next if ( $subject_subfield->[0] eq '9' ); |
1658 |
|
1659 |
# don't load unimarc subfields 3,4,5 |
1660 |
next if ( ( $marcflavour eq "UNIMARC" ) and ( $subject_subfield->[0] =~ /2|3|4|5/ ) ); |
1661 |
# don't load MARC21 subfields 2 (FIXME: any more subfields??) |
1662 |
next if ( ( $marcflavour eq "MARC21" ) and ( $subject_subfield->[0] =~ /2/ ) ); |
1663 |
|
1664 |
my $code = $subject_subfield->[0]; |
1665 |
my $value = $subject_subfield->[1]; |
1666 |
my $linkvalue = $value; |
1667 |
$linkvalue =~ s/(\(|\))//g; |
1668 |
# if no authority link, build a search query |
1669 |
unless ($subfield9) { |
1670 |
push @link_loop, { |
1671 |
limit => $subject_limit, |
1672 |
'link' => $linkvalue, |
1673 |
operator => (scalar @link_loop) ? ' and ' : undef |
1674 |
}; |
1675 |
} |
1676 |
my @this_link_loop = @link_loop; |
1677 |
# do not display $0 |
1678 |
unless ( $code eq '0' ) { |
1679 |
push @subfields_loop, { |
1680 |
code => $code, |
1681 |
value => $value, |
1682 |
link_loop => \@this_link_loop, |
1683 |
separator => (scalar @subfields_loop) ? $AuthoritySeparator : '' |
1684 |
}; |
1685 |
} |
1686 |
} |
1687 |
|
1688 |
push @marcsubjects, { |
1689 |
MARCSUBJECT_SUBFIELDS_LOOP => \@subfields_loop, |
1690 |
authoritylink => $authoritylink, |
1691 |
} if $authoritylink || @subfields_loop; |
1692 |
|
1693 |
} |
1694 |
return \@marcsubjects; |
1695 |
} #end getMARCsubjects |
1696 |
|
1697 |
=head2 GetMarcAuthors |
1607 |
=head2 GetMarcAuthors |
1698 |
|
1608 |
|
1699 |
authors = GetMarcAuthors($record,$marcflavour); |
1609 |
authors = GetMarcAuthors($record,$marcflavour); |