Lines 1-6
Link Here
|
1 |
package C4::AuthoritiesMarc; |
1 |
package C4::AuthoritiesMarc; |
2 |
|
2 |
|
3 |
# Copyright 2000-2002 Katipo Communications |
3 |
# Copyright 2000-2002 Katipo Communications |
|
|
4 |
# Copyright 2018 The National Library of Finland, University of Helsinki |
4 |
# |
5 |
# |
5 |
# This file is part of Koha. |
6 |
# This file is part of Koha. |
6 |
# |
7 |
# |
Lines 359-368
sub GuessAuthTypeCode {
Link Here
|
359 |
'110'=>{authtypecode=>'CORPO_NAME'}, |
360 |
'110'=>{authtypecode=>'CORPO_NAME'}, |
360 |
'111'=>{authtypecode=>'MEETI_NAME'}, |
361 |
'111'=>{authtypecode=>'MEETI_NAME'}, |
361 |
'130'=>{authtypecode=>'UNIF_TITLE'}, |
362 |
'130'=>{authtypecode=>'UNIF_TITLE'}, |
|
|
363 |
'147'=>{authtypecode=>'NAME_EVENT'}, |
362 |
'148'=>{authtypecode=>'CHRON_TERM'}, |
364 |
'148'=>{authtypecode=>'CHRON_TERM'}, |
363 |
'150'=>{authtypecode=>'TOPIC_TERM'}, |
365 |
'150'=>{authtypecode=>'TOPIC_TERM'}, |
364 |
'151'=>{authtypecode=>'GEOGR_NAME'}, |
366 |
'151'=>{authtypecode=>'GEOGR_NAME'}, |
365 |
'155'=>{authtypecode=>'GENRE/FORM'}, |
367 |
'155'=>{authtypecode=>'GENRE/FORM'}, |
|
|
368 |
'162'=>{authtypecode=>'MED_PERFRM'}, |
366 |
'180'=>{authtypecode=>'GEN_SUBDIV'}, |
369 |
'180'=>{authtypecode=>'GEN_SUBDIV'}, |
367 |
'181'=>{authtypecode=>'GEO_SUBDIV'}, |
370 |
'181'=>{authtypecode=>'GEO_SUBDIV'}, |
368 |
'182'=>{authtypecode=>'CHRON_SUBD'}, |
371 |
'182'=>{authtypecode=>'CHRON_SUBD'}, |
Lines 940-945
sub BuildSummary {
Link Here
|
940 |
# construct MARC21 summary |
943 |
# construct MARC21 summary |
941 |
# FIXME - looping over 1XX is questionable |
944 |
# FIXME - looping over 1XX is questionable |
942 |
# since MARC21 authority should have only one 1XX |
945 |
# since MARC21 authority should have only one 1XX |
|
|
946 |
use C4::Heading::MARC21; |
947 |
my $handler = C4::Heading::MARC21->new(); |
943 |
my $subfields_to_report; |
948 |
my $subfields_to_report; |
944 |
foreach my $field ($record->field('1..')) { |
949 |
foreach my $field ($record->field('1..')) { |
945 |
my $tag = $field->tag(); |
950 |
my $tag = $field->tag(); |
Lines 947-977
sub BuildSummary {
Link Here
|
947 |
# FIXME - 152 is not a good tag to use |
952 |
# FIXME - 152 is not a good tag to use |
948 |
# in MARC21 -- purely local tags really ought to be |
953 |
# in MARC21 -- purely local tags really ought to be |
949 |
# 9XX |
954 |
# 9XX |
950 |
if ($tag eq '100') { |
955 |
|
951 |
$subfields_to_report = 'abcdefghjklmnopqrstvxyz'; |
956 |
$subfields_to_report = $handler->get_auth_heading_subfields_to_report($tag); |
952 |
} elsif ($tag eq '110') { |
957 |
|
953 |
$subfields_to_report = 'abcdefghklmnoprstvxyz'; |
|
|
954 |
} elsif ($tag eq '111') { |
955 |
$subfields_to_report = 'acdefghklnpqstvxyz'; |
956 |
} elsif ($tag eq '130') { |
957 |
$subfields_to_report = 'adfghklmnoprstvxyz'; |
958 |
} elsif ($tag eq '148') { |
959 |
$subfields_to_report = 'abvxyz'; |
960 |
} elsif ($tag eq '150') { |
961 |
$subfields_to_report = 'abvxyz'; |
962 |
} elsif ($tag eq '151') { |
963 |
$subfields_to_report = 'avxyz'; |
964 |
} elsif ($tag eq '155') { |
965 |
$subfields_to_report = 'abvxyz'; |
966 |
} elsif ($tag eq '180') { |
967 |
$subfields_to_report = 'vxyz'; |
968 |
} elsif ($tag eq '181') { |
969 |
$subfields_to_report = 'vxyz'; |
970 |
} elsif ($tag eq '182') { |
971 |
$subfields_to_report = 'vxyz'; |
972 |
} elsif ($tag eq '185') { |
973 |
$subfields_to_report = 'vxyz'; |
974 |
} |
975 |
if ($subfields_to_report) { |
958 |
if ($subfields_to_report) { |
976 |
push @authorized, { |
959 |
push @authorized, { |
977 |
heading => $field->as_string($subfields_to_report), |
960 |
heading => $field->as_string($subfields_to_report), |
Lines 1095-1138
sub GetAuthorizedHeading {
Link Here
|
1095 |
return $field->as_string('abcdefghijlmnopqrstuvwxyz'); |
1078 |
return $field->as_string('abcdefghijlmnopqrstuvwxyz'); |
1096 |
} |
1079 |
} |
1097 |
} else { |
1080 |
} else { |
|
|
1081 |
use C4::Heading::MARC21; |
1082 |
my $handler = C4::Heading::MARC21->new(); |
1083 |
|
1098 |
foreach my $field ($record->field('1..')) { |
1084 |
foreach my $field ($record->field('1..')) { |
1099 |
my $tag = $field->tag(); |
1085 |
my $subfields = $handler->get_valid_bib_heading_subfields($field->tag()); |
1100 |
next if "152" eq $tag; |
1086 |
return $field->as_string($subfields) if ($subfields); |
1101 |
# FIXME - 152 is not a good tag to use |
|
|
1102 |
# in MARC21 -- purely local tags really ought to be |
1103 |
# 9XX |
1104 |
if ($tag eq '100') { |
1105 |
return $field->as_string('abcdefghjklmnopqrstvxyz68'); |
1106 |
} elsif ($tag eq '110') { |
1107 |
return $field->as_string('abcdefghklmnoprstvxyz68'); |
1108 |
} elsif ($tag eq '111') { |
1109 |
return $field->as_string('acdefghklnpqstvxyz68'); |
1110 |
} elsif ($tag eq '130') { |
1111 |
return $field->as_string('adfghklmnoprstvxyz68'); |
1112 |
} elsif ($tag eq '148') { |
1113 |
return $field->as_string('abvxyz68'); |
1114 |
} elsif ($tag eq '150') { |
1115 |
return $field->as_string('abvxyz68'); |
1116 |
} elsif ($tag eq '151') { |
1117 |
return $field->as_string('avxyz68'); |
1118 |
} elsif ($tag eq '155') { |
1119 |
return $field->as_string('abvxyz68'); |
1120 |
} elsif ($tag eq '180') { |
1121 |
return $field->as_string('vxyz68'); |
1122 |
} elsif ($tag eq '181') { |
1123 |
return $field->as_string('vxyz68'); |
1124 |
} elsif ($tag eq '182') { |
1125 |
return $field->as_string('vxyz68'); |
1126 |
} elsif ($tag eq '185') { |
1127 |
return $field->as_string('vxyz68'); |
1128 |
} else { |
1129 |
return $field->as_string(); |
1130 |
} |
1131 |
} |
1087 |
} |
1132 |
} |
1088 |
} |
1133 |
return; |
1089 |
return; |
1134 |
} |
1090 |
} |
1135 |
|
1091 |
|
|
|
1092 |
=head2 CompareFieldWithAuthority |
1093 |
|
1094 |
$match = &CompareFieldWithAuthority({ field => $field, authid => $authid }) |
1095 |
|
1096 |
Takes a MARC::Field from a bibliographic record and an authid, and returns true if they match. |
1097 |
|
1098 |
=cut |
1099 |
|
1100 |
sub CompareFieldWithAuthority { |
1101 |
my $args = shift; |
1102 |
|
1103 |
my $record = GetAuthority($args->{authid}); |
1104 |
return unless (ref $record eq 'MARC::Record'); |
1105 |
if (C4::Context->preference('marcflavour') eq 'UNIMARC') { |
1106 |
# UNIMARC has same subfields for bibs and authorities |
1107 |
foreach my $field ($record->field('2..')) { |
1108 |
return compare_fields($field, $args->{field}, 'abcdefghijlmnopqrstuvwxyz'); |
1109 |
} |
1110 |
} else { |
1111 |
use C4::Heading::MARC21; |
1112 |
my $handler = C4::Heading::MARC21->new(); |
1113 |
|
1114 |
foreach my $field ($record->field('1..')) { |
1115 |
my $subfields = $handler->get_valid_bib_heading_subfields($field->tag()); |
1116 |
return compare_fields($field, $args->{field}, $subfields) if ($subfields); |
1117 |
} |
1118 |
} |
1119 |
return 0; |
1120 |
} |
1121 |
|
1136 |
=head2 BuildAuthHierarchies |
1122 |
=head2 BuildAuthHierarchies |
1137 |
|
1123 |
|
1138 |
$text= &BuildAuthHierarchies( $authid, $force) |
1124 |
$text= &BuildAuthHierarchies( $authid, $force) |
Lines 1594-1599
sub get_auth_type_location {
Link Here
|
1594 |
} |
1580 |
} |
1595 |
} |
1581 |
} |
1596 |
|
1582 |
|
|
|
1583 |
=head2 compare_fields |
1584 |
|
1585 |
my match = compare_fields($field1, $field2, 'abcde'); |
1586 |
|
1587 |
Compares the listed subfields of both fields and return true if they all match |
1588 |
|
1589 |
=cut |
1590 |
|
1591 |
sub compare_fields { |
1592 |
my ($field1, $field2, $subfields) = @_; |
1593 |
|
1594 |
foreach my $subfield (split(//, $subfields)) { |
1595 |
my $subfield1 = $field1->subfield($subfield) // ''; |
1596 |
my $subfield2 = $field2->subfield($subfield) // ''; |
1597 |
return 0 unless $subfield1 eq $subfield2; |
1598 |
} |
1599 |
return 1; |
1600 |
} |
1601 |
|
1602 |
|
1597 |
END { } # module clean-up code here (global destructor) |
1603 |
END { } # module clean-up code here (global destructor) |
1598 |
|
1604 |
|
1599 |
1; |
1605 |
1; |
Lines 1604-1609
__END__
Link Here
|
1604 |
Koha Development Team <http://koha-community.org/> |
1610 |
Koha Development Team <http://koha-community.org/> |
1605 |
|
1611 |
|
1606 |
Paul POULAIN paul.poulain@free.fr |
1612 |
Paul POULAIN paul.poulain@free.fr |
|
|
1613 |
Ere Maijala ere.maijala@helsinki.fi |
1607 |
|
1614 |
|
1608 |
=cut |
1615 |
=cut |
1609 |
|
1616 |
|