From f40b93ed1f8b5035eeda3301c51c491bccc80a5f Mon Sep 17 00:00:00 2001 From: Srdjan Jankovic Date: Mon, 12 Sep 2011 21:09:49 +1200 Subject: [PATCH] [Signed Off] bug_6576: Submit when changing framework rather then reloading Content-Type: text/plain; charset="utf-8" TransformHtmlToMarc(): changed interface - no point passing params when they can be accessed from $cgi Signed-off-by: Liz Rea --- C4/Biblio.pm | 34 ++++++++++---------- authorities/authorities.pl | 3 +- cataloguing/addbiblio.pl | 21 +++++++----- cataloguing/merge.pl | 3 +- .../prog/en/modules/cataloguing/addbiblio.tt | 8 ++-- 5 files changed, 36 insertions(+), 33 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 96baaef..915139e 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -1989,8 +1989,8 @@ sub _default_ind_to_space { =head2 TransformHtmlToMarc - L<$record> = TransformHtmlToMarc(L<$params>,L<$cgi>) - L<$params> is a ref to an array as below: + L<$record> = TransformHtmlToMarc(L<$cgi>) + L<$cgi> is the CGI object which containts the values for subfields { 'tag_010_indicator1_531951' , 'tag_010_indicator2_531951' , @@ -2007,15 +2007,15 @@ sub _default_ind_to_space { 'tag_200_code_f_873510_110730' , 'tag_200_subfield_f_873510_110730' , } - L<$cgi> is the CGI object which containts the value. L<$record> is the MARC::Record object. =cut sub TransformHtmlToMarc { - my $params = shift; my $cgi = shift; + my @params = $cgi->param(); + # explicitly turn on the UTF-8 flag for all # 'tag_' parameters to avoid incorrect character # conversion later on @@ -2035,8 +2035,8 @@ sub TransformHtmlToMarc { my $record = MARC::Record->new(); my $i = 0; my @fields; - while ( $params->[$i] ) { # browse all CGI params - my $param = $params->[$i]; + while ( $params[$i] ) { # browse all CGI params + my $param = $params[$i]; my $newfield = 0; # if we are on biblionumber, store it in the MARC::Record (it may not be in the edited fields) @@ -2052,7 +2052,7 @@ sub TransformHtmlToMarc { my $tag = $1; my $ind1 = _default_ind_to_space( substr( $cgi->param($param), 0, 1 ) ); - my $ind2 = _default_ind_to_space( substr( $cgi->param( $params->[ $i + 1 ] ), 0, 1 ) ); + my $ind2 = _default_ind_to_space( substr( $cgi->param( $params[ $i + 1 ] ), 0, 1 ) ); $newfield = 0; my $j = $i + 2; @@ -2062,27 +2062,27 @@ sub TransformHtmlToMarc { # Force a fake leader even if not provided to avoid crashing # during decoding MARC record containing UTF-8 characters $record->leader( - length( $cgi->param($params->[$j+1]) ) == 24 - ? $cgi->param( $params->[ $j + 1 ] ) + length( $cgi->param($params[$j+1]) ) == 24 + ? $cgi->param( $params[ $j + 1 ] ) : ' nam a22 4500' ) ; # between 001 and 009 (included) - } elsif ( $cgi->param( $params->[ $j + 1 ] ) ne '' ) { - $newfield = MARC::Field->new( $tag, $cgi->param( $params->[ $j + 1 ] ), ); + } elsif ( $cgi->param( $params[ $j + 1 ] ) ne '' ) { + $newfield = MARC::Field->new( $tag, $cgi->param( $params[ $j + 1 ] ), ); } # > 009, deal with subfields } else { - while ( defined $params->[$j] && $params->[$j] =~ /_code_/ ) { # browse all it's subfield - my $inner_param = $params->[$j]; + while ( defined $params[$j] && $params[$j] =~ /_code_/ ) { # browse all it's subfield + my $inner_param = $params[$j]; if ($newfield) { - if ( $cgi->param( $params->[ $j + 1 ] ) ne '' ) { # only if there is a value (code => value) - $newfield->add_subfields( $cgi->param($inner_param) => $cgi->param( $params->[ $j + 1 ] ) ); + if ( $cgi->param( $params[ $j + 1 ] ) ne '' ) { # only if there is a value (code => value) + $newfield->add_subfields( $cgi->param($inner_param) => $cgi->param( $params[ $j + 1 ] ) ); } } else { - if ( $cgi->param( $params->[ $j + 1 ] ) ne '' ) { # creating only if there is a value (code => value) - $newfield = MARC::Field->new( $tag, $ind1, $ind2, $cgi->param($inner_param) => $cgi->param( $params->[ $j + 1 ] ), ); + if ( $cgi->param( $params[ $j + 1 ] ) ne '' ) { # creating only if there is a value (code => value) + $newfield = MARC::Field->new( $tag, $ind1, $ind2, $cgi->param($inner_param) => $cgi->param( $params[ $j + 1 ] ), ); } } $j += 2; diff --git a/authorities/authorities.pl b/authorities/authorities.pl index d4f1601..2e18332 100755 --- a/authorities/authorities.pl +++ b/authorities/authorities.pl @@ -581,8 +581,7 @@ if ($op eq "add") { # build indicator hash. my @ind_tag = $input->param('ind_tag'); my @indicator = $input->param('indicator'); - my @params = $input->param(); - my $record = TransformHtmlToMarc(\@params,$input); + my $record = TransformHtmlToMarc($input); if (C4::Context->preference("marcflavour") eq "UNIMARC"){ unless ($record->field('100')){ use POSIX qw(strftime); diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index 21601e9..ba10332 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -931,7 +931,7 @@ if ( $op eq "addbiblio" ) { ); # getting html input my @params = $input->param(); - $record = TransformHtmlToMarc( \@params , $input ); + $record = TransformHtmlToMarc( $input ); # check for a duplicate my ( $duplicatebiblionumber, $duplicatetitle ); if ( !$is_a_modif ) { @@ -1037,14 +1037,19 @@ elsif ( $op eq "delete" ) { $biblionumber = ""; } + if ( $record eq -1 ) { + $record = TransformHtmlToMarc( $input ); + } + else { #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; - MARC::Record::default_record_format("UNIMARC") - if ( C4::Context->preference("marcflavour") eq "UNIMARC" ); - my $urecord = MARC::Record::new_from_xml( $uxml, 'UTF-8' ); - $record = $urecord; - }; + eval { + my $uxml = $record->as_xml; + MARC::Record::default_record_format("UNIMARC") + if ( C4::Context->preference("marcflavour") eq "UNIMARC" ); + my $urecord = MARC::Record::new_from_xml( $uxml, 'UTF-8' ); + $record = $urecord; + }; + } build_tabs( $template, $record, $dbh, $encoding,$input ); $template->param( biblionumber => $biblionumber, diff --git a/cataloguing/merge.pl b/cataloguing/merge.pl index cc2d01d..c97ca7a 100755 --- a/cataloguing/merge.pl +++ b/cataloguing/merge.pl @@ -48,12 +48,11 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( #------------------------ if ($merge) { - my @params = $input->param(); my $dbh = C4::Context->dbh; my $sth; # Creating a new record from the html code - my $record = TransformHtmlToMarc( \@params , $input ); + my $record = TransformHtmlToMarc( $input ); my $tobiblio = $input->param('biblio1'); my $frombiblio = $input->param('biblio2'); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt index baa84c7..91d926e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt @@ -254,9 +254,9 @@ function GetZ3950Terms(){ } function Changefwk(FwkList) { - var fwk = FwkList.options[FwkList.selectedIndex].value; - window.location = "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% biblionumberdata %]&op=[% op %]&breedingid=[% breedingid %]&mode=[% popup %]&frameworkcode="+fwk; - + var f = document.f; + f.op.value = ""; + f.submit(); } // returns the subfieldcode based upon subfieldid writing @@ -776,7 +776,7 @@ function unHideSubfield(index,labelindex) { // FIXME :: is it used ?
  • - [% FOREACH frameworkcodeloo IN frameworkcodeloop %] [% IF ( frameworkcodeloo.selected ) %] -- 1.7.2.5