[Koha-patches] [PATCH] Bug 4838 Repeated authority headings break biblio record data entry form

Frédéric Demians f.demians at tamil.fr
Sun May 30 09:38:42 CEST 2010


This patch solves this bug. $9 is correcly populated for repeated headings
authority. The first heading is choosen automatically.

An improvement would allow the user to select which heading entry to copy.
---
 authorities/blinddetail-biblio-search.pl           |   45 ++++++-------------
 .../authorities/blinddetail-biblio-search.tmpl     |   15 +++----
 2 files changed, 21 insertions(+), 39 deletions(-)

diff --git a/authorities/blinddetail-biblio-search.pl b/authorities/blinddetail-biblio-search.pl
index e723187..08058a2 100755
--- a/authorities/blinddetail-biblio-search.pl
+++ b/authorities/blinddetail-biblio-search.pl
@@ -76,46 +76,29 @@ 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 );
+        for ( $field->subfields ) {
+            my ($letter, $value) = @$_;
+            $letter = '@' unless $letter;
+            push @subfield_loop, { marc_subfield => $letter, marc_value => $value };
         }
+        # We take the first entry of a repeatable authority heading.
+        # This situation can occur in a multilingual UNIMARC DB
+        last;
     }
-} 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 f0bcb38..d196131 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
@@ -20,19 +20,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
+
             <!-- TMPL_IF NAME="clear" -->
                 if (subfield){subfield.value="" ;}
             <!--TMPL_ELSE-->      
-            <!-- TMPL_LOOP NAME="0XX" -->
-                <!-- TMPL_LOOP NAME="subfield" -->
-                    if (code.value == "<!-- TMPL_VAR ESCAPE="JS" NAME="marc_subfield" -->"){
+              <!-- TMPL_LOOP NAME="SUBFIELD_LOOP" -->
+                if (code.value == "<!-- TMPL_VAR ESCAPE="JS" NAME="marc_subfield" -->"){
                         subfield.value = "<!-- TMPL_VAR ESCAPE="JS" NAME="marc_value" -->";
-                    }
-                <!-- /TMPL_LOOP -->
-            <!-- /TMPL_LOOP -->
-                if(code.value=='9'){
-                        subfield.value = "<!-- TMPL_VAR ESCAPE="JS" NAME="authid" -->";
                 }
+              <!-- /TMPL_LOOP -->
+              if(code.value=='9'){
+                  subfield.value = "<!-- TMPL_VAR ESCAPE="JS" NAME="authid" -->";
+              }
             <!--/TMPL_IF-->
             }
         }
-- 
1.5.6.5



More information about the Koha-patches mailing list