From 452e65166c7b0dc5a3c66e14b37f73b1b56919f9 Mon Sep 17 00:00:00 2001 From: tipaul Date: Tue, 1 Apr 2003 12:26:43 +0000 Subject: [PATCH] fixes --- C4/Biblio.pm | 34 +++++++++--------- C4/Output.pm | 3 +- C4/Reserves2.pm | 1 - C4/SearchMarc.pm | 2 -- acqui.simple/addbiblio.pl | 73 ++++++++++++++++++++++----------------- acqui.simple/additem.pl | 1 - search.marc/search.pl | 2 +- 7 files changed, 60 insertions(+), 56 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index b108449ab2..a6aa389e7f 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -1,6 +1,9 @@ package C4::Biblio; # $Id$ # $Log$ +# Revision 1.41 2003/04/01 12:26:43 tipaul +# fixes +# # Revision 1.40 2003/03/11 15:14:03 tipaul # pod updating # @@ -571,14 +574,14 @@ sub MARCaddsubfield { $sth=$dbh->prepare("insert into marc_subfield_table (bibid,tag,tagorder,tag_indicator,subfieldcode,subfieldorder,valuebloblink) values (?,?,?,?,?,?,?)"); $sth->execute($bibid,(sprintf "%03s",$tagid),$tagorder,$tag_indicator,$subfieldcode,$subfieldorder,$res); if ($sth->errstr) { - print STDERR "ERROR ==> insert into marc_subfield_table (bibid,tag,tagorder,tag_indicator,subfieldcode,subfieldorder,subfieldvalue) values ($bibid,$tagid,$tagorder,$tag_indicator,$subfieldcode,$subfieldorder,$subfieldvalue)\n"; + warn "ERROR ==> insert into marc_subfield_table (bibid,tag,tagorder,tag_indicator,subfieldcode,subfieldorder,subfieldvalue) values ($bibid,$tagid,$tagorder,$tag_indicator,$subfieldcode,$subfieldorder,$subfieldvalue)\n"; } # $dbh->do("unlock tables"); } else { my $sth=$dbh->prepare("insert into marc_subfield_table (bibid,tag,tagorder,tag_indicator,subfieldcode,subfieldorder,subfieldvalue) values (?,?,?,?,?,?,?)"); $sth->execute($bibid,(sprintf "%03s",$tagid),$tagorder,$tag_indicator,$subfieldcode,$subfieldorder,$subfieldvalue); if ($sth->errstr) { - print STDERR "ERROR ==> insert into marc_subfield_table (bibid,tag,tagorder,tag_indicator,subfieldcode,subfieldorder,subfieldvalue) values ($bibid,$tagid,$tagorder,$tag_indicator,$subfieldcode,$subfieldorder,$subfieldvalue)\n"; + warn "ERROR ==> insert into marc_subfield_table (bibid,tag,tagorder,tag_indicator,subfieldcode,subfieldorder,subfieldvalue) values ($bibid,$tagid,$tagorder,$tag_indicator,$subfieldcode,$subfieldorder,$subfieldvalue)\n"; } } &MARCaddword($dbh,$bibid,$tagid,$tagorder,$subfieldcode,$subfieldorder,$subfieldvalue); @@ -691,6 +694,8 @@ sub MARCmodbiblio { if ($oldrecord eq $record) { return; } +# warn "rec : ".$record->as_formatted; +# die; # otherwise, skip through each subfield... my @fields = $record->fields(); my $tagorder=0; @@ -718,6 +723,7 @@ sub MARCmodbiblio { # modify the subfield if it's a different string if ($oldfield->subfield(@$subfield[0]) ne @$subfield[1] ) { my $subfieldid=&MARCfindsubfieldid($dbh,$bibid,$field->tag(),$tagorder,@$subfield[0],$subfieldorder); + warn "subfieldid => $subfieldid"; &MARCmodsubfield($dbh,$subfieldid,@$subfield[1]); } } @@ -969,35 +975,27 @@ sub MARCkoha2marcOnefield { sub MARChtml2marc { my ($dbh,$rtags,$rsubfields,$rvalues,%indicators) = @_; - my $prevtag = @$rtags[0]; + my $prevtag = -1; my $record = MARC::Record->new(); - my %subfieldlist={}; + my %subfieldlist=(); + my $field; for (my $i=0; $i< @$rtags; $i++) { # rebuild MARC::Record if (@$rtags[$i] ne $prevtag) { -# if ($prevtag<10) { -# $prevtag='0'.10; -# } - $indicators{$prevtag}.=' '; if ($prevtag < 10) { $record->add_fields((sprintf "%03s",$prevtag),%subfieldlist->{'@'}); } else { - my $field = MARC::Field->new( (sprintf "%03s",$prevtag), substr($indicators{$prevtag},0,1),substr($indicators{$prevtag},1,1), %subfieldlist); $record->add_fields($field); } + $indicators{@$rtags[$i]}.=' '; + $field = MARC::Field->new( (sprintf "%03s",@$rtags[$i]), substr($indicators{@$rtags[$i]},0,1),substr($indicators{@$rtags[$i]},1,1), @$rsubfields[$i] => @$rvalues[$i]); $prevtag = @$rtags[$i]; - %subfieldlist={}; - %subfieldlist->{@$rsubfields[$i]} = @$rvalues[$i]; } else { - if (%subfieldlist->{@$rsubfields[$i]}) { - %subfieldlist->{@$rsubfields[$i]} .= '|'; - } - %subfieldlist->{@$rsubfields[$i]} .=@$rvalues[$i]; + $field->add_subfields(@$rsubfields[$i] => @$rvalues[$i]); $prevtag= @$rtags[$i]; } } # the last has not been included inside the loop... do it now ! - my $field = MARC::Field->new( $prevtag, "", "", %subfieldlist); $record->add_fields($field); return $record; } @@ -1063,7 +1061,7 @@ sub MARCaddword { if (length($word)>1 and !($stopwords->{uc($word)})) { $sth->execute($bibid,$tag,$tagorder,$subfieldid,$subfieldorder,$word,$word); if ($sth->err()) { - print STDERR "ERROR ==> insert into marc_word (bibid, tag, tagorder, subfieldid, subfieldorder, word, sndx_word) values ($bibid,$tag,$tagorder,$subfieldid,$subfieldorder,$word,soundex($word))\n"; + warn "ERROR ==> insert into marc_word (bibid, tag, tagorder, subfieldid, subfieldorder, word, sndx_word) values ($bibid,$tag,$tagorder,$subfieldid,$subfieldorder,$word,soundex($word))\n"; } } } @@ -1130,7 +1128,7 @@ sub NEWnewbiblio { $sth->execute("biblioitems.biblioitemnumber"); (my $tagfield2, my $tagsubfield2) = $sth->fetchrow; if ($tagfield1 != $tagfield2) { - print STDERR "Error in NEWnewbiblio : biblio.biblionumber and biblioitems.biblioitemnumber MUST have the same field number"; + warn "Error in NEWnewbiblio : biblio.biblionumber and biblioitems.biblioitemnumber MUST have the same field number"; print "Content-Type: text/html\n\nError in NEWnewbiblio : biblio.biblionumber and biblioitems.biblioitemnumber MUST have the same field number"; die; } diff --git a/C4/Output.pm b/C4/Output.pm index 33a5d2f63b..e7400ef002 100644 --- a/C4/Output.pm +++ b/C4/Output.pm @@ -120,10 +120,11 @@ sub themelanguage { THEME: foreach my $th (@themes) { foreach my $la (@languages) { -# warn "File = $htdocs/$th/$la/$tmpl\n"; + warn "File = $htdocs/$th/$la/$tmpl\n"; if (-e "$htdocs/$th/$la/$tmpl") { $theme = $th; $lang = $la; + warn "FOUND"; last THEME; } } diff --git a/C4/Reserves2.pm b/C4/Reserves2.pm index a80c67ceed..f5214734e1 100755 --- a/C4/Reserves2.pm +++ b/C4/Reserves2.pm @@ -793,6 +793,5 @@ sub getreservetitle { $sth->execute; my $data=$sth->fetchrow_hashref; $sth->finish; -# print $query; return($data); } diff --git a/C4/SearchMarc.pm b/C4/SearchMarc.pm index 86aa8d74e8..8ef3b349ff 100644 --- a/C4/SearchMarc.pm +++ b/C4/SearchMarc.pm @@ -56,7 +56,6 @@ on what is passed to it, it calls the appropriate search function. # marcsearch : search in the MARC biblio table. # everything is choosen by the user : what to search, the conditions... -# FIXME this is a 1st version of the Marc Search. It does not use fulltext searching or marc_words table sub catalogsearch { my ($dbh, $tags, $subfields, $and_or, $excluding, $operator, $value, $offset,$length) = @_; @@ -127,7 +126,6 @@ sub catalogsearch { } } chop $sql_tables; - warn "select m1.bibid from $sql_tables where $sql_where2 and ($sql_where1)"; my $sth; if ($sql_where2) { $sth = $dbh->prepare("select m1.bibid from $sql_tables where $sql_where2 and ($sql_where1)"); diff --git a/acqui.simple/addbiblio.pl b/acqui.simple/addbiblio.pl index 3f694fa99d..e8779a92a1 100755 --- a/acqui.simple/addbiblio.pl +++ b/acqui.simple/addbiblio.pl @@ -47,31 +47,30 @@ returned. sub find_value { my ($tagfield,$insubfield,$record) = @_; - my $result; + my @result; my $indicator; - warn "tagfield : $tagfield /".$record->as_formatted; if ($tagfield <10) { if ($record->field($tagfield)) { - $result = $record->field($tagfield)->data(); + push @result, $record->field($tagfield)->data(); } else { - $result=""; + push @result,""; } } else { foreach my $field ($record->field($tagfield)) { my @subfields = $field->subfields(); foreach my $subfield (@subfields) { if (@$subfield[0] eq $insubfield) { - $result .= @$subfield[1]; + push @result,@$subfield[1]; $indicator = $field->indicator(1).$field->indicator(2); } } } } - return($indicator,$result); + return($indicator,@result); } -=item find_value +=item MARCfindbreeding $record = MARCfindbreeding($dbh, $breedingid); @@ -88,7 +87,6 @@ sub MARCfindbreeding { my ($file,$marc) = $sth->fetchrow; if ($marc) { my $record = MARC::File::USMARC::decode($marc); - warn "==> ".$record->as_formatted(); if (ref($record) eq undef) { return -1; } else { @@ -180,36 +178,47 @@ sub build_tabs ($$$) { foreach my $subfield (sort(keys %{$tagslib->{$tag}})) { next if subfield_is_koha_internal_p($subfield); next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop); - my %subfield_data; - $subfield_data{tag}=$tag; - $subfield_data{subfield}=$subfield; - $subfield_data{marc_lib}="
".$tagslib->{$tag}->{$subfield}->{lib}."
"; - $subfield_data{tag_mandatory}=$tagslib->{$tag}->{mandatory}; - $subfield_data{mandatory}=$tagslib->{$tag}->{$subfield}->{mandatory}; - $subfield_data{repeatable}=$tagslib->{$tag}->{$subfield}->{repeatable}; # if breeding is not empty if ($record ne -1) { - my ($x,$value) = find_value($tag,$subfield,$record); - $value=char_decode($value) unless ($is_a_modif); - $indicator = $x if $x; #XXX - if ($tagslib->{$tag}->{$subfield}->{authorised_value}) { - $subfield_data{marc_value}= build_authorized_values_list($tag, $subfield, $value, $dbh, $authorised_values_sth); - } elsif ($tagslib->{$tag}->{$subfield}->{thesaurus_category}) { - $subfield_data{marc_value}=" {$tag}->{$subfield}->{thesaurus_category}&index=$i',$i)\">..."; #" - } elsif ($tagslib->{$tag}->{$subfield}->{'value_builder'}) { - my $plugin="../value_builder/".$tagslib->{$tag}->{$subfield}->{'value_builder'}; - require $plugin; - my $extended_param = plugin_parameters($dbh,$record,$tagslib,$i,$tabloop); - my ($function_name,$javascript) = plugin_javascript($dbh,$record,$tagslib,$i,$tabloop); - $subfield_data{marc_value}=" ... $javascript"; - } else { - $subfield_data{marc_value}=""; + my ($x,@value) = find_value($tag,$subfield,$record); + foreach my $value (@value) { + my %subfield_data; + $subfield_data{tag}=$tag; + $subfield_data{subfield}=$subfield; + $subfield_data{marc_lib}="
".$tagslib->{$tag}->{$subfield}->{lib}."
"; + $subfield_data{tag_mandatory}=$tagslib->{$tag}->{mandatory}; + $subfield_data{mandatory}=$tagslib->{$tag}->{$subfield}->{mandatory}; + $subfield_data{repeatable}=$tagslib->{$tag}->{$subfield}->{repeatable}; + $value=char_decode($value) unless ($is_a_modif); + $indicator = $x if $x; #XXX + if ($tagslib->{$tag}->{$subfield}->{authorised_value}) { + $subfield_data{marc_value}= build_authorized_values_list($tag, $subfield, $value, $dbh, $authorised_values_sth); + } elsif ($tagslib->{$tag}->{$subfield}->{thesaurus_category}) { + $subfield_data{marc_value}=" {$tag}->{$subfield}->{thesaurus_category}&index=$i',$i)\">..."; #" + } elsif ($tagslib->{$tag}->{$subfield}->{'value_builder'}) { + my $plugin="../value_builder/".$tagslib->{$tag}->{$subfield}->{'value_builder'}; + require $plugin; + my $extended_param = plugin_parameters($dbh,$record,$tagslib,$i,$tabloop); + my ($function_name,$javascript) = plugin_javascript($dbh,$record,$tagslib,$i,$tabloop); + $subfield_data{marc_value}=" ... $javascript"; + } else { + $subfield_data{marc_value}=""; + } + push(@subfields_data, \%subfield_data); + $i++; } # if breeding is empty } 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; + $subfield_data{subfield}=$subfield; + $subfield_data{marc_lib}="
".$tagslib->{$tag}->{$subfield}->{lib}."
"; + $subfield_data{tag_mandatory}=$tagslib->{$tag}->{mandatory}; + $subfield_data{mandatory}=$tagslib->{$tag}->{$subfield}->{mandatory}; + $subfield_data{repeatable}=$tagslib->{$tag}->{$subfield}->{repeatable}; if ($tagslib->{$tag}->{$subfield}->{authorised_value}) { $subfield_data{marc_value}= build_authorized_values_list($tag, $subfield, $value, $dbh, $authorised_values_sth); } elsif ($tagslib->{$tag}->{$subfield}->{thesaurus_category}) { @@ -223,9 +232,9 @@ sub build_tabs ($$$) { } else { $subfield_data{marc_value}=""; } + push(@subfields_data, \%subfield_data); + $i++; } - push(@subfields_data, \%subfield_data); - $i++; } if ($#subfields_data >= 0) { my %tag_data; diff --git a/acqui.simple/additem.pl b/acqui.simple/additem.pl index 343867f217..d89330ee7e 100755 --- a/acqui.simple/additem.pl +++ b/acqui.simple/additem.pl @@ -74,7 +74,6 @@ if ($op eq "additem") { $indicators{$ind_tag[$i]} = $indicator[$i]; } my $record = MARChtml2marc($dbh,\@tags,\@subfields,\@values,%indicators); - warn "item before NEWnewitem : ".$record->as_formatted(); # MARC::Record builded => now, record in DB my ($oldbiblionumber,$oldbibnum,$oldbibitemnum) = NEWnewitem($dbh,$record,$bibid); $nextop = "additem"; diff --git a/search.marc/search.pl b/search.marc/search.pl index a096eacdd4..da55e9b029 100755 --- a/search.marc/search.pl +++ b/search.marc/search.pl @@ -68,7 +68,7 @@ if ($op eq "do_search") { flagsrequired => {catalogue => 1}, debug => 1, }); - #$template->param(result => \@results); + $template->param(result => \@results); } else { ($template, $loggedinuser, $cookie) -- 2.39.5