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