1 package C4::Heading::MARC21;
3 # Copyright (C) 2008 LibLime
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
32 use C4::Heading::MARC21;
36 This is an internal helper class used by
37 C<C4::Heading> to parse headings data from
38 MARC21 records. Object of this type
39 do not carry data, instead, they only
42 =head1 DATA STRUCTURES
44 FIXME - this should be moved to a configuration file.
46 =head2 bib_heading_fields
50 my $bib_heading_fields = {
51 '100' => { auth_type => 'PERSO_NAME', subfields => 'abcdefghjklmnopqrst', main_entry => 1 },
52 '110' => { auth_type => 'CORPO_NAME', subfields => 'abcdefghklmnoprst', main_entry => 1 },
53 '111' => { auth_type => 'MEETI_NAME', subfields => 'acdefghjklnpqst', main_entry => 1 },
54 '130' => { auth_type => 'UNIF_TITLE', subfields => 'adfghklmnoprst', main_entry => 1 },
55 '600' => { auth_type => 'PERSO_NAME', subfields => 'abcdefghjklmnopqrstvxyz', subject => 1 },
56 '610' => { auth_type => 'CORPO_NAME', subfields => 'abcdefghklmnoprstvxyz', subject => 1 },
57 '611' => { auth_type => 'MEETI_NAME', subfields => 'acdefghjklnpqstvxyz', subject => 1 },
58 '630' => { auth_type => 'UNIF_TITLE', subfields => 'adfghklmnoprstvxyz', subject => 1 },
59 '648' => { auth_type => 'CHRON_TERM', subfields => 'avxyz', subject => 1 },
60 '650' => { auth_type => 'TOPIC_TERM', subfields => 'abvxyz', subject => 1 },
61 '651' => { auth_type => 'GEOGR_NAME', subfields => 'avxyz', subject => 1 },
62 '655' => { auth_type => 'GENRE/FORM', subfields => 'avxyz', subject => 1 },
63 '700' => { auth_type => 'PERSO_NAME', subfields => 'abcdefghjklmnopqrst' },
64 '710' => { auth_type => 'CORPO_NAME', subfields => 'abcdefghklmnoprst' },
65 '711' => { auth_type => 'MEETI_NAME', subfields => 'acdefghjklnpqst' },
66 '730' => { auth_type => 'UNIF_TITLE', subfields => 'adfghklmnoprst' },
67 '800' => { auth_type => 'PERSO_NAME', subfields => 'abcdefghjklmnopqrst', series => 1 },
68 '810' => { auth_type => 'CORPO_NAME', subfields => 'abcdefghklmnoprst', series => 1 },
69 '811' => { auth_type => 'MEETI_NAME', subfields => 'acdefghjklnpqst', series => 1 },
70 '830' => { auth_type => 'UNIF_TITLE', subfields => 'adfghklmnoprst', series => 1 },
79 'x' => 'generalsubdiv',
80 'y' => 'chronologicalsubdiv',
81 'z' => 'geographicsubdiv',
90 my $marc_handler = C4::Heading::MARC21->new();
98 return bless {}, $class;
101 =head2 valid_bib_heading_tag
105 sub valid_bib_heading_tag {
109 if (exists $bib_heading_fields->{$tag}) {
125 my $tag = $field->tag;
126 my $field_info = $bib_heading_fields->{$tag};
128 my $auth_type = $field_info->{'auth_type'};
129 my $subject = $field_info->{'subject'} ? 1 : 0;
130 my $series = $field_info->{'series'} ? 1 : 0;
131 my $main_entry = $field_info->{'main_entry'} ? 1 : 0;
132 my $thesaurus = $subject ? _get_subject_thesaurus($field) : "lcsh"; # use 'lcsh' for names, UT, etc.
133 my $search_heading = _get_search_heading($field, $field_info->{'subfields'});
134 my $display_heading = _get_display_heading($field, $field_info->{'subfields'});
136 return ($auth_type, $subject, $series, $main_entry, $thesaurus, $search_heading, $display_heading);
139 =head1 INTERNAL FUNCTIONS
141 =head2 _get_subject_thesaurus
145 sub _get_subject_thesaurus {
147 my $ind2 = $field->indicator(2);
149 my $thesaurus = "notdefined";
152 } elsif ($ind2 eq '1') {
154 } elsif ($ind2 eq '2') {
156 } elsif ($ind2 eq '3') {
158 } elsif ($ind2 eq '4') {
159 $thesaurus = "notspecified";
160 } elsif ($ind2 eq '5') {
162 } elsif ($ind2 eq '6') {
164 } elsif ($ind2 eq '7') {
165 my $sf2 = $field->subfield('2');
166 $thesaurus = $sf2 if defined($sf2);
172 =head2 _get_search_heading
176 sub _get_search_heading {
178 my $subfields = shift;
181 my @subfields = $field->subfields();
183 for (my $i = 0; $i <= $#subfields; $i++) {
184 my $code = $subfields[$i]->[0];
185 my $code_re = quotemeta $code;
186 my $value = $subfields[$i]->[1];
187 next unless $subfields =~ qr/$code_re/;
192 if (exists $subdivisions{$code}) {
193 $heading .= " $subdivisions{$code} $value";
195 $heading .= " $value";
200 # remove characters that are part of CCL syntax
201 $heading =~ s/[)(=]//g;
206 =head2 _get_display_heading
210 sub _get_display_heading {
212 my $subfields = shift;
215 my @subfields = $field->subfields();
217 for (my $i = 0; $i <= $#subfields; $i++) {
218 my $code = $subfields[$i]->[0];
219 my $value = $subfields[$i]->[1];
220 next unless $subfields =~ qr/$code/;
225 if (exists $subdivisions{$code}) {
226 $heading .= "--$value";
228 $heading .= " $value";
237 Koha Developement team <info@koha.org>
239 Galen Charlton <galen.charlton@liblime.com>