From 6c633aca559f90ecb7370de17600ab7b9ddcaf06 Mon Sep 17 00:00:00 2001 From: kados Date: Sun, 2 Apr 2006 19:12:01 +0000 Subject: [PATCH] syncing with rel_2_2, adding visibility handling --- cataloguing/addbiblio.pl | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index c138184dfd..267b05abf7 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -31,6 +31,7 @@ use C4::Log; use C4::Koha; # XXX subfield_is_koha_internal_p use HTML::Template; use MARC::File::USMARC; +use MARC::File::XML; use vars qw( $tagslib); use vars qw( $authorised_values_sth); @@ -169,17 +170,19 @@ sub create_input () { $subfield_data{tag}=$tag; $subfield_data{subfield}=$subfield; $subfield_data{marc_lib}="".$tagslib->{$tag}->{$subfield}->{lib}.""; + $subfield_data{marc_lib_plain}=$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}; $subfield_data{kohafield}=$tagslib->{$tag}->{$subfield}->{kohafield}; $subfield_data{index} = $i; + $subfield_data{visibility} = "display:none" unless (($tagslib->{$tag}->{$subfield}->{hidden}%2==0) or $value ne ''); #check parity # it's an authorised field if ($tagslib->{$tag}->{$subfield}->{authorised_value}) { $subfield_data{marc_value}= build_authorized_values_list($tag, $subfield, $value, $dbh,$authorised_values_sth); # it's a thesaurus / authority field } elsif ($tagslib->{$tag}->{$subfield}->{authtypecode}) { - $subfield_data{marc_value}=" {$tag}->{$subfield}->{authtypecode}."&index=$i',$i)\">..."; + $subfield_data{marc_value}=" {$tag}->{$subfield}->{authtypecode}."&index=$i',$i)\">..."; # it's a plugin field } elsif ($tagslib->{$tag}->{$subfield}->{'value_builder'}) { # opening plugin. Just check wether we are on a developper computer on a production one @@ -192,18 +195,18 @@ sub create_input () { require $plugin; my $extended_param = plugin_parameters($dbh,$rec,$tagslib,$i,$tabloop); my ($function_name,$javascript) = plugin_javascript($dbh,$rec,$tagslib,$i,$tabloop); - $subfield_data{marc_value}=" ... $javascript"; + $subfield_data{marc_value}=" ... $javascript"; # it's an hidden field } elsif ($tag eq '') { - $subfield_data{marc_value}=""; + $subfield_data{marc_value}=""; } elsif ($tagslib->{$tag}->{$subfield}->{'hidden'}) { - $subfield_data{marc_value}=""; + $subfield_data{marc_value}=""; # it's a standard field } else { if (length($value) >100) { $subfield_data{marc_value}=""; } else { - $subfield_data{marc_value}=""; #" + $subfield_data{marc_value}=""; #" } } return \%subfield_data; @@ -264,6 +267,7 @@ sub build_tabs ($$$$) { next if (length $subfield !=1); next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop); next if ($tag<10); + next if (($tagslib->{$tag}->{$subfield}->{hidden}<=-4) or ($tagslib->{$tag}->{$subfield}->{hidden}>=5) ); #check for visibility flag next if (defined($field->subfield($subfield))); push(@subfields_data, &create_input($tag,$subfield,'',$i,$tabloop,$record,$authorised_values_sth)); $i++; @@ -275,6 +279,10 @@ sub build_tabs ($$$$) { $tag_data{repeatable} = $tagslib->{$tag}->{repeatable}; $tag_data{indicator} = $record->field($tag)->indicator(1). $record->field($tag)->indicator(2) if ($tag>=10); $tag_data{subfield_loop} = \@subfields_data; + if ($tag<10) { + $tag_data{fixedfield} = 1; + } + push (@loop_data, \%tag_data); } # If there is more than 1 field, add an empty hidden field as separator. @@ -286,6 +294,9 @@ sub build_tabs ($$$$) { $tag_data{tag_lib} = ''; $tag_data{indicator} = ''; $tag_data{subfield_loop} = \@subfields_data; + if ($tag<10) { + $tag_data{fixedfield} = 1; + } push (@loop_data, \%tag_data); $i++; } @@ -295,6 +306,7 @@ sub build_tabs ($$$$) { my @subfields_data; foreach my $subfield (sort(keys %{$tagslib->{$tag}})) { next if (length $subfield !=1); + next if (($tagslib->{$tag}->{$subfield}->{hidden}<=-5) or ($tagslib->{$tag}->{$subfield}->{hidden}>=4) ); #check for visibility flag next if ($tagslib->{$tag}->{$subfield}->{tab} ne $tabloop); push(@subfields_data, &create_input($tag,$subfield,'',$i,$tabloop,$record,$authorised_values_sth)); $i++; @@ -306,6 +318,10 @@ sub build_tabs ($$$$) { $tag_data{repeatable} = $tagslib->{$tag}->{repeatable}; $tag_data{indicator} = $indicator; $tag_data{subfield_loop} = \@subfields_data; + $tag_data{tagfirstsubfield} = $tag_data{subfield_loop}[0]; + if ($tag<10) { + $tag_data{fixedfield} = 1; + } push (@loop_data, \%tag_data); } } @@ -460,16 +476,16 @@ if ($op eq "addbiblio") { } elsif ($op eq "addfield") { #------------------------------------------------------------------------------------------------------------------------------ my $addedfield = $input->param('addfield_field'); + my $tagaddfield_subfield = $input->param('addfield_subfield'); my @tags = $input->param('tag'); my @subfields = $input->param('subfield'); my @values = $input->param('field_value'); - # build indicator hash. my @ind_tag = $input->param('ind_tag'); my @indicator = $input->param('indicator'); my $xml = MARChtml2xml(\@tags,\@subfields,\@values,\@indicator,\@ind_tag); - my $record=MARC::Record::new_from_xml($xml, 'UTF-8'); + my $record=MARC::Record::new_from_xml($xml, 'UTF-8'); # adding an empty field - my $field = MARC::Field->new("$addedfield",'','','a'=> ""); + my $field = MARC::Field->new("$addedfield",'','','$tagaddfield_subfield' => ""); $record->append_fields($field); build_tabs ($template, $record, $dbh,$encoding); build_hidden_data; @@ -499,9 +515,9 @@ if ($op eq "addbiblio") { } #FIXME: it's kind of silly to go from MARC::Record to MARC::File::XML and then back again just to fix the encoding eval { - my $uxml = $record->as_xml; - my $urecord = MARC::Record::new_from_xml($uxml, 'UTF-8'); - $record = $urecord; + my $uxml = $record->as_xml; + my $urecord = MARC::Record::new_from_xml($uxml, 'UTF-8'); + $record = $urecord; }; build_tabs ($template, $record, $dbh,$encoding); build_hidden_data; -- 2.39.5