diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index 8bcddbcc79..eb1308712e 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -888,12 +888,13 @@ sub BuildSummary { my ($record,$authid,$authtypecode)=@_; my $dbh=C4::Context->dbh; my %summary; + my $summary_template; # handle $authtypecode is NULL or eq "" if ($authtypecode) { my $authref = GetAuthType($authtypecode); $summary{authtypecode} = $authref->{authtypecode}; $summary{type} = $authref->{authtypetext}; - $summary{summary} = $authref->{summary}; + $summary_template = $authref->{summary}; } my $marc21subfields = 'abcdfghjklmnopqrstuvxyz68'; my %marc21controlrefs = ( 'a' => 'earlier', @@ -926,14 +927,14 @@ sub BuildSummary { # 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') { + if ($summary_template and C4::Context->preference('marcflavour') eq 'UNIMARC') { my @fields = $record->fields(); # $reported_tag = '$9'.$result[$counter]; - my @stringssummary; + my @repets; foreach my $field (@fields) { my $tag = $field->tag(); my $tagvalue = $field->as_string(); - my $localsummary= $summary{summary}; + my $localsummary= $summary_template; $localsummary =~ s/\[(.?.?.?.?)$tag\*(.*?)\]/$1$tagvalue$2\[$1$tag$2\]/g; if ($tag<10) { if ($tag eq '001') { @@ -948,13 +949,13 @@ sub BuildSummary { $localsummary =~ s/\[(.?.?.?.?)$tagsubf(.*?)\]/$1$subfieldvalue$2\[$1$tagsubf$2\]/g; } } - push @stringssummary, $localsummary if ($localsummary ne $summary{summary}); + if ($localsummary ne $summary_template) { + $localsummary =~ s/\[(.*?)\]//g; + $localsummary =~ s/\n/
/g; + push @repets, $localsummary; + } } - my $resultstring; - $resultstring = join(" -- ",@stringssummary); - $resultstring =~ s/\[(.*?)\]//g; - $resultstring =~ s/\n/
/g; - $summary{summary} = $resultstring; + $summary{repets} = \@repets; } my @authorized; my @notes; diff --git a/authorities/auth_finder.pl b/authorities/auth_finder.pl index 2ff76ec222..607c6524f8 100755 --- a/authorities/auth_finder.pl +++ b/authorities/auth_finder.pl @@ -83,20 +83,6 @@ if ( $op eq "do_search" ) { $startfrom * $resultsperpage, $resultsperpage, $authtypecode, $orderby ); - # If an authority heading is repeated, add an arrayref to those repetions - # First heading -- Second heading - for my $heading (@$results) { - my @repets = split / -- /, $heading->{summary}; - if ( @repets > 1 ) { - my @repets_loop; - for ( my $i = 0 ; $i < @repets ; $i++ ) { - push @repets_loop, - { index => $index, repet => $i + 1, value => $repets[$i] }; - } - $heading->{repets} = \@repets_loop; - } - } - # multi page display gestion my $displaynext = 0; my $displayprev = $startfrom; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-search-results.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-search-results.inc index 8c2c83c65d..8de56e9254 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-search-results.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/authorities-search-results.inc @@ -50,18 +50,24 @@ [% END %] [% END %] [% BLOCK authresult %] - [% IF ( summary.summary ) %][% summary.summary | html %]:[% END %] +
+ [% FOREACH repet IN summary.repets %] + [% repet | html %] + [% UNLESS loop.last %] | [% END %] + [% END %] +
[% UNLESS ( summary.summaryonly ) %]
[% FOREACH authorize IN summary.authorized %] [% authorize.heading | html %] + [% UNLESS loop.last %] | [% END %] [% END %]
[% IF ( marcflavour == 'UNIMARC' ) %] [% IF summary.notes %]
[% FOREACH note IN summary.notes %] - [% note.note | html %] + [% note.note | html %] [% END %]
[% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt index 415185a014..898de870df 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt @@ -73,9 +73,9 @@ function doauth(authid, index, repet) [% PROCESS authresult summary=resul.summary %] [% resul.used %] times - [% IF resul.repets %] - [% FOREACH repet IN resul.repets %] - [% repet.repet %] + [% IF resul.summary && resul.summary.repets && resul.summary.repets.size > 1 %] + [% FOREACH repet IN resul.summary.repets %] + [% loop.count %] [% END %] [% ELSE %] choose diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/authorities-search-results.inc b/koha-tmpl/opac-tmpl/prog/en/includes/authorities-search-results.inc index 506bcf1d98..8efa4ec712 100644 --- a/koha-tmpl/opac-tmpl/prog/en/includes/authorities-search-results.inc +++ b/koha-tmpl/opac-tmpl/prog/en/includes/authorities-search-results.inc @@ -49,18 +49,24 @@ [% END %] [% END %] [% BLOCK authresult %] - [% IF ( summary.summary ) %][% summary.summary | html %]:[% END %] +
+ [% FOREACH repet IN summary.repets %] + [% repet | html %] + [% UNLESS loop.last %] | [% END %] + [% END %] +
[% UNLESS ( summary.summaryonly ) %]
[% FOREACH authorize IN summary.authorized %] [% authorize.heading | html %] + [% UNLESS loop.last %] | [% END %] [% END %]
[% IF ( marcflavour == 'UNIMARC' ) %] [% IF summary.notes %]
[% FOREACH note IN summary.notes %] - [% note.note | html %] + [% note.note | html %] [% END %]
[% END %]