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

(-)a/C4/Biblio.pm (-15 / +9 lines)
Lines 1991-1999 sub TransformKohaToMarc { Link Here
1991
    # In the next call we use the Default framework, since it is considered
1991
    # In the next call we use the Default framework, since it is considered
1992
    # authoritative for Koha to Marc mappings.
1992
    # authoritative for Koha to Marc mappings.
1993
    my $mss = GetMarcSubfieldStructure( '', { unsafe => 1 } ); # do not change framework
1993
    my $mss = GetMarcSubfieldStructure( '', { unsafe => 1 } ); # do not change framework
1994
    my $mss2; # belongs to $params->{framework} only filled when needed
1995
    my $tag_hr = {};
1994
    my $tag_hr = {};
1996
    my $need_split;
1997
    while ( my ($kohafield, $value) = each %$hash ) {
1995
    while ( my ($kohafield, $value) = each %$hash ) {
1998
        foreach my $fld ( @{ $mss->{$kohafield} } ) {
1996
        foreach my $fld ( @{ $mss->{$kohafield} } ) {
1999
            my $tagfield    = $fld->{tagfield};
1997
            my $tagfield    = $fld->{tagfield};
Lines 2001-2007 sub TransformKohaToMarc { Link Here
2001
            next if !$tagfield;
1999
            next if !$tagfield;
2002
2000
2003
            # BZ 21800: split value if field is repeatable.
2001
            # BZ 21800: split value if field is repeatable.
2004
            ( $need_split, $mss2 ) = _check_split($params, $mss2, $fld, $value);
2002
            my $need_split = _check_split($params, $fld, $value);
2005
            my @values = $need_split
2003
            my @values = $need_split
2006
                ? split(/\s?\|\s?/, $value, -1)
2004
                ? split(/\s?\|\s?/, $value, -1)
2007
                : ( $value );
2005
                : ( $value );
Lines 2027-2050 sub TransformKohaToMarc { Link Here
2027
2025
2028
sub _check_split {
2026
sub _check_split {
2029
# Checks if $value must be split; may consult passed framework
2027
# Checks if $value must be split; may consult passed framework
2030
# Returns 0|1, and framework hash if consulted
2028
    my ($params, $fld, $value) = @_;
2031
    my ($params, $mss2, $fld, $value) = @_;
2029
    return if index($value,'|') == -1; # nothing to worry about
2032
    return (0, $mss2) if index($value,'|') == -1; # nothing to worry about
2030
    return if $params->{no_split};
2033
    return (0, $mss2) if $params->{no_split};
2034
2031
2035
    # if we did not get a specific framework, check default in $mss
2032
    # if we did not get a specific framework, check default in $mss
2036
    return ( $fld->{repeatable}, $mss2) if !$params->{framework};
2033
    return $fld->{repeatable} if !$params->{framework};
2037
2034
2038
    # here we need to check the specific framework
2035
    # here we need to check the specific framework
2039
    if(!$mss2) {
2036
    my $mss = GetMarcSubfieldStructure($params->{framework}, { unsafe => 1 });
2040
        $mss2 = GetMarcSubfieldStructure($params->{framework}, { unsafe => 1 });
2037
    foreach my $fld2 ( @{ $mss->{ $fld->{kohafield} } } ) {
2041
    }
2042
    foreach my $fld2 ( @{ $mss2->{ $fld->{kohafield} } } ) {
2043
        next if $fld2->{tagfield} ne $fld->{tagfield};
2038
        next if $fld2->{tagfield} ne $fld->{tagfield};
2044
        next if $fld2->{tagsubfield} ne $fld->{tagsubfield};
2039
        next if $fld2->{tagsubfield} ne $fld->{tagsubfield};
2045
        return (1, $mss2) if $fld2->{repeatable};
2040
        return 1 if $fld2->{repeatable};
2046
    }
2041
    }
2047
    return (0, $mss2);
2042
    return;
2048
}
2043
}
2049
2044
2050
=head2 PrepHostMarcField
2045
=head2 PrepHostMarcField
2051
- 

Return to bug 24715