From 4ed8c0313cc85536f4eb738d8a6c627b82cdfdac Mon Sep 17 00:00:00 2001 From: Adrien Saurat Date: Fri, 4 May 2012 10:53:59 +0200 Subject: [PATCH] Bug 7442: fix for selection of authorities (UNIMARC) When editing a biblio record, if an authority is searched the generated links now behave correctly (if 200$x or 200$y exist they won't have their own link). Now encapsulated for UNIMARC. --- authorities/auth_finder.pl | 32 ++++++++++++++++++++++++++------ 1 files changed, 26 insertions(+), 6 deletions(-) diff --git a/authorities/auth_finder.pl b/authorities/auth_finder.pl index a3821ee..4ad9022 100755 --- a/authorities/auth_finder.pl +++ b/authorities/auth_finder.pl @@ -72,14 +72,34 @@ if ( $op eq "do_search" ) { $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++) { + my @repets_loop; + if ( C4::Context->preference("marcflavour") eq "UNIMARC" ) { + my $record = GetAuthority($heading->{'authid'}); + my $auth_name = ''; # will be displayed in the link tooltip + my $cpt = 0; + foreach my $field ($record->field('200')) { + $auth_name = $field->subfield('a'); + if ($field->subfield('b')) { $auth_name .= ', ' . $field->subfield('b') } + $cpt++; push @repets_loop, - { index => $index, repet => $i+1, value => $repets[$i] }; + { index => $index, repet => $cpt, value => $auth_name }; + } + if ( $cpt < 2 ) { + undef @repets_loop; + } + else { + $heading->{repets} = \@repets_loop; + } + } + else { + 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; } -- 1.7.4.1