koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] koha authorities/blinddetail-biblio-search.pl k...


From: Antoine Farnault
Subject: [Koha-cvs] koha authorities/blinddetail-biblio-search.pl k...
Date: Tue, 31 Jul 2007 16:11:48 +0000

CVSROOT:        /sources/koha
Module name:    koha
Changes by:     Antoine Farnault <toins>        07/07/31 16:11:48

Modified files:
        authorities    : blinddetail-biblio-search.pl 
        koha-tmpl/intranet-tmpl/prog/en/authorities: 
                                                     
blinddetail-biblio-search.tmpl 

Log message:
        fixed to work with addbiblio.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/authorities/blinddetail-biblio-search.pl?cvsroot=koha&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/prog/en/authorities/blinddetail-biblio-search.tmpl?cvsroot=koha&r1=1.4&r2=1.5

Patches:
Index: authorities/blinddetail-biblio-search.pl
===================================================================
RCS file: /sources/koha/koha/authorities/blinddetail-biblio-search.pl,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- authorities/blinddetail-biblio-search.pl    2 Jul 2007 09:49:40 -0000       
1.14
+++ authorities/blinddetail-biblio-search.pl    31 Jul 2007 16:11:48 -0000      
1.15
@@ -19,7 +19,7 @@
 
 =head1 NAME
 
-etail.pl : script to show an authority in MARC format
+blinddetail-biblio-search.pl : script to show an authority in MARC format
 
 =head1 SYNOPSIS
 
@@ -37,7 +37,6 @@
 
 =cut
 
-
 use strict;
 require Exporter;
 use C4::AuthoritiesMarc;
@@ -48,85 +47,89 @@
 use MARC::Record;
 use C4::Koha;
 
+my $query = new CGI;
 
-my $query=new CGI;
-
-my $dbh=C4::Context->dbh;
+my $dbh = C4::Context->dbh;
 
 my $authid = $query->param('authid');
 my $index = $query->param('index');
 my $tagid = $query->param('tagid');
 my $authtypecode = &GetAuthTypeCode($authid);
-my $tagslib = &GetTagsLabels(1,$authtypecode);
+my $tagslib      = &GetTagsLabels( 1, $authtypecode );
 
 my $auth_type = GetAuthType($authtypecode);
+my $record = GetAuthority($authid) if $authid;
 
-my $record =GetAuthority($authid) if $authid;
 # open template
-my ($template, $loggedinuser, $cookie)
-               = get_template_and_user({template_name => 
"authorities/blinddetail-biblio-search.tmpl",
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {
+        template_name   => "authorities/blinddetail-biblio-search.tmpl",
                             query => $query,
                             type => "intranet",
                             authnotrequired => 0,
-                            flagsrequired => {editauthorities => 1},
-                            debug => 1,
-                            });
+        flagsrequired   => { editauthorities => 1 },
+    }
+);
 
 # fill arrays
-my @loop_data =();
 my $tag;
