|
Lines 1008-1147
sub BuildSummary {
Link Here
|
| 1008 |
$resultstring =~ s/\[(.*?)\]//g; |
1008 |
$resultstring =~ s/\[(.*?)\]//g; |
| 1009 |
$resultstring =~ s/\n/<br>/g; |
1009 |
$resultstring =~ s/\n/<br>/g; |
| 1010 |
$summary{summary} = $resultstring; |
1010 |
$summary{summary} = $resultstring; |
| 1011 |
} else { |
1011 |
} |
| 1012 |
my @authorized; |
1012 |
my @authorized; |
| 1013 |
my @notes; |
1013 |
my @notes; |
| 1014 |
my @seefrom; |
1014 |
my @seefrom; |
| 1015 |
my @seealso; |
1015 |
my @seealso; |
| 1016 |
my @otherscript; |
1016 |
my @otherscript; |
| 1017 |
my @fields = $record->fields(); |
1017 |
my @fields = $record->fields(); |
| 1018 |
if (C4::Context->preference('marcflavour') eq 'UNIMARC') { |
1018 |
if (C4::Context->preference('marcflavour') eq 'UNIMARC') { |
| 1019 |
# construct UNIMARC summary, that is quite different from MARC21 one |
1019 |
# construct UNIMARC summary, that is quite different from MARC21 one |
| 1020 |
# accepted form |
1020 |
# accepted form |
| 1021 |
foreach my $field ($record->field('2..')) { |
1021 |
foreach my $field ($record->field('2..')) { |
| 1022 |
push @authorized, { heading => $field->as_string('abcdefghijlmnopqrstuvwxyz'), field => $field->tag() }; |
1022 |
push @authorized, { heading => $field->as_string('abcdefghijlmnopqrstuvwxyz'), field => $field->tag() }; |
| 1023 |
} |
1023 |
} |
| 1024 |
# rejected form(s) |
1024 |
# rejected form(s) |
| 1025 |
foreach my $field ($record->field('3..')) { |
1025 |
foreach my $field ($record->field('3..')) { |
| 1026 |
push @notes, { note => $field->subfield('a'), field => $field->tag() }; |
1026 |
push @notes, { note => $field->subfield('a'), field => $field->tag() }; |
| 1027 |
} |
1027 |
} |
| 1028 |
foreach my $field ($record->field('4..')) { |
1028 |
foreach my $field ($record->field('4..')) { |
| 1029 |
my $thesaurus = $field->subfield('2') ? "thes. : ".$thesaurus{"$field->subfield('2')"}." : " : ''; |
1029 |
my $thesaurus = $field->subfield('2') ? "thes. : ".$thesaurus{"$field->subfield('2')"}." : " : ''; |
| 1030 |
push @seefrom, { heading => $thesaurus . $field->as_string('abcdefghijlmnopqrstuvwxyz'), type => 'seefrom', field => $field->tag() }; |
1030 |
push @seefrom, { heading => $thesaurus . $field->as_string('abcdefghijlmnopqrstuvwxyz'), type => 'seefrom', field => $field->tag() }; |
| 1031 |
} |
1031 |
} |
| 1032 |
# see : |
1032 |
# see : |
| 1033 |
foreach my $field ($record->field('5..')) { |
1033 |
foreach my $field ($record->field('5..')) { |
| 1034 |
if (($field->subfield('5')) && ($field->subfield('a')) && ($field->subfield('5') eq 'g')) { |
1034 |
if (($field->subfield('5')) && ($field->subfield('a')) && ($field->subfield('5') eq 'g')) { |
| 1035 |
push @seealso, { $field->as_string('abcdefgjxyz'), type => 'broader', field => $field->tag() }; |
1035 |
push @seealso, { $field->as_string('abcdefgjxyz'), type => 'broader', field => $field->tag() }; |
| 1036 |
} elsif (($field->subfield('5')) && ($field->as_string) && ($field->subfield('5') eq 'h')){ |
1036 |
} elsif (($field->subfield('5')) && ($field->as_string) && ($field->subfield('5') eq 'h')){ |
| 1037 |
push @seealso, { heading => $field->as_string('abcdefgjxyz'), type => 'narrower', field => $field->tag() }; |
1037 |
push @seealso, { heading => $field->as_string('abcdefgjxyz'), type => 'narrower', field => $field->tag() }; |
| 1038 |
} elsif ($field->subfield('a')) { |
1038 |
} elsif ($field->subfield('a')) { |
| 1039 |
push @seealso, { heading => $field->as_string('abcdefgxyz'), type => 'seealso', field => $field->tag() }; |
1039 |
push @seealso, { heading => $field->as_string('abcdefgxyz'), type => 'seealso', field => $field->tag() }; |
| 1040 |
} |
|
|
| 1041 |
} |
1040 |
} |
|
|
1041 |
} |
| 1042 |
# // form |
1042 |
# // form |
| 1043 |
foreach my $field ($record->field('7..')) { |
1043 |
foreach my $field ($record->field('7..')) { |
| 1044 |
my $lang = substr($field->subfield('8'),3,3); |
1044 |
my $lang = substr($field->subfield('8'),3,3); |
| 1045 |
push @otherscript, { lang => $lang, term => $field->subfield('a'), direction => 'ltr', field => $field->tag() }; |
1045 |
push @otherscript, { lang => $lang, term => $field->subfield('a'), direction => 'ltr', field => $field->tag() }; |
| 1046 |
} |
1046 |
} |
| 1047 |
} else { |
1047 |
} else { |
| 1048 |
# construct MARC21 summary |
1048 |
# construct MARC21 summary |
| 1049 |
# FIXME - looping over 1XX is questionable |
1049 |
# FIXME - looping over 1XX is questionable |
| 1050 |
# since MARC21 authority should have only one 1XX |
1050 |
# since MARC21 authority should have only one 1XX |
| 1051 |
my $subfields_to_report; |
1051 |
my $subfields_to_report; |
| 1052 |
foreach my $field ($record->field('1..')) { |
1052 |
foreach my $field ($record->field('1..')) { |
| 1053 |
my $tag = $field->tag(); |
1053 |
my $tag = $field->tag(); |
| 1054 |
next if "152" eq $tag; |
1054 |
next if "152" eq $tag; |
| 1055 |
# FIXME - 152 is not a good tag to use |
1055 |
# FIXME - 152 is not a good tag to use |
| 1056 |
# in MARC21 -- purely local tags really ought to be |
1056 |
# in MARC21 -- purely local tags really ought to be |
| 1057 |
# 9XX |
1057 |
# 9XX |
| 1058 |
if ($tag eq '100') { |
1058 |
if ($tag eq '100') { |
| 1059 |
$subfields_to_report = 'abcdefghjklmnopqrstvxyz'; |
1059 |
$subfields_to_report = 'abcdefghjklmnopqrstvxyz'; |
| 1060 |
} elsif ($tag eq '110') { |
1060 |
} elsif ($tag eq '110') { |
| 1061 |
$subfields_to_report = 'abcdefghklmnoprstvxyz'; |
1061 |
$subfields_to_report = 'abcdefghklmnoprstvxyz'; |
| 1062 |
} elsif ($tag eq '111') { |
1062 |
} elsif ($tag eq '111') { |
| 1063 |
$subfields_to_report = 'acdefghklnpqstvxyz'; |
1063 |
$subfields_to_report = 'acdefghklnpqstvxyz'; |
| 1064 |
} elsif ($tag eq '130') { |
1064 |
} elsif ($tag eq '130') { |
| 1065 |
$subfields_to_report = 'adfghklmnoprstvxyz'; |
1065 |
$subfields_to_report = 'adfghklmnoprstvxyz'; |
| 1066 |
} elsif ($tag eq '148') { |
1066 |
} elsif ($tag eq '148') { |
| 1067 |
$subfields_to_report = 'abvxyz'; |
1067 |
$subfields_to_report = 'abvxyz'; |
| 1068 |
} elsif ($tag eq '150') { |
1068 |
} elsif ($tag eq '150') { |
| 1069 |
$subfields_to_report = 'abvxyz'; |
1069 |
$subfields_to_report = 'abvxyz'; |
| 1070 |
} elsif ($tag eq '151') { |
1070 |
} elsif ($tag eq '151') { |
| 1071 |
$subfields_to_report = 'avxyz'; |
1071 |
$subfields_to_report = 'avxyz'; |
| 1072 |
} elsif ($tag eq '155') { |
1072 |
} elsif ($tag eq '155') { |
| 1073 |
$subfields_to_report = 'abvxyz'; |
1073 |
$subfields_to_report = 'abvxyz'; |
| 1074 |
} elsif ($tag eq '180') { |
1074 |
} elsif ($tag eq '180') { |
| 1075 |
$subfields_to_report = 'vxyz'; |
1075 |
$subfields_to_report = 'vxyz'; |
| 1076 |
} elsif ($tag eq '181') { |
1076 |
} elsif ($tag eq '181') { |
| 1077 |
$subfields_to_report = 'vxyz'; |
1077 |
$subfields_to_report = 'vxyz'; |
| 1078 |
} elsif ($tag eq '182') { |
1078 |
} elsif ($tag eq '182') { |
| 1079 |
$subfields_to_report = 'vxyz'; |
1079 |
$subfields_to_report = 'vxyz'; |
| 1080 |
} elsif ($tag eq '185') { |
1080 |
} elsif ($tag eq '185') { |
| 1081 |
$subfields_to_report = 'vxyz'; |
1081 |
$subfields_to_report = 'vxyz'; |
| 1082 |
} |
|
|
| 1083 |
if ($subfields_to_report) { |
| 1084 |
push @authorized, { heading => $field->as_string($subfields_to_report), field => $tag }; |
| 1085 |
} else { |
| 1086 |
push @authorized, { heading => $field->as_string(), field => $tag }; |
| 1087 |
} |
| 1088 |
} |
1082 |
} |
| 1089 |
foreach my $field ($record->field('4..')) { #See From |
1083 |
if ($subfields_to_report) { |
| 1090 |
my $type = 'seefrom'; |
1084 |
push @authorized, { heading => $field->as_string($subfields_to_report), field => $tag }; |
| 1091 |
$type = $marc21controlrefs{substr $field->subfield('w'), 0, 1} if ($field->subfield('w')); |
1085 |
} else { |
| 1092 |
if ($type eq 'notapplicable') { |
1086 |
push @authorized, { heading => $field->as_string(), field => $tag }; |
| 1093 |
$type = substr $field->subfield('w'), 2, 1; |
|
|
| 1094 |
$type = 'earlier' if $type && $type ne 'n'; |
| 1095 |
} |
| 1096 |
if ($type eq 'subfi') { |
| 1097 |
push @seefrom, { heading => $field->as_string($marc21subfields), type => $field->subfield('i'), field => $field->tag() }; |
| 1098 |
} else { |
| 1099 |
push @seefrom, { heading => $field->as_string($marc21subfields), type => $type, field => $field->tag() }; |
| 1100 |
} |
| 1101 |
} |
1087 |
} |
| 1102 |
foreach my $field ($record->field('5..')) { #See Also |
1088 |
} |
| 1103 |
my $type = 'seealso'; |
1089 |
foreach my $field ($record->field('4..')) { #See From |
| 1104 |
$type = $marc21controlrefs{substr $field->subfield('w'), 0, 1} if ($field->subfield('w')); |
1090 |
my $type = 'seefrom'; |
| 1105 |
if ($type eq 'notapplicable') { |
1091 |
$type = $marc21controlrefs{substr $field->subfield('w'), 0, 1} if ($field->subfield('w')); |
| 1106 |
$type = substr $field->subfield('w'), 2, 1; |
1092 |
if ($type eq 'notapplicable') { |
| 1107 |
$type = 'earlier' if $type && $type ne 'n'; |
1093 |
$type = substr $field->subfield('w'), 2, 1; |
| 1108 |
} |
1094 |
$type = 'earlier' if $type && $type ne 'n'; |
| 1109 |
if ($type eq 'subfi') { |
|
|
| 1110 |
push @seealso, { heading => $field->as_string($marc21subfields), type => $field->subfield('i'), field => $field->tag() }; |
| 1111 |
} else { |
| 1112 |
push @seealso, { heading => $field->as_string($marc21subfields), type => $type, field => $field->tag() }; |
| 1113 |
} |
| 1114 |
} |
1095 |
} |
| 1115 |
foreach my $field ($record->field('6..')) { |
1096 |
if ($type eq 'subfi') { |
| 1116 |
push @notes, { note => $field->as_string(), field => $field->tag() }; |
1097 |
push @seefrom, { heading => $field->as_string($marc21subfields), type => $field->subfield('i'), field => $field->tag() }; |
|
|
1098 |
} else { |
| 1099 |
push @seefrom, { heading => $field->as_string($marc21subfields), type => $type, field => $field->tag() }; |
| 1117 |
} |
1100 |
} |
| 1118 |
foreach my $field ($record->field('880')) { |
1101 |
} |
| 1119 |
my $linkage = $field->subfield('6'); |
1102 |
foreach my $field ($record->field('5..')) { #See Also |
| 1120 |
my $category = substr $linkage, 0, 1; |
1103 |
my $type = 'seealso'; |
| 1121 |
if ($category eq '1') { |
1104 |
$type = $marc21controlrefs{substr $field->subfield('w'), 0, 1} if ($field->subfield('w')); |
| 1122 |
$category = 'preferred'; |
1105 |
if ($type eq 'notapplicable') { |
| 1123 |
} elsif ($category eq '4') { |
1106 |
$type = substr $field->subfield('w'), 2, 1; |
| 1124 |
$category = 'seefrom'; |
1107 |
$type = 'earlier' if $type && $type ne 'n'; |
| 1125 |
} elsif ($category eq '5') { |
1108 |
} |
| 1126 |
$category = 'seealso'; |
1109 |
if ($type eq 'subfi') { |
| 1127 |
} |
1110 |
push @seealso, { heading => $field->as_string($marc21subfields), type => $field->subfield('i'), field => $field->tag() }; |
| 1128 |
my $type; |
1111 |
} else { |
| 1129 |
if ($field->subfield('w')) { |
1112 |
push @seealso, { heading => $field->as_string($marc21subfields), type => $type, field => $field->tag() }; |
| 1130 |
$type = $marc21controlrefs{substr $field->subfield('w'), '0'}; |
1113 |
} |
| 1131 |
} else { |
1114 |
} |
| 1132 |
$type = $category; |
1115 |
foreach my $field ($record->field('6..')) { |
| 1133 |
} |
1116 |
push @notes, { note => $field->as_string(), field => $field->tag() }; |
| 1134 |
my $direction = $linkage =~ m#/r$# ? 'rtl' : 'ltr'; |
1117 |
} |
| 1135 |
push @otherscript, { term => $field->as_string($subfields_to_report), category => $category, type => $type, direction => $direction, linkage => $linkage }; |
1118 |
foreach my $field ($record->field('880')) { |
|
|
1119 |
my $linkage = $field->subfield('6'); |
| 1120 |
my $category = substr $linkage, 0, 1; |
| 1121 |
if ($category eq '1') { |
| 1122 |
$category = 'preferred'; |
| 1123 |
} elsif ($category eq '4') { |
| 1124 |
$category = 'seefrom'; |
| 1125 |
} elsif ($category eq '5') { |
| 1126 |
$category = 'seealso'; |
| 1127 |
} |
| 1128 |
my $type; |
| 1129 |
if ($field->subfield('w')) { |
| 1130 |
$type = $marc21controlrefs{substr $field->subfield('w'), '0'}; |
| 1131 |
} else { |
| 1132 |
$type = $category; |
| 1136 |
} |
1133 |
} |
|
|
1134 |
my $direction = $linkage =~ m#/r$# ? 'rtl' : 'ltr'; |
| 1135 |
push @otherscript, { term => $field->as_string($subfields_to_report), category => $category, type => $type, direction => $direction, linkage => $linkage }; |
| 1137 |
} |
1136 |
} |
| 1138 |
$summary{mainentry} = $authorized[0]->{heading}; |
|
|
| 1139 |
$summary{authorized} = \@authorized; |
| 1140 |
$summary{notes} = \@notes; |
| 1141 |
$summary{seefrom} = \@seefrom; |
| 1142 |
$summary{seealso} = \@seealso; |
| 1143 |
$summary{otherscript} = \@otherscript; |
| 1144 |
} |
1137 |
} |
|
|
1138 |
$summary{mainentry} = $authorized[0]->{heading}; |
| 1139 |
$summary{authorized} = \@authorized; |
| 1140 |
$summary{notes} = \@notes; |
| 1141 |
$summary{seefrom} = \@seefrom; |
| 1142 |
$summary{seealso} = \@seealso; |
| 1143 |
$summary{otherscript} = \@otherscript; |
| 1145 |
return \%summary; |
1144 |
return \%summary; |
| 1146 |
} |
1145 |
} |
| 1147 |
|
1146 |
|
| 1148 |
- |
|
|