|
Lines 664-670
sub marc_records_to_documents {
Link Here
|
| 664 |
} |
664 |
} |
| 665 |
} |
665 |
} |
| 666 |
|
666 |
|
| 667 |
if ( $self->index eq $BIBLIOS_INDEX and ( C4::Context->preference('IncludeSeeFromInSearches') || C4::Context->preference('IncludeSeeAlsoFromInSearches') ) ) { |
667 |
if ( |
|
|
668 |
$self->index eq $BIBLIOS_INDEX |
| 669 |
and ( C4::Context->preference('IncludeSeeFromInSearches') |
| 670 |
|| C4::Context->preference('IncludeSeeAlsoFromInSearches') ) |
| 671 |
) |
| 672 |
{ |
| 668 |
my $marc_filter = Koha::Filter::MARC::EmbedSeeFromHeadings->new; |
673 |
my $marc_filter = Koha::Filter::MARC::EmbedSeeFromHeadings->new; |
| 669 |
my @other_headings; |
674 |
my @other_headings; |
| 670 |
if ( C4::Context->preference('IncludeSeeFromInSearches') ) { |
675 |
if ( C4::Context->preference('IncludeSeeFromInSearches') ) { |
|
Lines 673-702
sub marc_records_to_documents {
Link Here
|
| 673 |
if ( C4::Context->preference('IncludeSeeAlsoFromInSearches') ) { |
678 |
if ( C4::Context->preference('IncludeSeeAlsoFromInSearches') ) { |
| 674 |
push @other_headings, 'see_also_from'; |
679 |
push @other_headings, 'see_also_from'; |
| 675 |
} |
680 |
} |
| 676 |
$marc_filter->initialize( |
681 |
$marc_filter->initialize( { options => { other_headings => \@other_headings } } ); |
| 677 |
{ |
682 |
foreach my $field ( $marc_filter->fields($record) ) { |
| 678 |
options => { |
683 |
my $data_field_rules = $data_fields_rules->{ $field->tag() }; |
| 679 |
other_headings => \@other_headings |
|
|
| 680 |
} |
| 681 |
} |
| 682 |
); |
| 683 |
foreach my $field ($marc_filter->fields($record)) { |
| 684 |
my $data_field_rules = $data_fields_rules->{$field->tag()}; |
| 685 |
if ($data_field_rules) { |
684 |
if ($data_field_rules) { |
| 686 |
my $subfields_mappings = $data_field_rules->{subfields}; |
685 |
my $subfields_mappings = $data_field_rules->{subfields}; |
| 687 |
my $wildcard_mappings = $subfields_mappings->{'*'}; |
686 |
my $wildcard_mappings = $subfields_mappings->{'*'}; |
| 688 |
foreach my $subfield ($field->subfields()) { |
687 |
foreach my $subfield ( $field->subfields() ) { |
| 689 |
my ($code, $data) = @{$subfield}; |
688 |
my ( $code, $data ) = @{$subfield}; |
| 690 |
my @mappings; |
689 |
my @mappings; |
| 691 |
push @mappings, @{ $subfields_mappings->{$code} } if $subfields_mappings->{$code}; |
690 |
push @mappings, @{ $subfields_mappings->{$code} } if $subfields_mappings->{$code}; |
| 692 |
push @mappings, @$wildcard_mappings if $wildcard_mappings; |
691 |
push @mappings, @$wildcard_mappings if $wildcard_mappings; |
|
|
692 |
|
| 693 |
# Do not include "see from" into these kind of fields |
693 |
# Do not include "see from" into these kind of fields |
| 694 |
@mappings = grep { $_->[0] !~ /__(sort|facet|suggestion)$/ } @mappings; |
694 |
@mappings = grep { $_->[0] !~ /__(sort|facet|suggestion)$/ } @mappings; |
| 695 |
if (@mappings) { |
695 |
if (@mappings) { |
| 696 |
$self->_process_mappings(\@mappings, $data, $record_document, { |
696 |
$self->_process_mappings( |
|
|
697 |
\@mappings, |
| 698 |
$data, |
| 699 |
$record_document, |
| 700 |
{ |
| 697 |
data_source => 'subfield', |
701 |
data_source => 'subfield', |
| 698 |
code => $code, |
702 |
code => $code, |
| 699 |
field => $field |
703 |
field => $field |
| 700 |
} |
704 |
} |
| 701 |
); |
705 |
); |
| 702 |
} |
706 |
} |
|
Lines 704-722
sub marc_records_to_documents {
Link Here
|
| 704 |
|
708 |
|
| 705 |
my $subfields_join_mappings = $data_field_rules->{subfields_join}; |
709 |
my $subfields_join_mappings = $data_field_rules->{subfields_join}; |
| 706 |
if ($subfields_join_mappings) { |
710 |
if ($subfields_join_mappings) { |
| 707 |
foreach my $subfields_group (keys %{$subfields_join_mappings}) { |
711 |
foreach my $subfields_group ( keys %{$subfields_join_mappings} ) { |
| 708 |
my $data_field = $field->clone; |
712 |
my $data_field = $field->clone; |
|
|
713 |
|
| 709 |
# remove empty subfields, otherwise they are printed as a space |
714 |
# remove empty subfields, otherwise they are printed as a space |
| 710 |
$data_field->delete_subfield(match => qr/^$/); |
715 |
$data_field->delete_subfield( match => qr/^$/ ); |
| 711 |
my $data = $data_field->as_string( $subfields_group ); |
716 |
my $data = $data_field->as_string($subfields_group); |
| 712 |
if ($data) { |
717 |
if ($data) { |
| 713 |
my @mappings = @{ $subfields_join_mappings->{$subfields_group} }; |
718 |
my @mappings = @{ $subfields_join_mappings->{$subfields_group} }; |
|
|
719 |
|
| 714 |
# Do not include "see from" into these kind of fields |
720 |
# Do not include "see from" into these kind of fields |
| 715 |
@mappings = grep { $_->[0] !~ /__(sort|facet|suggestion)$/ } @mappings; |
721 |
@mappings = grep { $_->[0] !~ /__(sort|facet|suggestion)$/ } @mappings; |
| 716 |
$self->_process_mappings(\@mappings, $data, $record_document, { |
722 |
$self->_process_mappings( |
|
|
723 |
\@mappings, |
| 724 |
$data, |
| 725 |
$record_document, |
| 726 |
{ |
| 717 |
data_source => 'subfields_group', |
727 |
data_source => 'subfields_group', |
| 718 |
codes => $subfields_group, |
728 |
codes => $subfields_group, |
| 719 |
field => $field |
729 |
field => $field |
| 720 |
} |
730 |
} |
| 721 |
); |
731 |
); |
| 722 |
} |
732 |
} |