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

(-)a/Koha/Filter/MARC/EmbedSeeFromHeadings.pm (-14 / +16 lines)
Lines 86-98 include in facets, sorting, or suggestion fields) Link Here
86
86
87
=cut
87
=cut
88
sub fields {
88
sub fields {
89
    my ($self, $record) = @_;
89
    my ( $self, $record ) = @_;
90
90
91
    my $params = $self->params;
91
    my $params         = $self->params;
92
    my $other_headings = $params->{options}->{other_headings} || [ 'see_from' ];
92
    my $other_headings = $params->{options}->{other_headings} || ['see_from'];
93
93
94
    my @auth_others;
94
    my @auth_others;
95
    foreach my $other_heading ( @$other_headings ) {
95
    foreach my $other_heading (@$other_headings) {
96
        if ( $other_heading eq 'see_from' ) {
96
        if ( $other_heading eq 'see_from' ) {
97
            push @auth_others, '4..';
97
            push @auth_others, '4..';
98
        }
98
        }
Lines 101-107 sub fields { Link Here
101
        }
101
        }
102
    }
102
    }
103
103
104
    my ($item_tag) = GetMarcFromKohaField( "items.itemnumber" );
104
    my ($item_tag) = GetMarcFromKohaField("items.itemnumber");
105
    $item_tag ||= '';
105
    $item_tag ||= '';
106
106
107
    my @newfields;
107
    my @newfields;
Lines 114-134 sub fields { Link Here
114
114
115
        my $authority = Koha::MetadataRecord::Authority->get_from_authid($authid);
115
        my $authority = Koha::MetadataRecord::Authority->get_from_authid($authid);
116
        next unless $authority;
116
        next unless $authority;
117
        my $auth_marc = $authority->record;
117
        my $auth_marc  = $authority->record;
118
        my @authfields = $auth_marc->field(@auth_others);
118
        my @authfields = $auth_marc->field(@auth_others);
119
        foreach my $authfield (@authfields) {
119
        foreach my $authfield (@authfields) {
120
            my $tag = substr($field->tag(), 0, 1) . substr($authfield->tag(), 1, 2);
120
            my $tag = substr( $field->tag(), 0, 1 ) . substr( $authfield->tag(), 1, 2 );
121
            next if MARC::Field->is_controlfield_tag($tag);
121
            next if MARC::Field->is_controlfield_tag($tag);
122
            my $newfield = MARC::Field->new($tag,
122
            my $newfield = MARC::Field->new(
123
                    'z',
123
                $tag,
124
                    $authfield->indicator(2) || ' ',
124
                'z',
125
                    '9' => '1');
125
                $authfield->indicator(2) || ' ',
126
            foreach my $sub ($authfield->subfields()) {
126
                '9' => '1'
127
                my ($code,$val) = @$sub;
127
            );
128
            foreach my $sub ( $authfield->subfields() ) {
129
                my ( $code, $val ) = @$sub;
128
                $newfield->add_subfields( $code => $val );
130
                $newfield->add_subfields( $code => $val );
129
            }
131
            }
130
            $newfield->delete_subfield( code => '9' );
132
            $newfield->delete_subfield( code => '9' );
131
            push @newfields, $newfield if (scalar($newfield->subfields()) > 0);
133
            push @newfields, $newfield if ( scalar( $newfield->subfields() ) > 0 );
132
        }
134
        }
133
    }
135
    }
134
136
(-)a/Koha/SearchEngine/Elasticsearch.pm (-23 / +33 lines)
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
                            }
(-)a/misc/migration_tools/rebuild_zebra.pl (-5 / +4 lines)
Lines 662-668 sub get_corrected_marc_record { Link Here
662
            my @filters;
662
            my @filters;
663
            my @other_headings;
663
            my @other_headings;
664
            push @filters, 'EmbedItemsAvailability';
664
            push @filters, 'EmbedItemsAvailability';
665
            if ( C4::Context->preference('IncludeSeeFromInSearches') || C4::Context->preference('IncludeSeeAlsoFromInSearches') ){
665
            if (   C4::Context->preference('IncludeSeeFromInSearches')
666
                || C4::Context->preference('IncludeSeeAlsoFromInSearches') )
667
            {
666
                push @filters, 'EmbedSeeFromHeadings';
668
                push @filters, 'EmbedSeeFromHeadings';
667
                if ( C4::Context->preference('IncludeSeeFromInSearches') ) {
669
                if ( C4::Context->preference('IncludeSeeFromInSearches') ) {
668
                    push @other_headings, 'see_from';
670
                    push @other_headings, 'see_from';
Lines 675-683 sub get_corrected_marc_record { Link Here
675
            my $normalizer = Koha::RecordProcessor->new(
677
            my $normalizer = Koha::RecordProcessor->new(
676
                {
678
                {
677
                    filters => \@filters,
679
                    filters => \@filters,
678
                    options => {
680
                    options => { other_headings => \@other_headings }
679
                        other_headings => \@other_headings
680
                    }
681
                }
681
                }
682
            );
682
            );
683
            $marc = $normalizer->process($marc);
683
            $marc = $normalizer->process($marc);
684
- 

Return to bug 34481