From fa0f51d9c28108d65757385f937edcd7ba150901 Mon Sep 17 00:00:00 2001 From: tipaul Date: Wed, 12 Feb 2003 11:01:04 +0000 Subject: [PATCH] Support for 000 -> 010 fields. Those fields doesn't have subfields. In koha, we will use a specific "trick" : fields <10 will have a "virtual" subfield : "@". Note it's only virtual : when rebuilding the MARC::Record, the koha API handle correctly "@" subfields => the resulting MARC record has a 00x field without subfield. --- C4/Biblio.pm | 11 +-- acqui.simple/addbiblio.pl | 145 +++++++++++++++--------------- admin/marc_subfields_structure.pl | 3 +- 3 files changed, 81 insertions(+), 78 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 1a1b00b31e..2dbbe67e66 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -1,6 +1,12 @@ package C4::Biblio; # $Id$ # $Log$ +# Revision 1.37 2003/02/12 11:03:03 tipaul +# Support for 000 -> 010 fields. +# Those fields doesn't have subfields. +# In koha, we will use a specific "trick" : fields <10 will have a "virtual" subfield : "@". +# Note it's only virtual : when rebuilding the MARC::Record, the koha API handle correctly "@" subfields => the resulting MARC record has a 00x field without subfield. +# # Revision 1.36 2003/02/12 11:01:01 tipaul # Support for 000 -> 010 fields. # Those fields doesn't have subfields. @@ -591,7 +597,6 @@ sub MARCgetbiblio { $previndicator.=" "; my $field; if ($prevtag <10) { - warn "add < $prevtag"; $record->add_fields((sprintf "%03s",$prevtag),%subfieldlist->{'@'}); } else { $field = MARC::Field->new( (sprintf "%03s",$prevtag), substr($previndicator,0,1), substr($previndicator,1,1), %subfieldlist); @@ -742,9 +747,6 @@ sub MARCmoditem { my $subfieldid=&MARCfindsubfieldid($dbh,$bibid,$field->tag(),$tagorder,@$subfield[0],$subfieldorder); # warn "changing : $subfieldid, $bibid,".$field->tag(),",$tagorder,@$subfield[0],@$subfield[1],$subfieldorder"; &MARCmodsubfield($dbh,$subfieldid,@$subfield[1]); - } else { -#FIXME ??? - warn "nothing to change : ".$oldfield->subfield(@$subfield[0]); } } } @@ -953,7 +955,6 @@ sub MARCkoha2marcOnefield { sub MARChtml2marc { my ($dbh,$rtags,$rsubfields,$rvalues,%indicators) = @_; my $prevtag = @$rtags[0]; - warn "prev : $prevtag"; my $record = MARC::Record->new(); my %subfieldlist={}; for (my $i=0; $i< @$rtags; $i++) { diff --git a/acqui.simple/addbiblio.pl b/acqui.simple/addbiblio.pl index 5d51a25145..de607b8646 100755 --- a/acqui.simple/addbiblio.pl +++ b/acqui.simple/addbiblio.pl @@ -47,15 +47,18 @@ returned. sub find_value { my ($tagfield,$insubfield,$record) = @_; -# warn "$tagfield / $insubfield // "; my $result; my $indicator; - foreach my $field ($record->field($tagfield)) { - my @subfields = $field->subfields(); - foreach my $subfield (@subfields) { - if (@$subfield[0] eq $insubfield) { - $result .= @$subfield[1]; - $indicator = $field->indicator(1).$field->indicator(2); + if ($tagfield <10) { + $result = $record->field($tagfield)->data(); + } else { + foreach my $field ($record->field($tagfield)) { + my @subfields = $field->subfields(); + foreach my $subfield (@subfields) { + if (@$subfield[0] eq $insubfield) { + $result .= @$subfield[1]; + $indicator = $field->indicator(1).$field->indicator(2); + } } } } @@ -163,73 +166,72 @@ sub build_tabs ($$$) { # my @fields = $record->fields(); my @loop_data = (); foreach my $tag (sort(keys (%{$tagslib}))) { - my $previous_tag = ''; - my @subfields_data; - my $indicator; - - # loop through each subfield - 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 $previous_tag = ''; + my @subfields_data; + my $indicator; + + # loop through each subfield + 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}=""; + } # 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); - 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}=""; - } + } else { + my ($x,$value); + ($x,$value) = find_value($tag,$subfield,$record) if ($record ne -1); + $value=char_decode($value) unless ($is_a_modif); + 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 ($#subfields_data >= 0) { + my %tag_data; + $tag_data{tag} = $tag; + $tag_data{tag_lib} = $tagslib->{$tag}->{lib}; + $tag_data{indicator} = $indicator; + $tag_data{subfield_loop} = \@subfields_data; + push (@loop_data, \%tag_data); + } } - push(@subfields_data, \%subfield_data); - $i++; - } - if ($#subfields_data >= 0) { - my %tag_data; - $tag_data{tag} = $tag; - $tag_data{tag_lib} = $tagslib->{$tag}->{lib}; - $tag_data{indicator} = $indicator; - $tag_data{subfield_loop} = \@subfields_data; - push (@loop_data, \%tag_data); - } + $template->param($tabloop."XX" =>\@loop_data); } - $template->param($tabloop."XX" =>\@loop_data); - } } @@ -284,7 +286,6 @@ my ($template, $loggedinuser, $cookie) $tagslib = &MARCgettagslib($dbh,1); my $record=-1; $record = MARCgetbiblio($dbh,$bibid) if ($bibid); -#warn "1= ".$record->as_formatted; $record = MARCfindbreeding($dbh,$breedingid) if ($breedingid); $is_a_modif=0; my ($oldbiblionumtagfield,$oldbiblionumtagsubfield); diff --git a/admin/marc_subfields_structure.pl b/admin/marc_subfields_structure.pl index c0284af6db..1a9afcf217 100755 --- a/admin/marc_subfields_structure.pl +++ b/admin/marc_subfields_structure.pl @@ -254,6 +254,7 @@ if ($op eq 'add_form') { for (my $i=0; $i<= $#tagsubfield ; $i++) { my $tagfield =$input->param('tagfield'); my $tagsubfield =$tagsubfield[$i]; + $tagsubfield="@" unless $tagsubfield; my $liblibrarian =$liblibrarian[$i]; my $libopac =$libopac[$i]; my $repeatable =$input->param("repeatable$i")?1:0; @@ -263,7 +264,7 @@ if ($op eq 'add_form') { my $authorised_value =$authorised_values[$i]; my $thesaurus_category =$thesaurus_category[$i]; my $value_builder=$value_builder[$i]; - if ($tagsubfield) { + if ($liblibrarian) { $sth->execute ($tagfield, $tagsubfield, $liblibrarian, -- 2.39.5