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
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 our $VERSION = 3.07.00.049;
33 use C4::Heading::MARC21;
37 This is an internal helper class used by
38 C<C4::Heading> to parse headings data from
39 MARC21 records. Object of this type
40 do not carry data, instead, they only
43 =head1 DATA STRUCTURES
45 FIXME - this should be moved to a configuration file.
47 =head2 bib_heading_fields
51 my $bib_heading_fields = {
53 auth_type => 'PERSO_NAME',
54 subfields => 'abcdfghjklmnopqrst',
58 auth_type => 'CORPO_NAME',
59 subfields => 'abcdfghklmnoprst',
63 auth_type => 'MEETI_NAME',
64 subfields => 'acdfghjklnpqst',
68 auth_type => 'UNIF_TITLE',
69 subfields => 'adfghklmnoprst',
72 '440' => { auth_type => 'UNIF_TITLE', subfields => 'anp', series => 1 },
74 auth_type => 'PERSO_NAME',
75 subfields => 'abcdfghjklmnopqrstvxyz',
79 auth_type => 'CORPO_NAME',
80 subfields => 'abcdfghklmnoprstvxyz',
84 auth_type => 'MEETI_NAME',
85 subfields => 'acdfghjklnpqstvxyz',
89 auth_type => 'UNIF_TITLE',
90 subfields => 'adfghklmnoprstvxyz',
93 '648' => { auth_type => 'CHRON_TERM', subfields => 'avxyz', subject => 1 },
94 '650' => { auth_type => 'TOPIC_TERM', subfields => 'abvxyz', subject => 1 },
95 '651' => { auth_type => 'GEOGR_NAME', subfields => 'avxyz', subject => 1 },
96 '655' => { auth_type => 'GENRE/FORM', subfields => 'avxyz', subject => 1 },
97 '700' => { auth_type => 'PERSO_NAME', subfields => 'abcdfghjklmnopqrst' },
98 '710' => { auth_type => 'CORPO_NAME', subfields => 'abcdfghklmnoprst' },
99 '711' => { auth_type => 'MEETI_NAME', subfields => 'acdfghjklnpqst' },
100 '730' => { auth_type => 'UNIF_TITLE', subfields => 'adfghklmnoprst' },
102 auth_type => 'PERSO_NAME',
103 subfields => 'abcdfghjklmnopqrst',
107 auth_type => 'CORPO_NAME',
108 subfields => 'abcdfghklmnoprst',
112 { auth_type => 'MEETI_NAME', subfields => 'acdfghjklnpqst', series => 1 },
114 { auth_type => 'UNIF_TITLE', subfields => 'adfghklmnoprst', series => 1 },
123 'x' => 'generalsubdiv',
124 'y' => 'chronologicalsubdiv',
125 'z' => 'geographicsubdiv',
132 my $marc_handler = C4::Heading::MARC21->new();
138 return bless {}, $class;
141 =head2 valid_bib_heading_tag
145 sub valid_bib_heading_tag {
148 my $frameworkcode = shift;
150 if ( exists $bib_heading_fields->{$tag} ) {
167 my $tag = $field->tag;
168 my $field_info = $bib_heading_fields->{$tag};
170 my $auth_type = $field_info->{'auth_type'};
173 ? _get_subject_thesaurus($field)
174 : "lcsh"; # use 'lcsh' for names, UT, etc.
176 _get_search_heading( $field, $field_info->{'subfields'} );
177 my $display_heading =
178 _get_display_heading( $field, $field_info->{'subfields'} );
180 return ( $auth_type, $thesaurus, $search_heading, $display_heading,
184 =head1 INTERNAL FUNCTIONS
186 =head2 _get_subject_thesaurus
190 sub _get_subject_thesaurus {
192 my $ind2 = $field->indicator(2);
194 my $thesaurus = "notdefined";
195 if ( $ind2 eq '0' ) {
198 elsif ( $ind2 eq '1' ) {
201 elsif ( $ind2 eq '2' ) {
204 elsif ( $ind2 eq '3' ) {
207 elsif ( $ind2 eq '4' ) {
208 $thesaurus = "notspecified";
210 elsif ( $ind2 eq '5' ) {
213 elsif ( $ind2 eq '6' ) {
216 elsif ( $ind2 eq '7' ) {
217 my $sf2 = $field->subfield('2');
218 $thesaurus = $sf2 if defined($sf2);
224 =head2 _get_search_heading
228 sub _get_search_heading {
230 my $subfields = shift;
233 my @subfields = $field->subfields();
235 for ( my $i = 0 ; $i <= $#subfields ; $i++ ) {
236 my $code = $subfields[$i]->[0];
237 my $code_re = quotemeta $code;
238 my $value = $subfields[$i]->[1];
239 $value =~ s/[-,.:=;!%\/]$//;
240 next unless $subfields =~ qr/$code_re/;
246 if ( exists $subdivisions{$code} ) {
247 $heading .= " $subdivisions{$code} $value";
250 $heading .= " $value";
255 # remove characters that are part of CCL syntax
256 $heading =~ s/[)(=]//g;
261 =head2 _get_display_heading
265 sub _get_display_heading {
267 my $subfields = shift;
270 my @subfields = $field->subfields();
272 for ( my $i = 0 ; $i <= $#subfields ; $i++ ) {
273 my $code = $subfields[$i]->[0];
274 my $code_re = quotemeta $code;
275 my $value = $subfields[$i]->[1];
276 next unless $subfields =~ qr/$code_re/;
282 if ( exists $subdivisions{$code} ) {
283 $heading .= "--$value";
286 $heading .= " $value";
293 # Additional limiters that we aren't using:
294 # if ($self->{'subject_added_entry'}) {
295 # $limiters .= " AND Heading-use-subject-added-entry=a";
297 # if ($self->{'series_added_entry'}) {
298 # $limiters .= " AND Heading-use-series-added-entry=a";
300 # if (not $self->{'subject_added_entry'} and not $self->{'series_added_entry'}) {
301 # $limiters .= " AND Heading-use-main-or-added-entry=a"
306 Koha Development Team <http://koha-community.org/>
308 Galen Charlton <galen.charlton@liblime.com>