[Koha-cvs] CVS: koha/acqui.simple addbiblio.pl,1.24,1.25 marcimport.pl,1.32,1.33

Paul POULAIN tipaul at users.sourceforge.net
Tue Apr 29 18:48:40 CEST 2003


Update of /cvsroot/koha/koha/acqui.simple
In directory sc8-pr-cvs1:/tmp/cvs-serv3884/acqui.simple

Modified Files:
	addbiblio.pl marcimport.pl 
Log Message:
really proud of this commit :-)
z3950 search and import seems to works fine.
Let me explain how :
* a "search z3950" button is added in the addbiblio template.
* when clicked, a popup appears and z3950/search.pl is called
* z3950/search.pl calls addz3950search in the DB
* the z3950 daemon retrieve the records and stores them in z3950results AND in marc_breeding table.
* as long as there as searches pending, the popup auto refresh every 2 seconds, and says how many searches are pending.
* when the user clicks on a z3950 result => the parent popup is called with the requested biblio, and auto-filled

Note :
* character encoding support : (It's a nightmare...) In the z3950servers table, a "encoding" column has been added. You can put "UNIMARC" or "USMARC" in this column. Depending on this, the char_decode in C4::Biblio.pm replaces marc-char-encode by an iso 8859-1 encoding. Note that in the breeding import this value has been added too, for a better support.
* the marc_breeding and z3950* tables have been modified : they have an encoding column and the random z3950 number is stored too for convenience => it's the key I use to list only requested biblios in the popup.


Index: addbiblio.pl
===================================================================
RCS file: /cvsroot/koha/koha/acqui.simple/addbiblio.pl,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -r1.24 -r1.25
*** addbiblio.pl	10 Apr 2003 13:56:05 -0000	1.24
--- addbiblio.pl	29 Apr 2003 16:48:35 -0000	1.25
***************
*** 37,41 ****
  =item find_value
  
!     ($indicators, $value) = find_value($tag, $subfield, $record);
  
  Find the given $subfield in the given $tag in the given
--- 37,41 ----
  =item find_value
  
!     ($indicators, $value) = find_value($tag, $subfield, $record,$encoding);
  
  Find the given $subfield in the given $tag in the given
***************
*** 47,51 ****
  
  sub find_value {
! 	my ($tagfield,$insubfield,$record) = @_;
  	my @result;
  	my $indicator;
--- 47,52 ----
  
  sub find_value {
! 	my ($tagfield,$insubfield,$record,$encoding) = @_;
! 	warn "FIND_VALUE : $encoding /";
  	my @result;
  	my $indicator;
***************
*** 61,65 ****
  			foreach my $subfield (@subfields) {
  				if (@$subfield[0] eq $insubfield) {
! 					push @result,@$subfield[1];
  					$indicator = $field->indicator(1).$field->indicator(2);
  				}
--- 62,67 ----
  			foreach my $subfield (@subfields) {
  				if (@$subfield[0] eq $insubfield) {
! 					warn "@$subfield[1]==> ".char_decode(@$subfield[1],$encoding);
! 					push @result,char_decode(@$subfield[1],$encoding);
  					$indicator = $field->indicator(1).$field->indicator(2);
  				}
***************
*** 78,81 ****
--- 80,84 ----
  record with id $breedingid.  If found, returns the decoded
  MARC::Record; otherwise, -1 is returned (FIXME).
+ Returns as second parameter the character encoding.
  
  =cut
***************
*** 83,89 ****
  sub MARCfindbreeding {
  	my ($dbh,$id) = @_;
! 	my $sth = $dbh->prepare("select file,marc from marc_breeding where id=?");
  	$sth->execute($id);
! 	my ($file,$marc) = $sth->fetchrow;
  	if ($marc) {
  		my $record = MARC::File::USMARC::decode($marc);
--- 86,92 ----
  sub MARCfindbreeding {
  	my ($dbh,$id) = @_;
! 	my $sth = $dbh->prepare("select file,marc,encoding from marc_breeding where id=?");
  	$sth->execute($id);
! 	my ($file,$marc,$encoding) = $sth->fetchrow;
  	if ($marc) {
  		my $record = MARC::File::USMARC::decode($marc);
***************
*** 91,95 ****
  			return -1;
  		} else {
! 			return $record;
  		}
  	}
--- 94,98 ----
  			return -1;
  		} else {
! 			return $record,$encoding;
  		}
  	}
***************
*** 155,160 ****
  }
  
! sub build_tabs ($$$) {
!     my($template, $record, $dbh) = @_;
  
      # fill arrays
--- 158,163 ----
  }
  
! sub build_tabs ($$$$) {
!     my($template, $record, $dbh,$encoding) = @_;
  
      # fill arrays
***************
*** 181,185 ****
  			# if breeding is not empty
  			if ($record ne -1) {
! 				my ($x, at value) = find_value($tag,$subfield,$record);
  				push (@value,"") if ($#value eq -1);
  				foreach my $value (@value) {
--- 184,188 ----
  			# if breeding is not empty
  			if ($record ne -1) {
! 				my ($x, at value) = find_value($tag,$subfield,$record,$encoding);
  				push (@value,"") if ($#value eq -1);
  				foreach my $value (@value) {
***************
*** 212,217 ****
  			} else {
  				my ($x,$value);
! 				($x,$value) = find_value($tag,$subfield,$record) if ($record ne -1);
! 				$value=char_decode($value) unless ($is_a_modif);
  					my %subfield_data;
  					$subfield_data{tag}=$tag;
--- 215,220 ----
  			} else {
  				my ($x,$value);
! 				($x,$value) = find_value($tag,$subfield,$record,$encoding) if ($record ne -1);
! # 				$value=char_decode($value) unless ($is_a_modif);
  					my %subfield_data;
  					$subfield_data{tag}=$tag;
***************
*** 278,286 ****
  }
  
- 
  my $input = new CGI;
  my $error = $input->param('error');
  my $oldbiblionumber=$input->param('oldbiblionumber'); # if bib exists, it's a modif, not a new biblio.
  my $breedingid = $input->param('breedingid');
  my $op = $input->param('op');
  my $dbh = C4::Context->dbh;
--- 281,289 ----
  }
  
  my $input = new CGI;
  my $error = $input->param('error');
  my $oldbiblionumber=$input->param('oldbiblionumber'); # if bib exists, it's a modif, not a new biblio.
  my $breedingid = $input->param('breedingid');
+ my $z3950 = $input->param('z3950');
  my $op = $input->param('op');
  my $dbh = C4::Context->dbh;
***************
*** 302,307 ****
  $tagslib = &MARCgettagslib($dbh,1);
  my $record=-1;
  $record = MARCgetbiblio($dbh,$bibid) if ($bibid);
! $record = MARCfindbreeding($dbh,$breedingid) if ($breedingid);
  $is_a_modif=0;
  my ($oldbiblionumtagfield,$oldbiblionumtagsubfield);
--- 305,312 ----
  $tagslib = &MARCgettagslib($dbh,1);
  my $record=-1;
+ my $encoding="";
  $record = MARCgetbiblio($dbh,$bibid) if ($bibid);
! ($record,$encoding) = MARCfindbreeding($dbh,$breedingid) if ($breedingid);
! 
  $is_a_modif=0;
  my ($oldbiblionumtagfield,$oldbiblionumtagsubfield);
***************
*** 331,337 ****
  		$indicators{$ind_tag[$i]} = $indicator[$i];
  	}
- 	warn "MARChtml";
  	my $record = MARChtml2marc($dbh,\@tags,\@subfields,\@values,%indicators);
- 	warn "MARChtml2";
  # MARC::Record built => now, record in DB
  	my $oldbibnum;
--- 336,340 ----
***************
*** 348,352 ****
  } else {
  #------------------------------------------------------------------------------------------------------------------------------
! 	build_tabs ($template, $record, $dbh);
  	build_hidden_data;
  	$template->param(
--- 351,355 ----
  } else {
  #------------------------------------------------------------------------------------------------------------------------------
! 	build_tabs ($template, $record, $dbh,$encoding);
  	build_hidden_data;
  	$template->param(

Index: marcimport.pl
===================================================================
RCS file: /cvsroot/koha/koha/acqui.simple/marcimport.pl,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -r1.32 -r1.33
*** marcimport.pl	22 Apr 2003 12:22:54 -0000	1.32
--- marcimport.pl	29 Apr 2003 16:48:36 -0000	1.33
***************
*** 68,71 ****
--- 68,72 ----
  my $overwrite_biblio = $input->param('overwrite_biblio');
  my $filename = $input->param('filename');
+ my $syntax = $input->param('syntax');
  my ($template, $loggedinuser, $cookie)
  	= get_template_and_user({template_name => "acqui.simple/marcimport.tmpl",
***************
*** 84,88 ****
  		$marcrecord.=$_;
  	}
! 	my ($notmarcrecord,$alreadyindb,$alreadyinfarm,$imported) = ImportBreeding($marcrecord,$overwrite_biblio,$filename);
  
  	$template->param(imported => $imported,
--- 85,89 ----
  		$marcrecord.=$_;
  	}
! 	my ($notmarcrecord,$alreadyindb,$alreadyinfarm,$imported) = ImportBreeding($marcrecord,$overwrite_biblio,$filename,$syntax);
  
  	$template->param(imported => $imported,
***************
*** 103,106 ****
--- 104,122 ----
  # log cleared, as marcimport is (almost) rewritten from scratch.
  # $Log$
+ # Revision 1.33  2003/04/29 16:48:36  tipaul
+ # really proud of this commit :-)
+ # z3950 search and import seems to works fine.
+ # Let me explain how :
+ # * a "search z3950" button is added in the addbiblio template.
+ # * when clicked, a popup appears and z3950/search.pl is called
+ # * z3950/search.pl calls addz3950search in the DB
+ # * the z3950 daemon retrieve the records and stores them in z3950results AND in marc_breeding table.
+ # * as long as there as searches pending, the popup auto refresh every 2 seconds, and says how many searches are pending.
+ # * when the user clicks on a z3950 result => the parent popup is called with the requested biblio, and auto-filled
+ #
+ # Note :
+ # * character encoding support : (It's a nightmare...) In the z3950servers table, a "encoding" column has been added. You can put "UNIMARC" or "USMARC" in this column. Depending on this, the char_decode in C4::Biblio.pm replaces marc-char-encode by an iso 8859-1 encoding. Note that in the breeding import this value has been added too, for a better support.
+ # * the marc_breeding and z3950* tables have been modified : they have an encoding column and the random z3950 number is stored too for convenience => it's the key I use to list only requested biblios in the popup.
+ #
  # Revision 1.32  2003/04/22 12:22:54  tipaul
  # 1st draft for z3950 client import.





More information about the Koha-cvs mailing list