View | Details | Raw Unified | Return to bug 6576
Collapse All | Expand All

(-)a/C4/Biblio.pm (-17 / +17 lines)
Lines 1989-1996 sub _default_ind_to_space { Link Here
1989
1989
1990
=head2 TransformHtmlToMarc
1990
=head2 TransformHtmlToMarc
1991
1991
1992
    L<$record> = TransformHtmlToMarc(L<$params>,L<$cgi>)
1992
    L<$record> = TransformHtmlToMarc(L<$cgi>)
1993
    L<$params> is a ref to an array as below:
1993
    L<$cgi> is the CGI object which containts the values for subfields
1994
    {
1994
    {
1995
        'tag_010_indicator1_531951' ,
1995
        'tag_010_indicator1_531951' ,
1996
        'tag_010_indicator2_531951' ,
1996
        'tag_010_indicator2_531951' ,
Lines 2007-2021 sub _default_ind_to_space { Link Here
2007
        'tag_200_code_f_873510_110730' ,
2007
        'tag_200_code_f_873510_110730' ,
2008
        'tag_200_subfield_f_873510_110730' ,
2008
        'tag_200_subfield_f_873510_110730' ,
2009
    }
2009
    }
2010
    L<$cgi> is the CGI object which containts the value.
2011
    L<$record> is the MARC::Record object.
2010
    L<$record> is the MARC::Record object.
2012
2011
2013
=cut
2012
=cut
2014
2013
2015
sub TransformHtmlToMarc {
2014
sub TransformHtmlToMarc {
2016
    my $params = shift;
2017
    my $cgi    = shift;
2015
    my $cgi    = shift;
2018
2016
2017
    my @params = $cgi->param();
2018
2019
    # explicitly turn on the UTF-8 flag for all
2019
    # explicitly turn on the UTF-8 flag for all
2020
    # 'tag_' parameters to avoid incorrect character
2020
    # 'tag_' parameters to avoid incorrect character
2021
    # conversion later on
2021
    # conversion later on
Lines 2035-2042 sub TransformHtmlToMarc { Link Here
2035
    my $record = MARC::Record->new();
2035
    my $record = MARC::Record->new();
2036
    my $i      = 0;
2036
    my $i      = 0;
2037
    my @fields;
2037
    my @fields;
2038
    while ( $params->[$i] ) {    # browse all CGI params
2038
    while ( $params[$i] ) {    # browse all CGI params
2039
        my $param    = $params->[$i];
2039
        my $param    = $params[$i];
2040
        my $newfield = 0;
2040
        my $newfield = 0;
2041
2041
2042
        # if we are on biblionumber, store it in the MARC::Record (it may not be in the edited fields)
2042
        # if we are on biblionumber, store it in the MARC::Record (it may not be in the edited fields)
Lines 2052-2058 sub TransformHtmlToMarc { Link Here
2052
            my $tag = $1;
2052
            my $tag = $1;
2053
2053
2054
            my $ind1 = _default_ind_to_space( substr( $cgi->param($param), 0, 1 ) );
2054
            my $ind1 = _default_ind_to_space( substr( $cgi->param($param), 0, 1 ) );
2055
            my $ind2 = _default_ind_to_space( substr( $cgi->param( $params->[ $i + 1 ] ), 0, 1 ) );
2055
            my $ind2 = _default_ind_to_space( substr( $cgi->param( $params[ $i + 1 ] ), 0, 1 ) );
2056
            $newfield = 0;
2056
            $newfield = 0;
2057
            my $j = $i + 2;
2057
            my $j = $i + 2;
2058
2058
Lines 2062-2088 sub TransformHtmlToMarc { Link Here
2062
                    # Force a fake leader even if not provided to avoid crashing
2062
                    # Force a fake leader even if not provided to avoid crashing
2063
                    # during decoding MARC record containing UTF-8 characters
2063
                    # during decoding MARC record containing UTF-8 characters
2064
                    $record->leader(
2064
                    $record->leader(
2065
                        length( $cgi->param($params->[$j+1]) ) == 24
2065
                        length( $cgi->param($params[$j+1]) ) == 24
2066
                        ? $cgi->param( $params->[ $j + 1 ] )
2066
                        ? $cgi->param( $params[ $j + 1 ] )
2067
                        : '     nam a22        4500'
2067
                        : '     nam a22        4500'
2068
			)
2068
			)
2069
                    ;
2069
                    ;
2070
                    # between 001 and 009 (included)
2070
                    # between 001 and 009 (included)
2071
                } elsif ( $cgi->param( $params->[ $j + 1 ] ) ne '' ) {
2071
                } elsif ( $cgi->param( $params[ $j + 1 ] ) ne '' ) {
2072
                    $newfield = MARC::Field->new( $tag, $cgi->param( $params->[ $j + 1 ] ), );
2072
                    $newfield = MARC::Field->new( $tag, $cgi->param( $params[ $j + 1 ] ), );
2073
                }
2073
                }
2074
2074
2075
                # > 009, deal with subfields
2075
                # > 009, deal with subfields
2076
            } else {
2076
            } else {
2077
                while ( defined $params->[$j] && $params->[$j] =~ /_code_/ ) {    # browse all it's subfield
2077
                while ( defined $params[$j] && $params[$j] =~ /_code_/ ) {    # browse all it's subfield
2078
                    my $inner_param = $params->[$j];
2078
                    my $inner_param = $params[$j];
2079
                    if ($newfield) {
2079
                    if ($newfield) {
2080
                        if ( $cgi->param( $params->[ $j + 1 ] ) ne '' ) {         # only if there is a value (code => value)
2080
                        if ( $cgi->param( $params[ $j + 1 ] ) ne '' ) {         # only if there is a value (code => value)
2081
                            $newfield->add_subfields( $cgi->param($inner_param) => $cgi->param( $params->[ $j + 1 ] ) );
2081
                            $newfield->add_subfields( $cgi->param($inner_param) => $cgi->param( $params[ $j + 1 ] ) );
2082
                        }
2082
                        }
2083
                    } else {
2083
                    } else {
2084
                        if ( $cgi->param( $params->[ $j + 1 ] ) ne '' ) {         # creating only if there is a value (code => value)
2084
                        if ( $cgi->param( $params[ $j + 1 ] ) ne '' ) {         # creating only if there is a value (code => value)
2085
                            $newfield = MARC::Field->new( $tag, $ind1, $ind2, $cgi->param($inner_param) => $cgi->param( $params->[ $j + 1 ] ), );
2085
                            $newfield = MARC::Field->new( $tag, $ind1, $ind2, $cgi->param($inner_param) => $cgi->param( $params[ $j + 1 ] ), );
2086
                        }
2086
                        }
2087
                    }
2087
                    }
2088
                    $j += 2;
2088
                    $j += 2;
(-)a/authorities/authorities.pl (-2 / +1 lines)
Lines 581-588 if ($op eq "add") { Link Here
581
    # build indicator hash.
581
    # build indicator hash.
582
    my @ind_tag = $input->param('ind_tag');
582
    my @ind_tag = $input->param('ind_tag');
583
    my @indicator = $input->param('indicator');
583
    my @indicator = $input->param('indicator');
584
    my @params = $input->param();
584
    my $record = TransformHtmlToMarc($input);
585
    my $record = TransformHtmlToMarc(\@params,$input);
586
    if  (C4::Context->preference("marcflavour") eq "UNIMARC"){
585
    if  (C4::Context->preference("marcflavour") eq "UNIMARC"){
587
        unless ($record->field('100')){
586
        unless ($record->field('100')){
588
        use POSIX qw(strftime);
587
        use POSIX qw(strftime);
(-)a/cataloguing/addbiblio.pl (-8 / +13 lines)
Lines 931-937 if ( $op eq "addbiblio" ) { Link Here
931
    );
931
    );
932
    # getting html input
932
    # getting html input
933
    my @params = $input->param();
933
    my @params = $input->param();
934
    $record = TransformHtmlToMarc( \@params , $input );
934
    $record = TransformHtmlToMarc( $input );
935
    # check for a duplicate
935
    # check for a duplicate
936
    my ( $duplicatebiblionumber, $duplicatetitle );
936
    my ( $duplicatebiblionumber, $duplicatetitle );
937
    if ( !$is_a_modif ) {
937
    if ( !$is_a_modif ) {
Lines 1037-1050 elsif ( $op eq "delete" ) { Link Here
1037
        $biblionumber = "";
1037
        $biblionumber = "";
1038
    }
1038
    }
1039
1039
1040
    if ( $record eq -1 ) {
1041
        $record = TransformHtmlToMarc( $input );
1042
    }
1043
    else {
1040
#FIXME: it's kind of silly to go from MARC::Record to MARC::File::XML and then back again just to fix the encoding
1044
#FIXME: it's kind of silly to go from MARC::Record to MARC::File::XML and then back again just to fix the encoding
1041
    eval {
1045
        eval {
1042
        my $uxml = $record->as_xml;
1046
            my $uxml = $record->as_xml;
1043
        MARC::Record::default_record_format("UNIMARC")
1047
            MARC::Record::default_record_format("UNIMARC")
1044
          if ( C4::Context->preference("marcflavour") eq "UNIMARC" );
1048
            if ( C4::Context->preference("marcflavour") eq "UNIMARC" );
1045
        my $urecord = MARC::Record::new_from_xml( $uxml, 'UTF-8' );
1049
            my $urecord = MARC::Record::new_from_xml( $uxml, 'UTF-8' );
1046
        $record = $urecord;
1050
            $record = $urecord;
1047
    };
1051
        };
1052
    }
1048
    build_tabs( $template, $record, $dbh, $encoding,$input );
1053
    build_tabs( $template, $record, $dbh, $encoding,$input );
1049
    $template->param(
1054
    $template->param(
1050
        biblionumber             => $biblionumber,
1055
        biblionumber             => $biblionumber,
(-)a/cataloguing/merge.pl (-2 / +1 lines)
Lines 48-59 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
48
#------------------------
48
#------------------------
49
if ($merge) {
49
if ($merge) {
50
50
51
    my @params = $input->param();
52
    my $dbh = C4::Context->dbh;
51
    my $dbh = C4::Context->dbh;
53
    my $sth;
52
    my $sth;
54
53
55
    # Creating a new record from the html code
54
    # Creating a new record from the html code
56
    my $record       = TransformHtmlToMarc( \@params , $input );
55
    my $record       = TransformHtmlToMarc( $input );
57
    my $tobiblio     =  $input->param('biblio1');
56
    my $tobiblio     =  $input->param('biblio1');
58
    my $frombiblio   =  $input->param('biblio2');
57
    my $frombiblio   =  $input->param('biblio2');
59
58
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt (-5 / +4 lines)
Lines 254-262 function GetZ3950Terms(){ Link Here
254
}
254
}
255
255
256
function Changefwk(FwkList) {
256
function Changefwk(FwkList) {
257
	var fwk = FwkList.options[FwkList.selectedIndex].value;
257
    var f = document.f;
258
	window.location = "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% biblionumberdata %]&op=[% op %]&breedingid=[% breedingid %]&mode=[% popup %]&frameworkcode="+fwk;
258
    f.op.value = "";
259
259
    f.submit();
260
}
260
}
261
261
262
// returns the subfieldcode based upon subfieldid writing
262
// returns the subfieldcode based upon subfieldid writing
Lines 776-782 function unHideSubfield(index,labelindex) { // FIXME :: is it used ? Link Here
776
			<li id="savebutton"><input id="addbiblio" type="submit" value="Save" /></li>
776
			<li id="savebutton"><input id="addbiblio" type="submit" value="Save" /></li>
777
			<li id="z3950searchc"><input type="button" id="z3950search" value="Z39.50 Search" onclick="PopupZ3950(); return false;" /></li>
777
			<li id="z3950searchc"><input type="button" id="z3950search" value="Z39.50 Search" onclick="PopupZ3950(); return false;" /></li>
778
			<li id="changeframework"><label for="Frameworks">Change framework: </label>
778
			<li id="changeframework"><label for="Frameworks">Change framework: </label>
779
			<select name="Frameworks" id="Frameworks" onchange="Changefwk(this);">
779
			<select name="frameworkcode" id="Frameworks" onchange="Changefwk(this);">
780
			                <option value="Default">Default</option>
780
			                <option value="Default">Default</option>
781
							[% FOREACH frameworkcodeloo IN frameworkcodeloop %]                                             
781
							[% FOREACH frameworkcodeloo IN frameworkcodeloop %]                                             
782
                                <option value="[% frameworkcodeloo.value %]" [% frameworkcodeloo.selected %]>
782
                                <option value="[% frameworkcodeloo.value %]" [% frameworkcodeloo.selected %]>
783
- 

Return to bug 6576