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