Lines 1682-1743
The subjects are stored in different fields depending on MARC flavour
Link Here
|
1682 |
|
1682 |
|
1683 |
sub GetMarcSubjects { |
1683 |
sub GetMarcSubjects { |
1684 |
my ( $record, $marcflavour ) = @_; |
1684 |
my ( $record, $marcflavour ) = @_; |
1685 |
my ( $mintag, $maxtag ); |
1685 |
my ( $mintag, $maxtag, $fields_filter ); |
1686 |
if ( $marcflavour eq "UNIMARC" ) { |
1686 |
if ( $marcflavour eq "UNIMARC" ) { |
1687 |
$mintag = "600"; |
1687 |
$mintag = "600"; |
1688 |
$maxtag = "611"; |
1688 |
$maxtag = "611"; |
1689 |
} else { # assume marc21 if not unimarc |
1689 |
$fields_filter = '6..'; |
|
|
1690 |
} else { # marc21/normarc |
1690 |
$mintag = "600"; |
1691 |
$mintag = "600"; |
1691 |
$maxtag = "699"; |
1692 |
$maxtag = "699"; |
|
|
1693 |
$fields_filter = '6..'; |
1692 |
} |
1694 |
} |
1693 |
|
1695 |
|
1694 |
my @marcsubjects; |
1696 |
my @marcsubjects; |
1695 |
my $subject = ""; |
|
|
1696 |
my $subfield = ""; |
1697 |
my $marcsubject; |
1698 |
|
1697 |
|
1699 |
my $subject_limit = C4::Context->preference("TraceCompleteSubfields") ? 'su,complete-subfield' : 'su'; |
1698 |
my $subject_limit = C4::Context->preference("TraceCompleteSubfields") ? 'su,complete-subfield' : 'su'; |
|
|
1699 |
my $authoritysep = C4::Context->preference('authoritysep'); |
1700 |
|
1700 |
|
1701 |
foreach my $field ( $record->field('6..') ) { |
1701 |
foreach my $field ( $record->field($fields_filter) ) { |
1702 |
next unless $field->tag() >= $mintag && $field->tag() <= $maxtag; |
1702 |
next unless ($field->tag() >= $mintag && $field->tag() <= $maxtag); |
1703 |
my @subfields_loop; |
1703 |
my @subfields_loop; |
1704 |
my @subfields = $field->subfields(); |
1704 |
my @subfields = $field->subfields(); |
1705 |
my $counter = 0; |
|
|
1706 |
my @link_loop; |
1705 |
my @link_loop; |
1707 |
|
1706 |
|
1708 |
# if there is an authority link, build the link with an= subfield9 |
1707 |
# if there is an authority link, build the links with an= subfield9 |
1709 |
my $found9 = 0; |
1708 |
my $subfield9 = $field->subfield('9'); |
|
|
1709 |
if ($subfield9) { |
1710 |
my $linkvalue = $subfield9; |
1711 |
$linkvalue =~ s/(\(|\))//g; |
1712 |
@link_loop = ( { limit => 'an', 'link' => $linkvalue } ); |
1713 |
} |
1714 |
|
1715 |
# other subfields |
1710 |
for my $subject_subfield (@subfields) { |
1716 |
for my $subject_subfield (@subfields) { |
|
|
1717 |
next if ( $subject_subfield->[0] eq '9' ); |
1711 |
|
1718 |
|
1712 |
# don't load unimarc subfields 3,4,5 |
1719 |
# don't load unimarc subfields 3,4,5 |
1713 |
next if ( ( $marcflavour eq "UNIMARC" ) and ( $subject_subfield->[0] =~ /2|3|4|5/ ) ); |
1720 |
next if ( ( $marcflavour eq "UNIMARC" ) and ( $subject_subfield->[0] =~ /2|3|4|5/ ) ); |
1714 |
|
|
|
1715 |
# don't load MARC21 subfields 2 (FIXME: any more subfields??) |
1721 |
# don't load MARC21 subfields 2 (FIXME: any more subfields??) |
1716 |
next if ( ( $marcflavour eq "MARC21" ) and ( $subject_subfield->[0] =~ /2/ ) ); |
1722 |
next if ( ( $marcflavour eq "MARC21" ) and ( $subject_subfield->[0] =~ /2/ ) ); |
|
|
1723 |
|
1717 |
my $code = $subject_subfield->[0]; |
1724 |
my $code = $subject_subfield->[0]; |
1718 |
my $value = $subject_subfield->[1]; |
1725 |
my $value = $subject_subfield->[1]; |
1719 |
my $linkvalue = $value; |
1726 |
my $linkvalue = $value; |
1720 |
$linkvalue =~ s/(\(|\))//g; |
1727 |
$linkvalue =~ s/(\(|\))//g; |
1721 |
my $operator; |
1728 |
# if no authority link, build a search query |
1722 |
if ( $counter != 0 ) { |
1729 |
unless ($subfield9) { |
1723 |
$operator = ' and '; |
1730 |
push @link_loop, { |
1724 |
} |
1731 |
limit => $subject_limit, |
1725 |
if ( $code eq 9 ) { |
1732 |
'link' => $linkvalue, |
1726 |
$found9 = 1; |
1733 |
operator => (scalar @link_loop) ? ' and ' : undef |
1727 |
@link_loop = ( { 'limit' => 'an', link => "$linkvalue" } ); |
1734 |
}; |
1728 |
} |
|
|
1729 |
if ( not $found9 ) { |
1730 |
push @link_loop, { 'limit' => $subject_limit, link => $linkvalue, operator => $operator }; |
1731 |
} |
1732 |
my $separator; |
1733 |
if ( $counter != 0 ) { |
1734 |
$separator = C4::Context->preference('authoritysep'); |
1735 |
} |
1735 |
} |
1736 |
|
|
|
1737 |
# ignore $9 |
1738 |
my @this_link_loop = @link_loop; |
1736 |
my @this_link_loop = @link_loop; |
1739 |
push @subfields_loop, { code => $code, value => $value, link_loop => \@this_link_loop, separator => $separator } unless ( $subject_subfield->[0] eq 9 || $subject_subfield->[0] eq '0' ); |
1737 |
# do not display $0 |
1740 |
$counter++; |
1738 |
unless ( $code eq '0' ) { |
|
|
1739 |
push @subfields_loop, { |
1740 |
code => $code, |
1741 |
value => $value, |
1742 |
link_loop => \@this_link_loop, |
1743 |
separator => (scalar @subfields_loop) ? $authoritysep : '' |
1744 |
}; |
1745 |
} |
1741 |
} |
1746 |
} |
1742 |
|
1747 |
|
1743 |
push @marcsubjects, { MARCSUBJECT_SUBFIELDS_LOOP => \@subfields_loop }; |
1748 |
push @marcsubjects, { MARCSUBJECT_SUBFIELDS_LOOP => \@subfields_loop }; |
Lines 1757-1763
The authors are stored in different fields depending on MARC flavour
Link Here
|
1757 |
|
1762 |
|
1758 |
sub GetMarcAuthors { |
1763 |
sub GetMarcAuthors { |
1759 |
my ( $record, $marcflavour ) = @_; |
1764 |
my ( $record, $marcflavour ) = @_; |
1760 |
my ( $mintag, $maxtag ); |
1765 |
my ( $mintag, $maxtag, $fields_filter ); |
1761 |
|
1766 |
|
1762 |
# tagslib useful for UNIMARC author reponsabilities |
1767 |
# tagslib useful for UNIMARC author reponsabilities |
1763 |
my $tagslib = |
1768 |
my $tagslib = |
Lines 1765-1779
sub GetMarcAuthors {
Link Here
|
1765 |
if ( $marcflavour eq "UNIMARC" ) { |
1770 |
if ( $marcflavour eq "UNIMARC" ) { |
1766 |
$mintag = "700"; |
1771 |
$mintag = "700"; |
1767 |
$maxtag = "712"; |
1772 |
$maxtag = "712"; |
1768 |
} elsif ( $marcflavour eq "MARC21" || $marcflavour eq "NORMARC" ) { # assume marc21 or normarc if not unimarc |
1773 |
$fields_filter = '7..'; |
|
|
1774 |
} else { # marc21/normarc |
1769 |
$mintag = "700"; |
1775 |
$mintag = "700"; |
1770 |
$maxtag = "720"; |
1776 |
$maxtag = "720"; |
1771 |
} else { |
1777 |
$fields_filter = '7..'; |
1772 |
return; |
|
|
1773 |
} |
1778 |
} |
|
|
1779 |
|
1774 |
my @marcauthors; |
1780 |
my @marcauthors; |
|
|
1781 |
my $authoritysep = C4::Context->preference('authoritysep'); |
1775 |
|
1782 |
|
1776 |
foreach my $field ( $record->fields ) { |
1783 |
foreach my $field ( $record->field($fields_filter) ) { |
1777 |
next unless $field->tag() >= $mintag && $field->tag() <= $maxtag; |
1784 |
next unless $field->tag() >= $mintag && $field->tag() <= $maxtag; |
1778 |
my @subfields_loop; |
1785 |
my @subfields_loop; |
1779 |
my @link_loop; |
1786 |
my @link_loop; |
Lines 1782-1827
sub GetMarcAuthors {
Link Here
|
1782 |
|
1789 |
|
1783 |
# if there is an authority link, build the link with Koha-Auth-Number: subfield9 |
1790 |
# if there is an authority link, build the link with Koha-Auth-Number: subfield9 |
1784 |
my $subfield9 = $field->subfield('9'); |
1791 |
my $subfield9 = $field->subfield('9'); |
|
|
1792 |
if ($subfield9) { |
1793 |
my $linkvalue = $subfield9; |
1794 |
$linkvalue =~ s/(\(|\))//g; |
1795 |
@link_loop = ( { 'limit' => 'an', 'link' => $linkvalue } ); |
1796 |
} |
1797 |
|
1798 |
# other subfields |
1785 |
for my $authors_subfield (@subfields) { |
1799 |
for my $authors_subfield (@subfields) { |
|
|
1800 |
next if ( $authors_subfield->[0] eq '9' ); |
1786 |
|
1801 |
|
1787 |
# don't load unimarc subfields 3, 5 |
1802 |
# don't load unimarc subfields 3, 5 |
1788 |
next if ( $marcflavour eq 'UNIMARC' and ( $authors_subfield->[0] =~ /3|5/ ) ); |
1803 |
next if ( $marcflavour eq 'UNIMARC' and ( $authors_subfield->[0] =~ /3|5/ ) ); |
1789 |
my $subfieldcode = $authors_subfield->[0]; |
1804 |
|
|
|
1805 |
my $code = $authors_subfield->[0]; |
1790 |
my $value = $authors_subfield->[1]; |
1806 |
my $value = $authors_subfield->[1]; |
1791 |
my $linkvalue = $value; |
1807 |
my $linkvalue = $value; |
1792 |
$linkvalue =~ s/(\(|\))//g; |
1808 |
$linkvalue =~ s/(\(|\))//g; |
1793 |
my $operator; |
1809 |
# UNIMARC author responsibility |
1794 |
if ( $count_auth != 0 ) { |
1810 |
if ( $marcflavour eq 'UNIMARC' and $code eq '4' ) { |
1795 |
$operator = ' and '; |
1811 |
$value = GetAuthorisedValueDesc( $field->tag(), $code, $value, '', $tagslib ); |
1796 |
} |
1812 |
$linkvalue = "($value)"; |
1797 |
|
1813 |
} |
1798 |
# if we have an authority link, use that as the link, otherwise use standard searching |
1814 |
# if no authority link, build a search query |
1799 |
if ($subfield9) { |
1815 |
unless ($subfield9) { |
1800 |
@link_loop = ( { 'limit' => 'an', link => "$subfield9" } ); |
1816 |
push @link_loop, { |
1801 |
} else { |
1817 |
limit => 'au', |
1802 |
|
1818 |
'link' => $linkvalue, |
1803 |
# reset $linkvalue if UNIMARC author responsibility |
1819 |
operator => (scalar @link_loop) ? ' and ' : undef |
1804 |
if ( $marcflavour eq 'UNIMARC' and ( $authors_subfield->[0] eq "4" ) ) { |
1820 |
}; |
1805 |
$linkvalue = "(" . GetAuthorisedValueDesc( $field->tag(), $authors_subfield->[0], $authors_subfield->[1], '', $tagslib ) . ")"; |
|
|
1806 |
} |
1807 |
push @link_loop, { 'limit' => 'au', link => $linkvalue, operator => $operator }; |
1808 |
} |
1821 |
} |
1809 |
$value = GetAuthorisedValueDesc( $field->tag(), $authors_subfield->[0], $authors_subfield->[1], '', $tagslib ) |
|
|
1810 |
if ( $marcflavour eq 'UNIMARC' and ( $authors_subfield->[0] =~ /4/ ) ); |
1811 |
my @this_link_loop = @link_loop; |
1822 |
my @this_link_loop = @link_loop; |
1812 |
my $separator; |
1823 |
# do not display $0 |
1813 |
if ( $count_auth != 0 ) { |
1824 |
unless ( $code eq '0') { |
1814 |
$separator = C4::Context->preference('authoritysep'); |
1825 |
push @subfields_loop, { |
|
|
1826 |
tag => $field->tag(), |
1827 |
code => $code, |
1828 |
value => $value, |
1829 |
link_loop => \@this_link_loop, |
1830 |
separator => (scalar @subfields_loop) ? $authoritysep : '' |
1831 |
}; |
1815 |
} |
1832 |
} |
1816 |
push @subfields_loop, |
|
|
1817 |
{ tag => $field->tag(), |
1818 |
code => $subfieldcode, |
1819 |
value => $value, |
1820 |
link_loop => \@this_link_loop, |
1821 |
separator => $separator |
1822 |
} |
1823 |
unless ( $authors_subfield->[0] eq '9' || $authors_subfield->[0] eq '0'); |
1824 |
$count_auth++; |
1825 |
} |
1833 |
} |
1826 |
push @marcauthors, { MARCAUTHOR_SUBFIELDS_LOOP => \@subfields_loop }; |
1834 |
push @marcauthors, { MARCAUTHOR_SUBFIELDS_LOOP => \@subfields_loop }; |
1827 |
} |
1835 |
} |
Lines 1894-1969
The series are stored in different fields depending on MARC flavour
Link Here
|
1894 |
|
1902 |
|
1895 |
sub GetMarcSeries { |
1903 |
sub GetMarcSeries { |
1896 |
my ( $record, $marcflavour ) = @_; |
1904 |
my ( $record, $marcflavour ) = @_; |
1897 |
my ( $mintag, $maxtag ); |
1905 |
my ( $mintag, $maxtag, $fields_filter ); |
1898 |
if ( $marcflavour eq "UNIMARC" ) { |
1906 |
if ( $marcflavour eq "UNIMARC" ) { |
1899 |
$mintag = "600"; |
1907 |
$mintag = "600"; |
1900 |
$maxtag = "619"; |
1908 |
$maxtag = "619"; |
1901 |
} else { # assume marc21 if not unimarc |
1909 |
$fields_filter = '6..'; |
|
|
1910 |
} else { # marc21/normarc |
1902 |
$mintag = "440"; |
1911 |
$mintag = "440"; |
1903 |
$maxtag = "490"; |
1912 |
$maxtag = "490"; |
|
|
1913 |
$fields_filter = '4..'; |
1904 |
} |
1914 |
} |
1905 |
|
1915 |
|
1906 |
my @marcseries; |
1916 |
my @marcseries; |
1907 |
my $subjct = ""; |
1917 |
my $authoritysep = C4::Context->preference('authoritysep'); |
1908 |
my $subfield = ""; |
|
|
1909 |
my $marcsubjct; |
1910 |
|
1918 |
|
1911 |
foreach my $field ( $record->field('440'), $record->field('490') ) { |
1919 |
foreach my $field ( $record->field($fields_filter) ) { |
|
|
1920 |
next unless $field->tag() >= $mintag && $field->tag() <= $maxtag; |
1912 |
my @subfields_loop; |
1921 |
my @subfields_loop; |
1913 |
|
|
|
1914 |
#my $value = $field->subfield('a'); |
1915 |
#$marcsubjct = {MARCSUBJCT => $value,}; |
1916 |
my @subfields = $field->subfields(); |
1922 |
my @subfields = $field->subfields(); |
1917 |
|
|
|
1918 |
#warn "subfields:".join " ", @$subfields; |
1919 |
my $counter = 0; |
1920 |
my @link_loop; |
1923 |
my @link_loop; |
|
|
1924 |
|
1921 |
for my $series_subfield (@subfields) { |
1925 |
for my $series_subfield (@subfields) { |
1922 |
my $volume_number; |
|
|
1923 |
undef $volume_number; |
1924 |
|
1926 |
|
1925 |
# see if this is an instance of a volume |
1927 |
# ignore $9, used for authority link |
1926 |
if ( $series_subfield->[0] eq 'v' ) { |
1928 |
next if ( $series_subfield->[0] eq '9' ); |
1927 |
$volume_number = 1; |
|
|
1928 |
} |
1929 |
|
1929 |
|
|
|
1930 |
my $volume_number; |
1930 |
my $code = $series_subfield->[0]; |
1931 |
my $code = $series_subfield->[0]; |
1931 |
my $value = $series_subfield->[1]; |
1932 |
my $value = $series_subfield->[1]; |
1932 |
my $linkvalue = $value; |
1933 |
my $linkvalue = $value; |
1933 |
$linkvalue =~ s/(\(|\))//g; |
1934 |
$linkvalue =~ s/(\(|\))//g; |
1934 |
if ( $counter != 0 ) { |
1935 |
|
1935 |
push @link_loop, { link => $linkvalue, operator => ' and ', }; |
1936 |
# see if this is an instance of a volume |
1936 |
} else { |
1937 |
if ( $code eq 'v' ) { |
1937 |
push @link_loop, { link => $linkvalue, operator => undef, }; |
1938 |
$volume_number = 1; |
1938 |
} |
|
|
1939 |
my $separator; |
1940 |
if ( $counter != 0 ) { |
1941 |
$separator = C4::Context->preference('authoritysep'); |
1942 |
} |
1939 |
} |
|
|
1940 |
|
1941 |
push @link_loop, { |
1942 |
'link' => $linkvalue, |
1943 |
operator => (scalar @link_loop) ? ' and ' : undef |
1944 |
}; |
1945 |
|
1943 |
if ($volume_number) { |
1946 |
if ($volume_number) { |
1944 |
push @subfields_loop, { volumenum => $value }; |
1947 |
push @subfields_loop, { volumenum => $value }; |
1945 |
} else { |
1948 |
} else { |
1946 |
if ( $series_subfield->[0] ne '9' ) { |
1949 |
push @subfields_loop, { |
1947 |
push @subfields_loop, { |
1950 |
code => $code, |
1948 |
code => $code, |
1951 |
value => $value, |
1949 |
value => $value, |
1952 |
link_loop => \@link_loop, |
1950 |
link_loop => \@link_loop, |
1953 |
separator => (scalar @subfields_loop) ? $authoritysep : '', |
1951 |
separator => $separator, |
1954 |
volumenum => $volume_number, |
1952 |
volumenum => $volume_number, |
|
|
1953 |
}; |
1954 |
} |
1955 |
} |
1955 |
} |
1956 |
} |
1956 |
$counter++; |
|
|
1957 |
} |
1957 |
} |
1958 |
push @marcseries, { MARCSERIES_SUBFIELDS_LOOP => \@subfields_loop }; |
1958 |
push @marcseries, { MARCSERIES_SUBFIELDS_LOOP => \@subfields_loop }; |
1959 |
|
1959 |
|
1960 |
#$marcsubjct = {MARCSUBJCT => $field->as_string(),}; |
|
|
1961 |
#push @marcsubjcts, $marcsubjct; |
1962 |
#$subjct = $value; |
1963 |
|
1964 |
} |
1960 |
} |
1965 |
my $marcseriessarray = \@marcseries; |
1961 |
return \@marcseries; |
1966 |
return $marcseriessarray; |
|
|
1967 |
} #end getMARCseriess |
1962 |
} #end getMARCseriess |
1968 |
|
1963 |
|
1969 |
=head2 GetMarcHosts |
1964 |
=head2 GetMarcHosts |