From 6b3e4f19f4902e926375d337d948b2050b348537 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Demians?= Date: Mon, 20 Dec 2010 15:09:49 +0100 Subject: [PATCH] Bug 4838 Allow to choose which authority heading to copy into biblio record With this patch, in biblio record data entry form, when ... is clicked for an authority controlled field, it's possible to select which heading repetion to copy if the authority has repeated headings. When there is just one authority repetition, the first one is displayed to choose, as previously. This patch is REQUIRED by French libraries following SUDOC UNIMARC format, and cataloguing multilingual materials ie all Higher Educational and Research libraries. Signed-off-by: Henri-Damien LAURENT Signed-off-by: Chris Cormack --- authorities/auth_finder.pl | 14 ++++++ authorities/blinddetail-biblio-search.pl | 47 ++++++------------- .../blinddetail-biblio-search.tmpl | 15 +++--- .../authorities/searchresultlist-auth.tmpl | 6 +++ 4 files changed, 41 insertions(+), 41 deletions(-) diff --git a/authorities/auth_finder.pl b/authorities/auth_finder.pl index 89f632fb65..99ac2c170e 100755 --- a/authorities/auth_finder.pl +++ b/authorities/auth_finder.pl @@ -70,6 +70,20 @@ if ( $op eq "do_search" ) { SearchAuthorities( \@marclist, \@and_or, \@excluding, \@operator, \@value, $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/authorities/blinddetail-biblio-search.pl b/authorities/blinddetail-biblio-search.pl index 1495348596..0f734b2062 100755 --- a/authorities/blinddetail-biblio-search.pl +++ b/authorities/blinddetail-biblio-search.pl @@ -75,46 +75,27 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( ); # fill arrays -my @loop_data = (); +my @subfield_loop; if ($authid) { - foreach my $field ( $record->field( $auth_type->{auth_tag_to_report} ) ) { - my @subfields_data; - my @subf = $field->subfields; - - # loop through each subfield - my %result; - for my $i ( 0 .. $#subf ) { - $subf[$i][0] = "@" unless $subf[$i][0]; - $result{ $subf[$i][0] } .= $subf[$i][1] . "|"; - } - foreach ( keys %result ) { - my %subfield_data; - chop $result{$_}; - $subfield_data{marc_value} = $result{$_}; - $subfield_data{marc_subfield} = $_; - - # $subfield_data{marc_tag}=$field->tag(); - push( @subfields_data, \%subfield_data ); - } - if ( $#subfields_data >= 0 ) { - my %tag_data; - $tag_data{tag} = $field->tag() . ' -' . $tagslib->{ $field->tag() }->{lib}; - $tag_data{subfield} = \@subfields_data; - push( @loop_data, \%tag_data ); - } + my @fields = $record->field( $auth_type->{auth_tag_to_report} ); + my $repet = ($query->param('repet') || 1) - 1; + my $field = $fields[$repet]; + for ( $field->subfields ) { + my ($letter, $value) = @$_; + $letter = '@' unless $letter; + push @subfield_loop, { marc_subfield => $letter, marc_value => $value }; } -} else { +} +else { # authid is empty => the user want to empty the entry. $template->param( "clear" => 1 ); -# warn Data::Dumper::Dumper(\@loop_data); } -$template->param( "0XX" => \@loop_data ); - $template->param( - authid => $authid ? $authid : "", - index => $index, - tagid => $tagid, + authid => $authid ? $authid : "", + index => $index, + tagid => $tagid, + SUBFIELD_LOOP => \@subfield_loop, ); output_html_with_http_headers $query, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/blinddetail-biblio-search.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/blinddetail-biblio-search.tmpl index a6e47232c0..a9753b34a2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/blinddetail-biblio-search.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/blinddetail-biblio-search.tmpl @@ -19,19 +19,18 @@ if(subfields[i].getAttribute('name').match(re)){ // it s a subfield var code = subfields[i]; // code is the first input var subfield = subfields[i+1]; // subfield the second + if (subfield){subfield.value="" ;} - - - if (code.value == ""){ + + if (code.value == ""){ subfield.value = ""; - } - - - if(code.value=='9'){ - subfield.value = ""; } + + if(code.value=='9'){ + subfield.value = ""; + } } } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tmpl index e327451673..5d1f9a425f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tmpl @@ -70,7 +70,13 @@ function jumpfull(page) times + + + &index=&repet=')" title=""> + + &index=')">choose + ">Edit authority -- 2.39.5