|
Lines 33-39
BEGIN {
Link Here
|
| 33 |
GetMarcControlnumber |
33 |
GetMarcControlnumber |
| 34 |
GetMarcISBN |
34 |
GetMarcISBN |
| 35 |
GetMarcISSN |
35 |
GetMarcISSN |
| 36 |
GetMarcSubjects |
|
|
| 37 |
GetMarcSeries |
36 |
GetMarcSeries |
| 38 |
GetMarcUrls |
37 |
GetMarcUrls |
| 39 |
GetUsedMarcStructure |
38 |
GetUsedMarcStructure |
|
Lines 1560-1654
sub GetMarcISSN {
Link Here
|
| 1560 |
return \@marcissns; |
1559 |
return \@marcissns; |
| 1561 |
} # end GetMarcISSN |
1560 |
} # end GetMarcISSN |
| 1562 |
|
1561 |
|
| 1563 |
=head2 GetMarcSubjects |
|
|
| 1564 |
|
| 1565 |
$marcsubjcts = GetMarcSubjects($record,$marcflavour); |
| 1566 |
|
| 1567 |
Get all subjects from the MARC record and returns them in an array. |
| 1568 |
The subjects are stored in different fields depending on MARC flavour |
| 1569 |
|
| 1570 |
=cut |
| 1571 |
|
| 1572 |
sub GetMarcSubjects { |
| 1573 |
my ( $record, $marcflavour ) = @_; |
| 1574 |
if (!$record) { |
| 1575 |
carp 'GetMarcSubjects called on undefined record'; |
| 1576 |
return; |
| 1577 |
} |
| 1578 |
my ( $mintag, $maxtag, $fields_filter ); |
| 1579 |
if ( $marcflavour eq "UNIMARC" ) { |
| 1580 |
$mintag = "600"; |
| 1581 |
$maxtag = "611"; |
| 1582 |
$fields_filter = '6..'; |
| 1583 |
} else { # marc21 |
| 1584 |
$mintag = "600"; |
| 1585 |
$maxtag = "699"; |
| 1586 |
$fields_filter = '6..'; |
| 1587 |
} |
| 1588 |
|
| 1589 |
my @marcsubjects; |
| 1590 |
|
| 1591 |
my $subject_limit = C4::Context->preference("TraceCompleteSubfields") ? 'su,complete-subfield' : 'su'; |
| 1592 |
my $AuthoritySeparator = C4::Context->preference('AuthoritySeparator'); |
| 1593 |
|
| 1594 |
foreach my $field ( $record->field($fields_filter) ) { |
| 1595 |
next unless ($field->tag() >= $mintag && $field->tag() <= $maxtag); |
| 1596 |
my @subfields_loop; |
| 1597 |
my @subfields = $field->subfields(); |
| 1598 |
my @link_loop; |
| 1599 |
|
| 1600 |
# if there is an authority link, build the links with an= subfield9 |
| 1601 |
my $subfield9 = $field->subfield('9'); |
| 1602 |
my $authoritylink; |
| 1603 |
if ($subfield9) { |
| 1604 |
my $linkvalue = $subfield9; |
| 1605 |
$linkvalue =~ s/(\(|\))//g; |
| 1606 |
@link_loop = ( { limit => 'an', 'link' => $linkvalue } ); |
| 1607 |
$authoritylink = $linkvalue |
| 1608 |
} |
| 1609 |
|
| 1610 |
# other subfields |
| 1611 |
for my $subject_subfield (@subfields) { |
| 1612 |
next if ( $subject_subfield->[0] eq '9' ); |
| 1613 |
|
| 1614 |
# don't load unimarc subfields 3,4,5 |
| 1615 |
next if ( ( $marcflavour eq "UNIMARC" ) and ( $subject_subfield->[0] =~ /2|3|4|5/ ) ); |
| 1616 |
# don't load MARC21 subfields 2 (FIXME: any more subfields??) |
| 1617 |
next if ( ( $marcflavour eq "MARC21" ) and ( $subject_subfield->[0] =~ /2/ ) ); |
| 1618 |
|
| 1619 |
my $code = $subject_subfield->[0]; |
| 1620 |
my $value = $subject_subfield->[1]; |
| 1621 |
my $linkvalue = $value; |
| 1622 |
$linkvalue =~ s/(\(|\))//g; |
| 1623 |
# if no authority link, build a search query |
| 1624 |
unless ($subfield9) { |
| 1625 |
push @link_loop, { |
| 1626 |
limit => $subject_limit, |
| 1627 |
'link' => $linkvalue, |
| 1628 |
operator => (scalar @link_loop) ? ' AND ' : undef |
| 1629 |
}; |
| 1630 |
} |
| 1631 |
my @this_link_loop = @link_loop; |
| 1632 |
# do not display $0 |
| 1633 |
unless ( $code eq '0' ) { |
| 1634 |
push @subfields_loop, { |
| 1635 |
code => $code, |
| 1636 |
value => $value, |
| 1637 |
link_loop => \@this_link_loop, |
| 1638 |
separator => (scalar @subfields_loop) ? $AuthoritySeparator : '' |
| 1639 |
}; |
| 1640 |
} |
| 1641 |
} |
| 1642 |
|
| 1643 |
push @marcsubjects, { |
| 1644 |
MARCSUBJECT_SUBFIELDS_LOOP => \@subfields_loop, |
| 1645 |
authoritylink => $authoritylink, |
| 1646 |
} if $authoritylink || @subfields_loop; |
| 1647 |
|
| 1648 |
} |
| 1649 |
return \@marcsubjects; |
| 1650 |
} #end getMARCsubjects |
| 1651 |
|
| 1652 |
=head2 GetMarcUrls |
1562 |
=head2 GetMarcUrls |
| 1653 |
|
1563 |
|
| 1654 |
$marcurls = GetMarcUrls($record,$marcflavour); |
1564 |
$marcurls = GetMarcUrls($record,$marcflavour); |