Lines 46-57
BEGIN {
Link Here
|
46 |
&DelAuthority |
46 |
&DelAuthority |
47 |
&GetAuthority |
47 |
&GetAuthority |
48 |
&GetAuthorityXML |
48 |
&GetAuthorityXML |
49 |
|
49 |
|
50 |
&CountUsage |
50 |
&CountUsage |
51 |
&CountUsageChildren |
51 |
&CountUsageChildren |
52 |
&SearchAuthorities |
52 |
&SearchAuthorities |
53 |
|
53 |
|
54 |
&BuildSummary |
54 |
&BuildSummary |
55 |
&BuildUnimarcHierarchies |
55 |
&BuildUnimarcHierarchies |
56 |
&BuildUnimarcHierarchy |
56 |
&BuildUnimarcHierarchy |
57 |
|
57 |
|
Lines 926-934
sub FindDuplicateAuthority {
Link Here
|
926 |
|
926 |
|
927 |
=head2 BuildSummary |
927 |
=head2 BuildSummary |
928 |
|
928 |
|
929 |
$text= &BuildSummary( $record, $authid, $authtypecode) |
929 |
$summary= &BuildSummary( $record, $authid, $authtypecode) |
930 |
|
930 |
|
931 |
return HTML encoded Summary |
931 |
Returns a hashref with a summary of the specified record. |
932 |
|
932 |
|
933 |
Comment : authtypecode can be infered from both record and authid. |
933 |
Comment : authtypecode can be infered from both record and authid. |
934 |
Moreover, authid can also be inferred from $record. |
934 |
Moreover, authid can also be inferred from $record. |
Lines 936-1106
Would it be interesting to delete those things.
Link Here
|
936 |
|
936 |
|
937 |
=cut |
937 |
=cut |
938 |
|
938 |
|
939 |
sub BuildSummary{ |
939 |
sub BuildSummary { |
940 |
## give this a Marc record to return summary |
940 |
## give this a Marc record to return summary |
941 |
my ($record,$authid,$authtypecode)=@_; |
941 |
my ($record,$authid,$authtypecode)=@_; |
942 |
my $dbh=C4::Context->dbh; |
942 |
my $dbh=C4::Context->dbh; |
943 |
my $summary; |
943 |
my %summary; |
944 |
# handle $authtypecode is NULL or eq "" |
944 |
# handle $authtypecode is NULL or eq "" |
945 |
if ($authtypecode) { |
945 |
if ($authtypecode) { |
946 |
my $authref = GetAuthType($authtypecode); |
946 |
my $authref = GetAuthType($authtypecode); |
947 |
$summary = $authref->{summary}; |
947 |
$summary{authtypecode} = $authref->{authtypecode}; |
948 |
} |
948 |
$summary{type} = $authref->{authtypetext}; |
949 |
# FIXME: should use I18N.pm |
949 |
$summary{summary} = $authref->{summary}; |
950 |
my %language; |
|
|
951 |
$language{'fre'}="Français"; |
952 |
$language{'eng'}="Anglais"; |
953 |
$language{'ger'}="Allemand"; |
954 |
$language{'ita'}="Italien"; |
955 |
$language{'spa'}="Espagnol"; |
956 |
my %thesaurus; |
957 |
$thesaurus{'1'}="Peuples"; |
958 |
$thesaurus{'2'}="Anthroponymes"; |
959 |
$thesaurus{'3'}="Oeuvres"; |
960 |
$thesaurus{'4'}="Chronologie"; |
961 |
$thesaurus{'5'}="Lieux"; |
962 |
$thesaurus{'6'}="Sujets"; |
963 |
#thesaurus a remplir |
964 |
my @fields = $record->fields(); |
965 |
my $reported_tag; |
966 |
# if the library has a summary defined, use it. Otherwise, build a standard one |
967 |
# FIXME - it appears that the summary field in the authority frameworks |
968 |
# can work as a display template. However, this doesn't |
969 |
# suit the MARC21 version, so for now the "templating" |
970 |
# feature will be enabled only for UNIMARC for backwards |
971 |
# compatibility. |
972 |
if ($summary and C4::Context->preference('marcflavour') eq 'UNIMARC') { |
973 |
my @fields = $record->fields(); |
974 |
# $reported_tag = '$9'.$result[$counter]; |
975 |
my @stringssummary; |
976 |
foreach my $field (@fields) { |
977 |
my $tag = $field->tag(); |
978 |
my $tagvalue = $field->as_string(); |
979 |
my $localsummary= $summary; |
980 |
$localsummary =~ s/\[(.?.?.?.?)$tag\*(.*?)\]/$1$tagvalue$2\[$1$tag$2\]/g; |
981 |
if ($tag<10) { |
982 |
if ($tag eq '001') { |
983 |
$reported_tag.='$3'.$field->data(); |
984 |
} |
985 |
} else { |
986 |
my @subf = $field->subfields; |
987 |
for my $i (0..$#subf) { |
988 |
my $subfieldcode = $subf[$i][0]; |
989 |
my $subfieldvalue = $subf[$i][1]; |
990 |
my $tagsubf = $tag.$subfieldcode; |
991 |
$localsummary =~ s/\[(.?.?.?.?)$tagsubf(.*?)\]/$1$subfieldvalue$2\[$1$tagsubf$2\]/g; |
992 |
} |
993 |
} |
994 |
push @stringssummary, $localsummary if ($localsummary ne $summary); |
995 |
} |
950 |
} |
996 |
my $resultstring; |
951 |
my $marc21subfields = 'abcdfghjklmnopqrstuvxyz'; |
997 |
$resultstring = join(" -- ",@stringssummary); |
952 |
my %marc21controlrefs = ( 'a' => 'earlier', |
998 |
$resultstring =~ s/\[(.*?)\]//g; |
953 |
'b' => 'later', |
999 |
$resultstring =~ s/\n/<br\/>/g; |
954 |
'd' => 'acronym', |
1000 |
$summary = $resultstring; |
955 |
'f' => 'musical', |
1001 |
} else { |
956 |
'g' => 'broader', |
1002 |
my $heading = ''; |
957 |
'h' => 'narrower', |
1003 |
my $altheading = ''; |
958 |
'i' => 'subfi', |
1004 |
my $seealso = ''; |
959 |
't' => 'parent' |
1005 |
my $broaderterms = ''; |
960 |
); |
1006 |
my $narrowerterms = ''; |
961 |
my %thesaurus; |
1007 |
my $see = ''; |
962 |
$thesaurus{'1'}="Peuples"; |
1008 |
my $seeheading = ''; |
963 |
$thesaurus{'2'}="Anthroponymes"; |
1009 |
my $notes = ''; |
964 |
$thesaurus{'3'}="Oeuvres"; |
|
|
965 |
$thesaurus{'4'}="Chronologie"; |
966 |
$thesaurus{'5'}="Lieux"; |
967 |
$thesaurus{'6'}="Sujets"; |
968 |
#thesaurus a remplir |
1010 |
my @fields = $record->fields(); |
969 |
my @fields = $record->fields(); |
1011 |
if (C4::Context->preference('marcflavour') eq 'UNIMARC') { |
970 |
my $reported_tag; |
1012 |
# construct UNIMARC summary, that is quite different from MARC21 one |
971 |
# if the library has a summary defined, use it. Otherwise, build a standard one |
1013 |
# accepted form |
972 |
# FIXME - it appears that the summary field in the authority frameworks |
1014 |
foreach my $field ($record->field('2..')) { |
973 |
# can work as a display template. However, this doesn't |
1015 |
$heading.= $field->as_string('abcdefghijlmnopqrstuvwxyz'); |
974 |
# suit the MARC21 version, so for now the "templating" |
1016 |
} |
975 |
# feature will be enabled only for UNIMARC for backwards |
1017 |
# rejected form(s) |
976 |
# compatibility. |
1018 |
foreach my $field ($record->field('3..')) { |
977 |
if ($summary{summary} and C4::Context->preference('marcflavour') eq 'UNIMARC') { |
1019 |
$notes.= '<span class="note">'.$field->subfield('a')."</span>\n"; |
978 |
my @fields = $record->fields(); |
1020 |
} |
979 |
# $reported_tag = '$9'.$result[$counter]; |
1021 |
foreach my $field ($record->field('4..')) { |
980 |
my @stringssummary; |
1022 |
if ($field->subfield('2')) { |
981 |
foreach my $field (@fields) { |
1023 |
my $thesaurus = "thes. : ".$thesaurus{"$field->subfield('2')"}." : "; |
982 |
my $tag = $field->tag(); |
1024 |
$see.= '<span class="UF">'.$thesaurus.$field->as_string('abcdefghijlmnopqrstuvwxyz')."</span> -- \n"; |
983 |
my $tagvalue = $field->as_string(); |
|
|
984 |
my $localsummary= $summary{summary}; |
985 |
$localsummary =~ s/\[(.?.?.?.?)$tag\*(.*?)\]/$1$tagvalue$2\[$1$tag$2\]/g; |
986 |
if ($tag<10) { |
987 |
if ($tag eq '001') { |
988 |
$reported_tag.='$3'.$field->data(); |
989 |
} |
990 |
} else { |
991 |
my @subf = $field->subfields; |
992 |
for my $i (0..$#subf) { |
993 |
my $subfieldcode = $subf[$i][0]; |
994 |
my $subfieldvalue = $subf[$i][1]; |
995 |
my $tagsubf = $tag.$subfieldcode; |
996 |
$localsummary =~ s/\[(.?.?.?.?)$tagsubf(.*?)\]/$1$subfieldvalue$2\[$1$tagsubf$2\]/g; |
997 |
} |
998 |
} |
999 |
push @stringssummary, $localsummary if ($localsummary ne $summary{summary}); |
1025 |
} |
1000 |
} |
1026 |
} |
1001 |
my $resultstring; |
1027 |
# see : |
1002 |
$resultstring = join(" -- ",@stringssummary); |
1028 |
foreach my $field ($record->field('5..')) { |
1003 |
$resultstring =~ s/\[(.*?)\]//g; |
1029 |
|
1004 |
$resultstring =~ s/\n/<br>/g; |
1030 |
if (($field->subfield('5')) && ($field->subfield('a')) && ($field->subfield('5') eq 'g')) { |
1005 |
$summary{summary} = $resultstring; |
1031 |
$broaderterms.= '<span class="BT"> '.$field->as_string('abcdefgjxyz')."</span> -- \n"; |
1006 |
} else { |
1032 |
} elsif (($field->subfield('5')) && ($field->as_string) && ($field->subfield('5') eq 'h')){ |
1007 |
my @authorized; |
1033 |
$narrowerterms.= '<span class="NT">'.$field->as_string('abcdefgjxyz')."</span> -- \n"; |
1008 |
my @notes; |
1034 |
} elsif ($field->subfield('a')) { |
1009 |
my @seefrom; |
1035 |
$seealso.= '<span class="RT">'.$field->as_string('abcdefgxyz')."</a></span> -- \n"; |
1010 |
my @seealso; |
|
|
1011 |
my @otherscript; |
1012 |
my @fields = $record->fields(); |
1013 |
if (C4::Context->preference('marcflavour') eq 'UNIMARC') { |
1014 |
# construct UNIMARC summary, that is quite different from MARC21 one |
1015 |
# accepted form |
1016 |
foreach my $field ($record->field('2..')) { |
1017 |
push @authorized, $field->as_string('abcdefghijlmnopqrstuvwxyz'); |
1018 |
} |
1019 |
# rejected form(s) |
1020 |
foreach my $field ($record->field('3..')) { |
1021 |
push @notes, $field->subfield('a'); |
1022 |
} |
1023 |
foreach my $field ($record->field('4..')) { |
1024 |
my $thesaurus = $field->subfield('2') ? "thes. : ".$thesaurus{"$field->subfield('2')"}." : " : ''; |
1025 |
push @seefrom, { heading => $thesaurus . $field->as_string('abcdefghijlmnopqrstuvwxyz'), type => 'seefrom' }; |
1026 |
} |
1027 |
# see : |
1028 |
foreach my $field ($record->field('5..')) { |
1029 |
if (($field->subfield('5')) && ($field->subfield('a')) && ($field->subfield('5') eq 'g')) { |
1030 |
push @seealso, { $field->as_string('abcdefgjxyz'), type => 'broader' }; |
1031 |
} elsif (($field->subfield('5')) && ($field->as_string) && ($field->subfield('5') eq 'h')){ |
1032 |
push @seealso, { heading => $field->as_string('abcdefgjxyz'), type => 'narrower' }; |
1033 |
} elsif ($field->subfield('a')) { |
1034 |
push @seealso, { heading => $field->as_string('abcdefgxyz'), type => 'seealso' }; |
1035 |
} |
1036 |
} |
1037 |
# // form |
1038 |
foreach my $field ($record->field('7..')) { |
1039 |
my $lang = substr($field->subfield('8'),3,3); |
1040 |
push @otherscript, { lang => $lang, term => $field->subfield('a') }; |
1041 |
} |
1042 |
} else { |
1043 |
# construct MARC21 summary |
1044 |
# FIXME - looping over 1XX is questionable |
1045 |
# since MARC21 authority should have only one 1XX |
1046 |
foreach my $field ($record->field('1..')) { |
1047 |
my $tag = $field->tag(); |
1048 |
next if "152" eq $tag; |
1049 |
# FIXME - 152 is not a good tag to use |
1050 |
# in MARC21 -- purely local tags really ought to be |
1051 |
# 9XX |
1052 |
if ($tag eq '100') { |
1053 |
push @authorized, $field->as_string('abcdefghjklmnopqrstvxyz68'); |
1054 |
} elsif ($tag eq '110') { |
1055 |
push @authorized, $field->as_string('abcdefghklmnoprstvxyz68'); |
1056 |
} elsif ($tag eq '111') { |
1057 |
push @authorized, $field->as_string('acdefghklnpqstvxyz68'); |
1058 |
} elsif ($tag eq '130') { |
1059 |
push @authorized, $field->as_string('adfghklmnoprstvxyz68'); |
1060 |
} elsif ($tag eq '148') { |
1061 |
push @authorized, $field->as_string('abvxyz68'); |
1062 |
} elsif ($tag eq '150') { |
1063 |
push @authorized, $field->as_string('abvxyz68'); |
1064 |
} elsif ($tag eq '151') { |
1065 |
push @authorized, $field->as_string('avxyz68'); |
1066 |
} elsif ($tag eq '155') { |
1067 |
push @authorized, $field->as_string('abvxyz68'); |
1068 |
} elsif ($tag eq '180') { |
1069 |
push @authorized, $field->as_string('vxyz68'); |
1070 |
} elsif ($tag eq '181') { |
1071 |
push @authorized, $field->as_string('vxyz68'); |
1072 |
} elsif ($tag eq '182') { |
1073 |
push @authorized, $field->as_string('vxyz68'); |
1074 |
} elsif ($tag eq '185') { |
1075 |
push @authorized, $field->as_string('vxyz68'); |
1076 |
} else { |
1077 |
push @authorized, $field->as_string(); |
1078 |
} |
1079 |
} #See From |
1080 |
foreach my $field ($record->field('4..')) { |
1081 |
my $type = 'seefrom'; |
1082 |
$type = $marc21controlrefs{substr $field->subfield('w'), '0'} if ($field->subfield('w')); |
1083 |
if ($type eq 'subfi') { |
1084 |
push @seefrom, { heading => $field->as_string($marc21subfields), type => $field->subfield('i') }; |
1085 |
} else { |
1086 |
push @seefrom, { heading => $field->as_string($marc21subfields), type => $type }; |
1087 |
} |
1088 |
} #See Also |
1089 |
foreach my $field ($record->field('5..')) { |
1090 |
my $type = 'seealso'; |
1091 |
$type = $marc21controlrefs{substr $field->subfield('w'), '0'} if ($field->subfield('w')); |
1092 |
if ($type eq 'subfi') { |
1093 |
push @seealso, { heading => $field->as_string($marc21subfields), type => $field->subfield('i') }; |
1094 |
} else { |
1095 |
push @seealso, { heading => $field->as_string($marc21subfields), type => $type }; |
1096 |
} |
1097 |
} |
1098 |
foreach my $field ($record->field('6..')) { |
1099 |
push @notes, $field->as_string(); |
1100 |
} |
1036 |
} |
1101 |
} |
1037 |
} |
1102 |
$summary{authorized} = \@authorized; |
1038 |
# // form |
1103 |
$summary{notes} = \@notes; |
1039 |
foreach my $field ($record->field('7..')) { |
1104 |
$summary{seefrom} = \@seefrom; |
1040 |
my $lang = substr($field->subfield('8'),3,3); |
1105 |
$summary{seealso} = \@seealso; |
1041 |
$seeheading.= '<span class="langue"> En '.$language{$lang}.' : </span><span class="OT"> '.$field->subfield('a')."</span><br />\n"; |
1106 |
$summary{otherscript} = \@otherscript; |
1042 |
} |
1107 |
} |
1043 |
$broaderterms =~s/-- \n$//; |
1108 |
return \%summary; |
1044 |
$narrowerterms =~s/-- \n$//; |
|
|
1045 |
$seealso =~s/-- \n$//; |
1046 |
$see =~s/-- \n$//; |
1047 |
$summary = $heading."<br />".($notes?"$notes <br />":""); |
1048 |
$summary.= '<p><div class="label">TG : '.$broaderterms.'</div></p>' if ($broaderterms); |
1049 |
$summary.= '<p><div class="label">TS : '.$narrowerterms.'</div></p>' if ($narrowerterms); |
1050 |
$summary.= '<p><div class="label">TA : '.$seealso.'</div></p>' if ($seealso); |
1051 |
$summary.= '<p><div class="label">EP : '.$see.'</div></p>' if ($see); |
1052 |
$summary.= '<p><div class="label">'.$seeheading.'</div></p>' if ($seeheading); |
1053 |
} else { |
1054 |
# construct MARC21 summary |
1055 |
# FIXME - looping over 1XX is questionable |
1056 |
# since MARC21 authority should have only one 1XX |
1057 |
foreach my $field ($record->field('1..')) { |
1058 |
next if "152" eq $field->tag(); # FIXME - 152 is not a good tag to use |
1059 |
# in MARC21 -- purely local tags really ought to be |
1060 |
# 9XX |
1061 |
if ($record->field('100')) { |
1062 |
$heading.= $field->as_string('abcdefghjklmnopqrstvxyz68'); |
1063 |
} elsif ($record->field('110')) { |
1064 |
$heading.= $field->as_string('abcdefghklmnoprstvxyz68'); |
1065 |
} elsif ($record->field('111')) { |
1066 |
$heading.= $field->as_string('acdefghklnpqstvxyz68'); |
1067 |
} elsif ($record->field('130')) { |
1068 |
$heading.= $field->as_string('adfghklmnoprstvxyz68'); |
1069 |
} elsif ($record->field('148')) { |
1070 |
$heading.= $field->as_string('abvxyz68'); |
1071 |
} elsif ($record->field('150')) { |
1072 |
$heading.= $field->as_string('abvxyz68'); |
1073 |
#$heading.= $field->as_formatted(); |
1074 |
my $tag=$field->tag(); |
1075 |
$heading=~s /^$tag//g; |
1076 |
$heading =~s /\_/\$/g; |
1077 |
} elsif ($record->field('151')) { |
1078 |
$heading.= $field->as_string('avxyz68'); |
1079 |
} elsif ($record->field('155')) { |
1080 |
$heading.= $field->as_string('abvxyz68'); |
1081 |
} elsif ($record->field('180')) { |
1082 |
$heading.= $field->as_string('vxyz68'); |
1083 |
} elsif ($record->field('181')) { |
1084 |
$heading.= $field->as_string('vxyz68'); |
1085 |
} elsif ($record->field('182')) { |
1086 |
$heading.= $field->as_string('vxyz68'); |
1087 |
} elsif ($record->field('185')) { |
1088 |
$heading.= $field->as_string('vxyz68'); |
1089 |
} else { |
1090 |
$heading.= $field->as_string(); |
1091 |
} |
1092 |
} #See From |
1093 |
foreach my $field ($record->field('4..')) { |
1094 |
$seeheading.= "<br /> <i>used for/see from:</i> ".$field->as_string(); |
1095 |
} #See Also |
1096 |
foreach my $field ($record->field('5..')) { |
1097 |
$altheading.= "<br /> <i>see also:</i> ".$field->as_string(); |
1098 |
} |
1099 |
$summary .= ": " if $summary; |
1100 |
$summary.=$heading.$seeheading.$altheading; |
1101 |
} |
1102 |
} |
1103 |
return $summary; |
1104 |
} |
1109 |
} |
1105 |
|
1110 |
|
1106 |
=head2 BuildUnimarcHierarchies |
1111 |
=head2 BuildUnimarcHierarchies |