[Koha-cvs] CVS: koha/C4 Biblio.pm,1.31,1.32

Paul POULAIN tipaul at users.sourceforge.net
Mon Dec 16 16:09:10 CET 2002


Update of /cvsroot/koha/koha/C4
In directory sc8-pr-cvs1:/tmp/cvs-serv21406/C4

Modified Files:
	Biblio.pm 
Log Message:
small but important bugfix (fixes a problem in export)

Index: Biblio.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Biblio.pm,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -r1.31 -r1.32
*** Biblio.pm	13 Dec 2002 16:22:04 -0000	1.31
--- Biblio.pm	16 Dec 2002 15:08:50 -0000	1.32
***************
*** 2,5 ****
--- 2,8 ----
  # $Id$
  # $Log$
+ # Revision 1.32  2002/12/16 15:08:50  tipaul
+ # small but important bugfix (fixes a problem in export)
+ #
  # Revision 1.31  2002/12/13 16:22:04  tipaul
  # 1st draft of marc export
***************
*** 548,552 ****
      my $prevtag='  ';
      my $previndicator;
!     my %subfieldlist={};
      while (my $row=$sth->fetchrow_hashref) {
  		if ($row->{'valuebloblink'}) { #---- search blob if there is one
--- 551,555 ----
      my $prevtag='  ';
      my $previndicator;
!     my %subfieldlist;
      while (my $row=$sth->fetchrow_hashref) {
  		if ($row->{'valuebloblink'}) { #---- search blob if there is one
***************
*** 562,579 ****
  			}
  			$previndicator.="  ";
! #			warn "NEW : subfieldcode : $prevtag";
  			my $field = MARC::Field->new( $prevtag, substr($previndicator,0,1), substr($previndicator,1,1), %subfieldlist);
! #			warn $field->as_formatted();
  			$record->add_fields($field);
  			$prevtagorder=$row->{tagorder};
  			$prevtag = $row->{tag};
  			$previndicator=$row->{tag_indicator};
! 			%subfieldlist={};
  			%subfieldlist->{$row->{'subfieldcode'}} = $row->{'subfieldvalue'};
  		} else {
  #			warn "subfieldcode : $row->{'subfieldcode'} / value : $row->{'subfieldvalue'}, tag : $row->{tag}";
! 			if (%subfieldlist->{$row->{'subfieldcode'}}) {
! 				%subfieldlist->{$row->{'subfieldcode'}}.='|';
! 			}
  			%subfieldlist->{$row->{'subfieldcode'}} .= $row->{'subfieldvalue'};
  			$prevtag= $row->{tag};
--- 565,585 ----
  			}
  			$previndicator.="  ";
! #			warn "NEW : subfieldcode : $prevtag".substr($previndicator,0,1).substr($previndicator,1,1),;
! #			foreach my $x (keys %subfieldlist) {
! #				warn "                      $x => ".$subfieldlist{$x};
! #			}
  			my $field = MARC::Field->new( $prevtag, substr($previndicator,0,1), substr($previndicator,1,1), %subfieldlist);
! #			warn $field;
  			$record->add_fields($field);
  			$prevtagorder=$row->{tagorder};
  			$prevtag = $row->{tag};
  			$previndicator=$row->{tag_indicator};
! 			%subfieldlist;
  			%subfieldlist->{$row->{'subfieldcode'}} = $row->{'subfieldvalue'};
  		} else {
  #			warn "subfieldcode : $row->{'subfieldcode'} / value : $row->{'subfieldvalue'}, tag : $row->{tag}";
! #			if (%subfieldlist->{$row->{'subfieldcode'}}) {
! #				%subfieldlist->{$row->{'subfieldcode'}}.='|';
! #			}
  			%subfieldlist->{$row->{'subfieldcode'}} .= $row->{'subfieldvalue'};
  			$prevtag= $row->{tag};
***************
*** 583,586 ****
--- 589,596 ----
  	# the last has not been included inside the loop... do it now !
  	my $field = MARC::Field->new( $prevtag, "", "", %subfieldlist);
+ #			warn "NEW : subfieldcode : $prevtag".substr($previndicator,0,1).substr($previndicator,1,1),;
+ #			foreach my $x (keys %subfieldlist) {
+ #				warn "                      $x => ".$subfieldlist{$x};
+ #			}
  	$record->add_fields($field);
  	return $record;
***************
*** 974,994 ****
  sub MARCmarc2kohaOneField {
  # FIXME ? if a field has a repeatable subfield that is used in old-db, only the 1st will be retrieved...
!     my ($sth,$kohatable,$kohafield,$record,$result)= @_;
  #    warn "kohatable / $kohafield / $result / ";
!     my $res="";
!     my $tagfield;
!     my $subfield;
!     $sth->execute($kohatable.".".$kohafield);
!     ($tagfield,$subfield) = $sth->fetchrow;
!     foreach my $field ($record->field($tagfield)) {
! 	if ($field->subfield($subfield)) {
! 	    if ($result->{$kohafield}) {
! 		$result->{$kohafield} .= " | ".$field->subfield($subfield);
! 	    } else {
! 		$result->{$kohafield}=$field->subfield($subfield);
! 	    }
  	}
!     }
!     return $result;
  }
  
--- 984,1004 ----
  sub MARCmarc2kohaOneField {
  # FIXME ? if a field has a repeatable subfield that is used in old-db, only the 1st will be retrieved...
! 	my ($sth,$kohatable,$kohafield,$record,$result)= @_;
  #    warn "kohatable / $kohafield / $result / ";
! 	my $res="";
! 	my $tagfield;
! 	my $subfield;
! 	$sth->execute($kohatable.".".$kohafield);
! 	($tagfield,$subfield) = $sth->fetchrow;
! 	foreach my $field ($record->field($tagfield)) {
! 		if ($field->subfield($subfield)) {
! 		if ($result->{$kohafield}) {
! 			$result->{$kohafield} .= " | ".$field->subfield($subfield);
! 		} else {
! 			$result->{$kohafield}=$field->subfield($subfield);
! 		}
! 		}
  	}
! 	return $result;
  }
  





More information about the Koha-cvs mailing list