-my @loop_data =();
+my @loop_data = ();
 if ($authid) {
-  foreach my $field ($record->field($auth_type->{auth_tag_to_report})) {
+    foreach my $field ( $record->field( $auth_type->{auth_tag_to_report} ) ) {
     my @subfields_data;
-    my @subf=$field->subfields;
+        my @subf = $field->subfields;
+
     # loop through each subfield
     my %result;
-    for my $i (0..$#subf) {
+        for my $i ( 0 .. $#subf ) {
       $subf[$i][0] = "@" unless $subf[$i][0];
-      $result{$subf[$i][0]}.=$subf[$i][1]."|";
+            $result{ $subf[$i][0] } .= $subf[$i][1] . "|";
     }
-    foreach (keys %result) {
+        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);
+            $subfield_data{marc_value}    = $result{$_};
+            $subfield_data{marc_subfield} = $_;
+
+            # $subfield_data{marc_tag}=$field->tag();
+            push( @subfields_data, \%subfield_data );
     }
-    if ($#subfields_data>=0) {
+        if ( $#subfields_data >= 0 ) {
       my %tag_data;
-      $tag_data{tag}=$field->tag().' -'. $tagslib->{$field->tag()}->{lib};
+            $tag_data{tag} = $field->tag() . ' -' . $tagslib->{ $field->tag() 
}->{lib};
       $tag_data{subfield} = address@hidden;
-      push (@loop_data, \%tag_data);
+            push( @loop_data, \%tag_data );
     }
   }
 } else {
-# authid is empty => the user want to empty the entry.
+    # authid is empty => the user want to empty the entry.
   my @subfields_data;
-  foreach my $subfield ('a'..'z') {
     my %subfield_data;
-    $subfield_data{marc_value}='';
-    $subfield_data{marc_subfield}=$subfield;
-    push(@subfields_data, \%subfield_data);
+    foreach my $subfield ( '0' .. '9' ) { #subfield code should also be number 
!
+        $subfield_data{marc_value}    = '';
+        $subfield_data{marc_subfield} = $subfield;
+        push( @subfields_data, \%subfield_data );
   }
-#      if ($#subfields_data>=0) {
+    foreach my $subfield ( 'a' .. 'z' ) {
+        $subfield_data{marc_value}    = '';
+        $subfield_data{marc_subfield} = $subfield;
+        push( @subfields_data, \%subfield_data );
+    }
+    
   my %tag_data;
-#                      $tag_data{tag}=$field->tag().' -'. 
$tagslib->{$field->tag()}->{lib};
+    # $tag_data{tag}=$field->tag().' -'. $tagslib->{$field->tag()}->{lib};
   $tag_data{subfield} = address@hidden;
-  push (@loop_data, \%tag_data);
-#      }
+    push( @loop_data, \%tag_data );
+    warn Data::Dumper::Dumper(address@hidden);
 }
 
-$template->param("0XX" =>address@hidden);
+$template->param( "0XX" => address@hidden );
 
-
-$template->param(authid => $authid?$authid:"",
+$template->param(
+    authid => $authid ? $authid : "",
                 index => $index,
                 tagid => $tagid,
-                intranetcolorstylesheet => 
C4::Context->preference("intranetcolorstylesheet"),
-                intranetstylesheet => 
C4::Context->preference("intranetstylesheet"),
-                IntranetNav => C4::Context->preference("IntranetNav"),
-                );
+);
+
 output_html_with_http_headers $query, $cookie, $template->output;
 

Index: 
koha-tmpl/intranet-tmpl/prog/en/authorities/blinddetail-biblio-search.tmpl
===================================================================
RCS file: 
/sources/koha/koha/koha-tmpl/intranet-tmpl/prog/en/authorities/blinddetail-biblio-search.tmpl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- koha-tmpl/intranet-tmpl/prog/en/authorities/blinddetail-biblio-search.tmpl  
5 Jun 2007 08:54:18 -0000       1.4
+++ koha-tmpl/intranet-tmpl/prog/en/authorities/blinddetail-biblio-search.tmpl  
31 Jul 2007 16:11:48 -0000      1.5
@@ -3,57 +3,41 @@
 <!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
 
 <script type="text/javascript">
+    window.onload = go();
 
-function go()
-{
-var index_start = <!-- TMPL_VAR NAME="index" -->;
-var whichfield = opener.opener.document.f.tag[index_start].value;
-i=index_start
-// go forward, until reaching the end of the field.
-while (i<opener.opener.document.f.field_value.length) {
-       if (opener.opener.document.f.tag[i].value == whichfield && 
opener.opener.document.f.subfield[i].value == '9') {
-               opener.opener.document.f.field_value[i].value = "<!-- TMPL_VAR 
NAME="authid" -->";
+    function go(){
+        var index_start = "<!-- TMPL_VAR NAME='index' -->";
+        var whichfield;
+        try {
+            whichfield = opener.opener.document.getElementById(index_start);
+        } catch(e) {
+            return;
        }
-       <!-- TMPL_LOOP NAME="0XX" -->
-               <!-- TMPL_LOOP NAME="subfield" -->
-                       if (opener.opener.document.f.tag[i].value == whichfield 
&& opener.opener.document.f.subfield[i].value == '<!-- TMPL_VAR 
NAME="marc_subfield" -->') 
-                       {
-                               opener.opener.document.f.field_value[i].value = 
"<!-- TMPL_VAR NAME="marc_value" -->";
-                       }
-               <!-- /TMPL_LOOP -->
-       <!-- /TMPL_LOOP -->
-       if (opener.opener.document.f.tag[i].value != whichfield) {
-               i=opener.opener.document.f.field_value.length;
-       }
-       i++;
-}
-// go backward until the beginning of the field
-i=index_start
-while (i>=0) {
-       if (opener.opener.document.f.tag[i].value == whichfield && 
opener.opener.document.f.subfield[i].value == '9') {
-               opener.opener.document.f.field_value[i].value = "<!-- TMPL_VAR 
NAME="authid">";
+        
+        // browse all its subfields
+        var subfields = 
whichfield.parentNode.parentNode.getElementsByTagName('input');
+        var re = /^tag_\d*_code_/;
+        for(var i=0, len = subfields.length ; i< len ; i++) { // browse all 
subfields
+            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(code.value=='9'){
+                        subfield.value = "<!-- TMPL_VAR NAME="authid" -->";
        }
        <!-- TMPL_LOOP NAME="0XX" -->
                <!-- TMPL_LOOP NAME="subfield" -->
-                       if (opener.opener.document.f.tag[i].value == whichfield 
&& opener.opener.document.f.subfield[i].value == '<!-- TMPL_VAR 
NAME="marc_subfield" -->') 
-                       {
-                               opener.opener.document.f.field_value[i].value = 
"<!-- TMPL_VAR NAME="marc_value" -->";
+                    if (code.value == "<!-- TMPL_VAR NAME="marc_subfield" 
-->"){
+                        subfield.value = "<!-- TMPL_VAR NAME="marc_value" -->";
                        }
                <!-- /TMPL_LOOP -->
        <!-- /TMPL_LOOP -->
-       if (opener.opener.document.f.tag[i].value != whichfield) {
-               i=0;
        }
-       i--;
-}
+        }
+        
        opener.close();
-       self.close();
+               window.close();
        return false;
-
-
-}
-</script>
-<script language="javascript" type="text/javascript">
-window.onload = go();
+    }
 </script>
+
 <!-- TMPL_INCLUDE name="intranet-bottom.inc" -->
\ No newline at end of file




reply via email to

[Prev in Thread] Current Thread [Next in Thread]