Bug 4838 Allow to choose which authority heading to copy into biblio record
authorFrédéric Demians <f.demians@tamil.fr>
Mon, 20 Dec 2010 14:09:49 +0000 (15:09 +0100)
committerChris Cormack <chrisc@catalyst.net.nz>
Tue, 21 Dec 2010 03:50:45 +0000 (16:50 +1300)
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 <henridamien.laurent@biblibre.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
authorities/auth_finder.pl
authorities/blinddetail-biblio-search.pl
koha-tmpl/intranet-tmpl/prog/en/modules/authorities/blinddetail-biblio-search.tmpl
koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tmpl

index 89f632f..99ac2c1 100755 (executable)
@@ -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;
index 1495348..0f734b2 100755 (executable)
@@ -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;
index a6e4723..a9753b3 100644 (file)
             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-->
             }
         }
index e327451..5d1f9a4 100644 (file)
@@ -70,7 +70,13 @@ function jumpfull(page)
                         <td><!-- TMPL_VAR NAME="summary" --></td>
                         <td><!-- TMPL_VAR NAME="used" --> times</td>
                         <td>
+                          <!-- TMPL_IF name="repets" -->
+                            <!-- TMPL_LOOP NAME="repets" -->
+                              <a href="javascript:jumpfull('blinddetail-biblio-search.pl?authid=<!-- TMPL_VAR NAME="authid" -->&amp;index=<!-- TMPL_VAR NAME="index" -->&amp;repet=<!-- TMPL_VAR NAME="repet" -->')" title="<!-- TMPL_VAR NAME="value" -->"><!-- TMPL_VAR NAME="repet" --></a>
+                            <!-- /TMPL_LOOP -->
+                          <!-- TMPL_ELSE -->
                             <a href="javascript:jumpfull('blinddetail-biblio-search.pl?authid=<!-- TMPL_VAR NAME="authid" -->&amp;index=<!-- TMPL_VAR NAME="index" -->')">choose</a>
+                          <!-- /TMPL_IF -->
                         </td>
                         <td><a href="authorities.pl?authid=<!-- TMPL_VAR NAME="authid" -->">Edit authority</a></td>
                     </tr>