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
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
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 = {
52 auth_type
=> 'PERSO_NAME',
53 subfields
=> 'abcdfghjklmnopqrst',
57 auth_type
=> 'CORPO_NAME',
58 subfields
=> 'abcdfghklmnoprst',
62 auth_type
=> 'MEETI_NAME',
63 subfields
=> 'acdfghjklnpqst',
67 auth_type
=> 'UNIF_TITLE',
68 subfields
=> 'adfghklmnoprst',
71 '440' => { auth_type
=> 'UNIF_TITLE', subfields
=> 'anp', series
=> 1 },
73 auth_type
=> 'PERSO_NAME',
74 subfields
=> 'abcdfghjklmnopqrstvxyz',
78 auth_type
=> 'CORPO_NAME',
79 subfields
=> 'abcdfghklmnoprstvxyz',
83 auth_type
=> 'MEETI_NAME',
84 subfields
=> 'acdfghjklnpqstvxyz',
88 auth_type
=> 'UNIF_TITLE',
89 subfields
=> 'adfghklmnoprstvxyz',
92 '648' => { auth_type
=> 'CHRON_TERM', subfields
=> 'avxyz', subject
=> 1 },
93 '650' => { auth_type
=> 'TOPIC_TERM', subfields
=> 'abvxyz', subject
=> 1 },
94 '651' => { auth_type
=> 'GEOGR_NAME', subfields
=> 'avxyz', subject
=> 1 },
95 '655' => { auth_type
=> 'GENRE/FORM', subfields
=> 'avxyz', subject
=> 1 },
96 '690' => { auth_type
=> 'TOPIC_TERM', subfields
=> 'abvxyz', subject
=> 1 },
97 '691' => { auth_type
=> 'GEOGR_NAME', subfields
=> 'avxyz', subject
=> 1 },
98 '696' => { auth_type
=> 'PERSO_NAME', subfields
=> 'abcdfghjklmnopqrst' },
99 '697' => { auth_type
=> 'CORPO_NAME', subfields
=> 'abcdfghklmnoprst' },
100 '698' => { auth_type
=> 'MEETI_NAME', subfields
=> 'acdfghjklnpqst' },
101 '699' => { auth_type
=> 'UNIF_TITLE', subfields
=> 'adfghklmnoprst' },
102 '700' => { auth_type
=> 'PERSO_NAME', subfields
=> 'abcdfghjklmnopqrst' },
103 '710' => { auth_type
=> 'CORPO_NAME', subfields
=> 'abcdfghklmnoprst' },
104 '711' => { auth_type
=> 'MEETI_NAME', subfields
=> 'acdfghjklnpqst' },
105 '730' => { auth_type
=> 'UNIF_TITLE', subfields
=> 'adfghklmnoprst' },
107 auth_type
=> 'PERSO_NAME',
108 subfields
=> 'abcdfghjklmnopqrst',
112 auth_type
=> 'CORPO_NAME',
113 subfields
=> 'abcdfghklmnoprst',
117 { auth_type
=> 'MEETI_NAME', subfields
=> 'acdfghjklnpqst', series
=> 1 },
119 { auth_type
=> 'UNIF_TITLE', subfields
=> 'adfghklmnoprst', series
=> 1 },
128 'x' => 'generalsubdiv',
129 'y' => 'chronologicalsubdiv',
130 'z' => 'geographicsubdiv',
137 my $marc_handler = C4::Heading::MARC21->new();
143 return bless {}, $class;
146 =head2 valid_bib_heading_tag
150 sub valid_bib_heading_tag
{
153 my $frameworkcode = shift;
155 if ( exists $bib_heading_fields->{$tag} ) {
164 =head2 valid_bib_heading_subfield
168 sub valid_bib_heading_subfield
{
171 my $subfield = shift;
173 if ( exists $bib_heading_fields->{$tag} ) {
174 return 1 if ($bib_heading_fields->{$tag}->{subfields
} =~ /$subfield/);
187 my $tag = $field->tag;
188 my $field_info = $bib_heading_fields->{$tag};
190 my $auth_type = $field_info->{'auth_type'};
193 ? _get_subject_thesaurus
($field)
194 : "lcsh"; # use 'lcsh' for names, UT, etc.
196 _get_search_heading
( $field, $field_info->{'subfields'} );
197 my $display_heading =
198 _get_display_heading
( $field, $field_info->{'subfields'} );
200 return ( $auth_type, $thesaurus, $search_heading, $display_heading,
204 =head1 INTERNAL FUNCTIONS
206 =head2 _get_subject_thesaurus
210 sub _get_subject_thesaurus
{
212 my $ind2 = $field->indicator(2);
214 my $thesaurus = "notdefined";
215 if ( $ind2 eq '0' ) {
218 elsif ( $ind2 eq '1' ) {
221 elsif ( $ind2 eq '2' ) {
224 elsif ( $ind2 eq '3' ) {
227 elsif ( $ind2 eq '4' ) {
228 $thesaurus = "notspecified";
230 elsif ( $ind2 eq '5' ) {
233 elsif ( $ind2 eq '6' ) {
236 elsif ( $ind2 eq '7' ) {
237 my $sf2 = $field->subfield('2');
238 $thesaurus = $sf2 if defined($sf2);
244 =head2 _get_search_heading
248 sub _get_search_heading
{
250 my $subfields = shift;
253 my @subfields = $field->subfields();
255 for ( my $i = 0 ; $i <= $#subfields ; $i++ ) {
256 my $code = $subfields[$i]->[0];
257 my $code_re = quotemeta $code;
258 my $value = $subfields[$i]->[1];
259 $value =~ s/[-,.:=;!%\/]$//;
260 next unless $subfields =~ qr/$code_re/;
266 if ( exists $subdivisions{$code} ) {
267 $heading .= " $subdivisions{$code} $value";
270 $heading .= " $value";
275 # remove characters that are part of CCL syntax
276 $heading =~ s/[)(=]//g;
281 =head2 _get_display_heading
285 sub _get_display_heading
{
287 my $subfields = shift;
290 my @subfields = $field->subfields();
292 for ( my $i = 0 ; $i <= $#subfields ; $i++ ) {
293 my $code = $subfields[$i]->[0];
294 my $code_re = quotemeta $code;
295 my $value = $subfields[$i]->[1];
296 next unless $subfields =~ qr/$code_re/;
302 if ( exists $subdivisions{$code} ) {
303 $heading .= "--$value";
306 $heading .= " $value";
313 # Additional limiters that we aren't using:
314 # if ($self->{'subject_added_entry'}) {
315 # $limiters .= " AND Heading-use-subject-added-entry=a";
317 # if ($self->{'series_added_entry'}) {
318 # $limiters .= " AND Heading-use-series-added-entry=a";
320 # if (not $self->{'subject_added_entry'} and not $self->{'series_added_entry'}) {
321 # $limiters .= " AND Heading-use-main-or-added-entry=a"
326 Koha Development Team <http://koha-community.org/>
328 Galen Charlton <galen.charlton@liblime.com>