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>.
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 '690' => { auth_type
=> 'TOPIC_TERM', subfields
=> 'abvxyz', subject
=> 1 },
98 '691' => { auth_type
=> 'GEOGR_NAME', subfields
=> 'avxyz', subject
=> 1 },
99 '696' => { auth_type
=> 'PERSO_NAME', subfields
=> 'abcdfghjklmnopqrst' },
100 '697' => { auth_type
=> 'CORPO_NAME', subfields
=> 'abcdfghklmnoprst' },
101 '698' => { auth_type
=> 'MEETI_NAME', subfields
=> 'acdfghjklnpqst' },
102 '699' => { auth_type
=> 'UNIF_TITLE', subfields
=> 'adfghklmnoprst' },
103 '700' => { auth_type
=> 'PERSO_NAME', subfields
=> 'abcdfghjklmnopqrst' },
104 '710' => { auth_type
=> 'CORPO_NAME', subfields
=> 'abcdfghklmnoprst' },
105 '711' => { auth_type
=> 'MEETI_NAME', subfields
=> 'acdfghjklnpqst' },
106 '730' => { auth_type
=> 'UNIF_TITLE', subfields
=> 'adfghklmnoprst' },
108 auth_type
=> 'PERSO_NAME',
109 subfields
=> 'abcdfghjklmnopqrst',
113 auth_type
=> 'CORPO_NAME',
114 subfields
=> 'abcdfghklmnoprst',
118 { auth_type
=> 'MEETI_NAME', subfields
=> 'acdfghjklnpqst', series
=> 1 },
120 { auth_type
=> 'UNIF_TITLE', subfields
=> 'adfghklmnoprst', series
=> 1 },
129 'x' => 'generalsubdiv',
130 'y' => 'chronologicalsubdiv',
131 'z' => 'geographicsubdiv',
138 my $marc_handler = C4::Heading::MARC21->new();
144 return bless {}, $class;
147 =head2 valid_bib_heading_tag
151 sub valid_bib_heading_tag
{
154 my $frameworkcode = shift;
156 if ( exists $bib_heading_fields->{$tag} ) {
173 my $tag = $field->tag;
174 my $field_info = $bib_heading_fields->{$tag};
176 my $auth_type = $field_info->{'auth_type'};
179 ? _get_subject_thesaurus
($field)
180 : "lcsh"; # use 'lcsh' for names, UT, etc.
182 _get_search_heading
( $field, $field_info->{'subfields'} );
183 my $display_heading =
184 _get_display_heading
( $field, $field_info->{'subfields'} );
186 return ( $auth_type, $thesaurus, $search_heading, $display_heading,
190 =head1 INTERNAL FUNCTIONS
192 =head2 _get_subject_thesaurus
196 sub _get_subject_thesaurus
{
198 my $ind2 = $field->indicator(2);
200 my $thesaurus = "notdefined";
201 if ( $ind2 eq '0' ) {
204 elsif ( $ind2 eq '1' ) {
207 elsif ( $ind2 eq '2' ) {
210 elsif ( $ind2 eq '3' ) {
213 elsif ( $ind2 eq '4' ) {
214 $thesaurus = "notspecified";
216 elsif ( $ind2 eq '5' ) {
219 elsif ( $ind2 eq '6' ) {
222 elsif ( $ind2 eq '7' ) {
223 my $sf2 = $field->subfield('2');
224 $thesaurus = $sf2 if defined($sf2);
230 =head2 _get_search_heading
234 sub _get_search_heading
{
236 my $subfields = shift;
239 my @subfields = $field->subfields();
241 for ( my $i = 0 ; $i <= $#subfields ; $i++ ) {
242 my $code = $subfields[$i]->[0];
243 my $code_re = quotemeta $code;
244 my $value = $subfields[$i]->[1];
245 $value =~ s/[-,.:=;!%\/]$//;
246 next unless $subfields =~ qr/$code_re/;
252 if ( exists $subdivisions{$code} ) {
253 $heading .= " $subdivisions{$code} $value";
256 $heading .= " $value";
261 # remove characters that are part of CCL syntax
262 $heading =~ s/[)(=]//g;
267 =head2 _get_display_heading
271 sub _get_display_heading
{
273 my $subfields = shift;
276 my @subfields = $field->subfields();
278 for ( my $i = 0 ; $i <= $#subfields ; $i++ ) {
279 my $code = $subfields[$i]->[0];
280 my $code_re = quotemeta $code;
281 my $value = $subfields[$i]->[1];
282 next unless $subfields =~ qr/$code_re/;
288 if ( exists $subdivisions{$code} ) {
289 $heading .= "--$value";
292 $heading .= " $value";
299 # Additional limiters that we aren't using:
300 # if ($self->{'subject_added_entry'}) {
301 # $limiters .= " AND Heading-use-subject-added-entry=a";
303 # if ($self->{'series_added_entry'}) {
304 # $limiters .= " AND Heading-use-series-added-entry=a";
306 # if (not $self->{'subject_added_entry'} and not $self->{'series_added_entry'}) {
307 # $limiters .= " AND Heading-use-main-or-added-entry=a"
312 Koha Development Team <http://koha-community.org/>
314 Galen Charlton <galen.charlton@liblime.com>