|
Lines 1079-1091
sub GetUsedMarcStructure {
Link Here
|
| 1079 |
=cut |
1079 |
=cut |
| 1080 |
|
1080 |
|
| 1081 |
sub GetMarcSubfieldStructure { |
1081 |
sub GetMarcSubfieldStructure { |
| 1082 |
my ( $frameworkcode ) = @_; |
1082 |
my ( $frameworkcode, $params ) = @_; |
| 1083 |
|
1083 |
|
| 1084 |
$frameworkcode //= ''; |
1084 |
$frameworkcode //= ''; |
| 1085 |
|
1085 |
|
| 1086 |
my $cache = Koha::Caches->get_instance(); |
1086 |
my $cache = Koha::Caches->get_instance(); |
| 1087 |
my $cache_key = "MarcSubfieldStructure-$frameworkcode"; |
1087 |
my $cache_key = "MarcSubfieldStructure-$frameworkcode"; |
| 1088 |
my $cached = $cache->get_from_cache($cache_key); |
1088 |
my $cached = $cache->get_from_cache($cache_key, { unsafe => ($params && $params->{unsafe}) }); |
| 1089 |
return $cached if $cached; |
1089 |
return $cached if $cached; |
| 1090 |
|
1090 |
|
| 1091 |
my $dbh = C4::Context->dbh; |
1091 |
my $dbh = C4::Context->dbh; |
|
Lines 1129-1135
sub GetMarcFromKohaField {
Link Here
|
| 1129 |
return unless $kohafield; |
1129 |
return unless $kohafield; |
| 1130 |
# The next call uses the Default framework since it is AUTHORITATIVE |
1130 |
# The next call uses the Default framework since it is AUTHORITATIVE |
| 1131 |
# for all Koha to MARC mappings. |
1131 |
# for all Koha to MARC mappings. |
| 1132 |
my $mss = GetMarcSubfieldStructure( '' ); # Do not change framework |
1132 |
my $mss = GetMarcSubfieldStructure( '', { unsafe => 1 } ); # Do not change framework |
| 1133 |
my @retval; |
1133 |
my @retval; |
| 1134 |
foreach( @{ $mss->{$kohafield} } ) { |
1134 |
foreach( @{ $mss->{$kohafield} } ) { |
| 1135 |
push @retval, $_->{tagfield}, $_->{tagsubfield}; |
1135 |
push @retval, $_->{tagfield}, $_->{tagsubfield}; |
|
Lines 1156-1162
sub GetMarcSubfieldStructureFromKohaField {
Link Here
|
| 1156 |
|
1156 |
|
| 1157 |
# The next call uses the Default framework since it is AUTHORITATIVE |
1157 |
# The next call uses the Default framework since it is AUTHORITATIVE |
| 1158 |
# for all Koha to MARC mappings. |
1158 |
# for all Koha to MARC mappings. |
| 1159 |
my $mss = GetMarcSubfieldStructure(''); # Do not change framework |
1159 |
my $mss = GetMarcSubfieldStructure( '', { unsafe => 1 } ); # Do not change framework |
| 1160 |
return unless $mss->{$kohafield}; |
1160 |
return unless $mss->{$kohafield}; |
| 1161 |
return wantarray ? @{$mss->{$kohafield}} : $mss->{$kohafield}->[0]; |
1161 |
return wantarray ? @{$mss->{$kohafield}} : $mss->{$kohafield}->[0]; |
| 1162 |
} |
1162 |
} |
|
Lines 2188-2194
sub TransformKohaToMarc {
Link Here
|
| 2188 |
|
2188 |
|
| 2189 |
# In the next call we use the Default framework, since it is considered |
2189 |
# In the next call we use the Default framework, since it is considered |
| 2190 |
# authoritative for Koha to Marc mappings. |
2190 |
# authoritative for Koha to Marc mappings. |
| 2191 |
my $mss = GetMarcSubfieldStructure( '' ); # do not change framework |
2191 |
my $mss = GetMarcSubfieldStructure( '', { unsafe => 1 } ); # do not change framewok |
| 2192 |
my $tag_hr = {}; |
2192 |
my $tag_hr = {}; |
| 2193 |
while ( my ($kohafield, $value) = each %$hash ) { |
2193 |
while ( my ($kohafield, $value) = each %$hash ) { |
| 2194 |
foreach my $fld ( @{ $mss->{$kohafield} } ) { |
2194 |
foreach my $fld ( @{ $mss->{$kohafield} } ) { |
|
Lines 2601-2607
sub TransformMarcToKoha {
Link Here
|
| 2601 |
|
2601 |
|
| 2602 |
# The next call acknowledges Default as the authoritative framework |
2602 |
# The next call acknowledges Default as the authoritative framework |
| 2603 |
# for Koha to MARC mappings. |
2603 |
# for Koha to MARC mappings. |
| 2604 |
my $mss = GetMarcSubfieldStructure(''); # Do not change framework |
2604 |
my $mss = GetMarcSubfieldStructure( '', { unsafe => 1 } ); # Do not change framework |
| 2605 |
foreach my $kohafield ( keys %{ $mss } ) { |
2605 |
foreach my $kohafield ( keys %{ $mss } ) { |
| 2606 |
my ( $table, $column ) = split /[.]/, $kohafield, 2; |
2606 |
my ( $table, $column ) = split /[.]/, $kohafield, 2; |
| 2607 |
next unless $tables{$table}; |
2607 |
next unless $tables{$table}; |
| 2608 |
- |
|
|