my @marcsubjects;
my $subject_limit = C4::Context->preference("TraceCompleteSubfields") ? 'su,complete-subfield' : 'su';
- my $authoritysep = C4::Context->preference('authoritysep');
+ my $AuthoritySeparator = C4::Context->preference('AuthoritySeparator');
foreach my $field ( $record->field($fields_filter) ) {
next unless ($field->tag() >= $mintag && $field->tag() <= $maxtag);
code => $code,
value => $value,
link_loop => \@this_link_loop,
- separator => (scalar @subfields_loop) ? $authoritysep : ''
+ separator => (scalar @subfields_loop) ? $AuthoritySeparator : ''
};
}
}
}
my @marcauthors;
- my $authoritysep = C4::Context->preference('authoritysep');
+ my $AuthoritySeparator = C4::Context->preference('AuthoritySeparator');
foreach my $field ( $record->field($fields_filter) ) {
next unless $field->tag() >= $mintag && $field->tag() <= $maxtag;
code => $code,
value => $value,
link_loop => \@this_link_loop,
- separator => (scalar @subfields_loop) ? $authoritysep : ''
+ separator => (scalar @subfields_loop) ? $AuthoritySeparator : ''
};
}
}
}
my @marcseries;
- my $authoritysep = C4::Context->preference('authoritysep');
+ my $AuthoritySeparator = C4::Context->preference('AuthoritySeparator');
foreach my $field ( $record->field($fields_filter) ) {
next unless $field->tag() >= $mintag && $field->tag() <= $maxtag;
code => $code,
value => $value,
link_loop => \@link_loop,
- separator => (scalar @subfields_loop) ? $authoritysep : '',
+ separator => (scalar @subfields_loop) ? $AuthoritySeparator : '',
volumenum => $volume_number,
}
}
my $record = MARC::Record->new();
SetMarcUnicodeFlag( $record, C4::Context->preference("marcflavour") );
my $db_to_marc = C4::Context->marcfromkohafield;
+ my $tag_hr = {};
while ( my ($name, $value) = each %$hash ) {
next unless my $dtm = $db_to_marc->{''}->{$name};
next unless ( scalar( @$dtm ) );
my ($tag, $letter) = @$dtm;
+ $tag .= '';
foreach my $value ( split(/\s?\|\s?/, $value, -1) ) {
- if ( my $field = $record->field($tag) ) {
- $field->add_subfields( $letter => $value );
- }
- else {
- $record->insert_fields_ordered( MARC::Field->new(
- $tag, " ", " ", $letter => $value ) );
- }
+ next if $value eq '';
+ $tag_hr->{$tag} //= [];
+ push @{$tag_hr->{$tag}}, [($letter, $value)];
}
-
+ }
+ foreach my $tag (sort keys %$tag_hr) {
+ my @sfl = @{$tag_hr->{$tag}};
+ @sfl = sort { $a->[0] cmp $b->[0]; } @sfl;
+ @sfl = map { @{$_}; } @sfl;
+ $record->insert_fields_ordered(
+ MARC::Field->new($tag, " ", " ", @sfl)
+ );
}
return $record;
}