diff --git a/C4/Auth.pm b/C4/Auth.pm
index c97046a1ec..66e70bd447 100644
--- a/C4/Auth.pm
+++ b/C4/Auth.pm
@@ -315,7 +315,7 @@ sub get_template_and_user {
"BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1,
EnhancedMessagingPreferences => C4::Context->preference('EnhancedMessagingPreferences'),
GoogleJackets => C4::Context->preference("GoogleJackets"),
- OpenLibraryCovers => C4::Context->preference("OpenLibraryCovers"),
+ OpenLibraryCovers => C4::Context->preference("OpenLibraryCovers"),
KohaAdminEmailAddress => "" . C4::Context->preference("KohaAdminEmailAddress"),
LoginBranchcode => (C4::Context->userenv?C4::Context->userenv->{"branch"}:"insecure"),
LoginFirstname => (C4::Context->userenv?C4::Context->userenv->{"firstname"}:"Bel"),
@@ -328,7 +328,8 @@ sub get_template_and_user {
XSLTDetailsDisplay => C4::Context->preference("XSLTDetailsDisplay"),
XSLTResultsDisplay => C4::Context->preference("XSLTResultsDisplay"),
using_https => $in->{'query'}->https() ? 1 : 0,
- noItemTypeImages => C4::Context->preference("noItemTypeImages"),
+ noItemTypeImages => C4::Context->preference("noItemTypeImages"),
+ marcflavour => C4::Context->preference("marcflavour"),
);
if ( $in->{'type'} eq "intranet" ) {
diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm
index 5ea509802a..c92c319f90 100644
--- a/C4/AuthoritiesMarc.pm
+++ b/C4/AuthoritiesMarc.pm
@@ -46,12 +46,12 @@ BEGIN {
&DelAuthority
&GetAuthority
&GetAuthorityXML
-
+
&CountUsage
&CountUsageChildren
&SearchAuthorities
- &BuildSummary
+ &BuildSummary
&BuildUnimarcHierarchies
&BuildUnimarcHierarchy
@@ -926,9 +926,9 @@ sub FindDuplicateAuthority {
=head2 BuildSummary
- $text= &BuildSummary( $record, $authid, $authtypecode)
+ $summary= &BuildSummary( $record, $authid, $authtypecode)
-return HTML encoded Summary
+Returns a hashref with a summary of the specified record.
Comment : authtypecode can be infered from both record and authid.
Moreover, authid can also be inferred from $record.
@@ -936,171 +936,176 @@ Would it be interesting to delete those things.
=cut
-sub BuildSummary{
-## give this a Marc record to return summary
- my ($record,$authid,$authtypecode)=@_;
- my $dbh=C4::Context->dbh;
- my $summary;
- # handle $authtypecode is NULL or eq ""
- if ($authtypecode) {
- my $authref = GetAuthType($authtypecode);
- $summary = $authref->{summary};
- }
- # FIXME: should use I18N.pm
- my %language;
- $language{'fre'}="Français";
- $language{'eng'}="Anglais";
- $language{'ger'}="Allemand";
- $language{'ita'}="Italien";
- $language{'spa'}="Espagnol";
- my %thesaurus;
- $thesaurus{'1'}="Peuples";
- $thesaurus{'2'}="Anthroponymes";
- $thesaurus{'3'}="Oeuvres";
- $thesaurus{'4'}="Chronologie";
- $thesaurus{'5'}="Lieux";
- $thesaurus{'6'}="Sujets";
- #thesaurus a remplir
- my @fields = $record->fields();
- my $reported_tag;
- # if the library has a summary defined, use it. Otherwise, build a standard one
- # FIXME - it appears that the summary field in the authority frameworks
- # can work as a display template. However, this doesn't
- # suit the MARC21 version, so for now the "templating"
- # feature will be enabled only for UNIMARC for backwards
- # compatibility.
- if ($summary and C4::Context->preference('marcflavour') eq 'UNIMARC') {
- my @fields = $record->fields();
- # $reported_tag = '$9'.$result[$counter];
- my @stringssummary;
- foreach my $field (@fields) {
- my $tag = $field->tag();
- my $tagvalue = $field->as_string();
- my $localsummary= $summary;
- $localsummary =~ s/\[(.?.?.?.?)$tag\*(.*?)\]/$1$tagvalue$2\[$1$tag$2\]/g;
- if ($tag<10) {
- if ($tag eq '001') {
- $reported_tag.='$3'.$field->data();
- }
- } else {
- my @subf = $field->subfields;
- for my $i (0..$#subf) {
- my $subfieldcode = $subf[$i][0];
- my $subfieldvalue = $subf[$i][1];
- my $tagsubf = $tag.$subfieldcode;
- $localsummary =~ s/\[(.?.?.?.?)$tagsubf(.*?)\]/$1$subfieldvalue$2\[$1$tagsubf$2\]/g;
- }
- }
- push @stringssummary, $localsummary if ($localsummary ne $summary);
+sub BuildSummary {
+ ## give this a Marc record to return summary
+ my ($record,$authid,$authtypecode)=@_;
+ my $dbh=C4::Context->dbh;
+ my %summary;
+ # handle $authtypecode is NULL or eq ""
+ if ($authtypecode) {
+ my $authref = GetAuthType($authtypecode);
+ $summary{authtypecode} = $authref->{authtypecode};
+ $summary{type} = $authref->{authtypetext};
+ $summary{summary} = $authref->{summary};
}
- my $resultstring;
- $resultstring = join(" -- ",@stringssummary);
- $resultstring =~ s/\[(.*?)\]//g;
- $resultstring =~ s/\n/
/g;
- $summary = $resultstring;
- } else {
- my $heading = '';
- my $altheading = '';
- my $seealso = '';
- my $broaderterms = '';
- my $narrowerterms = '';
- my $see = '';
- my $seeheading = '';
- my $notes = '';
+ my $marc21subfields = 'abcdfghjklmnopqrstuvxyz';
+ my %marc21controlrefs = ( 'a' => 'earlier',
+ 'b' => 'later',
+ 'd' => 'acronym',
+ 'f' => 'musical',
+ 'g' => 'broader',
+ 'h' => 'narrower',
+ 'i' => 'subfi',
+ 't' => 'parent'
+ );
+ my %thesaurus;
+ $thesaurus{'1'}="Peuples";
+ $thesaurus{'2'}="Anthroponymes";
+ $thesaurus{'3'}="Oeuvres";
+ $thesaurus{'4'}="Chronologie";
+ $thesaurus{'5'}="Lieux";
+ $thesaurus{'6'}="Sujets";
+ #thesaurus a remplir
my @fields = $record->fields();
- if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
- # construct UNIMARC summary, that is quite different from MARC21 one
- # accepted form
- foreach my $field ($record->field('2..')) {
- $heading.= $field->as_string('abcdefghijlmnopqrstuvwxyz');
- }
- # rejected form(s)
- foreach my $field ($record->field('3..')) {
- $notes.= ''.$field->subfield('a')."\n";
- }
- foreach my $field ($record->field('4..')) {
- if ($field->subfield('2')) {
- my $thesaurus = "thes. : ".$thesaurus{"$field->subfield('2')"}." : ";
- $see.= ''.$thesaurus.$field->as_string('abcdefghijlmnopqrstuvwxyz')." -- \n";
+ my $reported_tag;
+# if the library has a summary defined, use it. Otherwise, build a standard one
+# FIXME - it appears that the summary field in the authority frameworks
+# can work as a display template. However, this doesn't
+# suit the MARC21 version, so for now the "templating"
+# feature will be enabled only for UNIMARC for backwards
+# compatibility.
+ if ($summary{summary} and C4::Context->preference('marcflavour') eq 'UNIMARC') {
+ my @fields = $record->fields();
+# $reported_tag = '$9'.$result[$counter];
+ my @stringssummary;
+ foreach my $field (@fields) {
+ my $tag = $field->tag();
+ my $tagvalue = $field->as_string();
+ my $localsummary= $summary{summary};
+ $localsummary =~ s/\[(.?.?.?.?)$tag\*(.*?)\]/$1$tagvalue$2\[$1$tag$2\]/g;
+ if ($tag<10) {
+ if ($tag eq '001') {
+ $reported_tag.='$3'.$field->data();
+ }
+ } else {
+ my @subf = $field->subfields;
+ for my $i (0..$#subf) {
+ my $subfieldcode = $subf[$i][0];
+ my $subfieldvalue = $subf[$i][1];
+ my $tagsubf = $tag.$subfieldcode;
+ $localsummary =~ s/\[(.?.?.?.?)$tagsubf(.*?)\]/$1$subfieldvalue$2\[$1$tagsubf$2\]/g;
+ }
+ }
+ push @stringssummary, $localsummary if ($localsummary ne $summary{summary});
}
- }
- # see :
- foreach my $field ($record->field('5..')) {
-
- if (($field->subfield('5')) && ($field->subfield('a')) && ($field->subfield('5') eq 'g')) {
- $broaderterms.= ' '.$field->as_string('abcdefgjxyz')." -- \n";
- } elsif (($field->subfield('5')) && ($field->as_string) && ($field->subfield('5') eq 'h')){
- $narrowerterms.= ''.$field->as_string('abcdefgjxyz')." -- \n";
- } elsif ($field->subfield('a')) {
- $seealso.= ''.$field->as_string('abcdefgxyz')." -- \n";
+ my $resultstring;
+ $resultstring = join(" -- ",@stringssummary);
+ $resultstring =~ s/\[(.*?)\]//g;
+ $resultstring =~ s/\n/
/g;
+ $summary{summary} = $resultstring;
+ } else {
+ my @authorized;
+ my @notes;
+ my @seefrom;
+ my @seealso;
+ my @otherscript;
+ my @fields = $record->fields();
+ if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
+# construct UNIMARC summary, that is quite different from MARC21 one
+# accepted form
+ foreach my $field ($record->field('2..')) {
+ push @authorized, $field->as_string('abcdefghijlmnopqrstuvwxyz');
+ }
+# rejected form(s)
+ foreach my $field ($record->field('3..')) {
+ push @notes, $field->subfield('a');
+ }
+ foreach my $field ($record->field('4..')) {
+ my $thesaurus = $field->subfield('2') ? "thes. : ".$thesaurus{"$field->subfield('2')"}." : " : '';
+ push @seefrom, { heading => $thesaurus . $field->as_string('abcdefghijlmnopqrstuvwxyz'), type => 'seefrom' };
+ }
+# see :
+ foreach my $field ($record->field('5..')) {
+ if (($field->subfield('5')) && ($field->subfield('a')) && ($field->subfield('5') eq 'g')) {
+ push @seealso, { $field->as_string('abcdefgjxyz'), type => 'broader' };
+ } elsif (($field->subfield('5')) && ($field->as_string) && ($field->subfield('5') eq 'h')){
+ push @seealso, { heading => $field->as_string('abcdefgjxyz'), type => 'narrower' };
+ } elsif ($field->subfield('a')) {
+ push @seealso, { heading => $field->as_string('abcdefgxyz'), type => 'seealso' };
+ }
+ }
+# // form
+ foreach my $field ($record->field('7..')) {
+ my $lang = substr($field->subfield('8'),3,3);
+ push @otherscript, { lang => $lang, term => $field->subfield('a') };
+ }
+ } else {
+# construct MARC21 summary
+# FIXME - looping over 1XX is questionable
+# since MARC21 authority should have only one 1XX
+ foreach my $field ($record->field('1..')) {
+ my $tag = $field->tag();
+ next if "152" eq $tag;
+# FIXME - 152 is not a good tag to use
+# in MARC21 -- purely local tags really ought to be
+# 9XX
+ if ($tag eq '100') {
+ push @authorized, $field->as_string('abcdefghjklmnopqrstvxyz68');
+ } elsif ($tag eq '110') {
+ push @authorized, $field->as_string('abcdefghklmnoprstvxyz68');
+ } elsif ($tag eq '111') {
+ push @authorized, $field->as_string('acdefghklnpqstvxyz68');
+ } elsif ($tag eq '130') {
+ push @authorized, $field->as_string('adfghklmnoprstvxyz68');
+ } elsif ($tag eq '148') {
+ push @authorized, $field->as_string('abvxyz68');
+ } elsif ($tag eq '150') {
+ push @authorized, $field->as_string('abvxyz68');
+ } elsif ($tag eq '151') {
+ push @authorized, $field->as_string('avxyz68');
+ } elsif ($tag eq '155') {
+ push @authorized, $field->as_string('abvxyz68');
+ } elsif ($tag eq '180') {
+ push @authorized, $field->as_string('vxyz68');
+ } elsif ($tag eq '181') {
+ push @authorized, $field->as_string('vxyz68');
+ } elsif ($tag eq '182') {
+ push @authorized, $field->as_string('vxyz68');
+ } elsif ($tag eq '185') {
+ push @authorized, $field->as_string('vxyz68');
+ } else {
+ push @authorized, $field->as_string();
+ }
+ } #See From
+ foreach my $field ($record->field('4..')) {
+ my $type = 'seefrom';
+ $type = $marc21controlrefs{substr $field->subfield('w'), '0'} if ($field->subfield('w'));
+ if ($type eq 'subfi') {
+ push @seefrom, { heading => $field->as_string($marc21subfields), type => $field->subfield('i') };
+ } else {
+ push @seefrom, { heading => $field->as_string($marc21subfields), type => $type };
+ }
+ } #See Also
+ foreach my $field ($record->field('5..')) {
+ my $type = 'seealso';
+ $type = $marc21controlrefs{substr $field->subfield('w'), '0'} if ($field->subfield('w'));
+ if ($type eq 'subfi') {
+ push @seealso, { heading => $field->as_string($marc21subfields), type => $field->subfield('i') };
+ } else {
+ push @seealso, { heading => $field->as_string($marc21subfields), type => $type };
+ }
+ }
+ foreach my $field ($record->field('6..')) {
+ push @notes, $field->as_string();
+ }
}
- }
- # // form
- foreach my $field ($record->field('7..')) {
- my $lang = substr($field->subfield('8'),3,3);
- $seeheading.= ' En '.$language{$lang}.' : '.$field->subfield('a')."
\n";
- }
- $broaderterms =~s/-- \n$//;
- $narrowerterms =~s/-- \n$//;
- $seealso =~s/-- \n$//;
- $see =~s/-- \n$//;
- $summary = $heading."
".($notes?"$notes
":"");
- $summary.= '
[% Tag0X.tag %]
[% subfiel.marc_lib %]: [% subfiel.marc_value %]
- [% END %] +[% subfiel.marc_lib %]: + [% IF subfiel.isurl %][% subfiel.marc_value %] + [% ELSE %][% subfiel.marc_value %][% END %]
+ [% END %]