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

(-)a/Koha/Authority/ControlledIndicators.pm (-1 / +29 lines)
Lines 83-88 sub get { Link Here
83
            } elsif( $rule->{$ind} eq 'auth2' ) {
83
            } elsif( $rule->{$ind} eq 'auth2' ) {
84
                $result->{$ind} = $report_fld->indicator(2) if $report_fld;
84
                $result->{$ind} = $report_fld->indicator(2) if $report_fld;
85
            } elsif( $rule->{$ind} eq 'thesaurus' ) {
85
            } elsif( $rule->{$ind} eq 'thesaurus' ) {
86
                my @info = _thesaurus_info( $record );
87
                $result->{$ind} = $info[0];
88
                $result->{sub2} = $info[1];
86
            } else {
89
            } else {
87
                $result->{$ind} = substr( $rule->{$ind}, 0, 1);
90
                $result->{$ind} = substr( $rule->{$ind}, 0, 1);
88
            }
91
            }
Lines 117-122 sub _load_pref { Link Here
117
    return $res;
120
    return $res;
118
}
121
}
119
122
123
sub _thesaurus_info {
124
    # This sub is triggered by the term 'thesaurus' in the controlling pref.
125
    # The indicator of some MARC21 fields (like 600 ind2) is controlled by
126
    # authority field 008/11 and 040$f. Additionally, it may also control $2.
127
    my ( $record ) = @_;
128
    my $code = $record->field('008')
129
        ? substr($record->field('008')->data, 11, 1)
130
        : q{};
131
    my %thes_mapping = ( a => 0, b => 1, c => 2, d => 3, k => 5, n => 4, r => 7, s => 7, v => 6, z => 7, '|' => 4 );
132
    my $ind = $thes_mapping{ $code } // $code // '4';
133
134
    # Determine optional subfield $2
135
    my $sub2;
136
    if( $ind eq '7' ) {
137
        # Important now to return a defined value
138
        $sub2 = $code eq 'r'
139
            ? 'aat'
140
            : $code eq 's'
141
            ? 'sears'
142
            : $code eq 'z' # pick from 040$f
143
            ? $record->subfield( '040', 'f' ) // q{}
144
            : q{};
145
    }
146
    return ( $ind, $sub2 );
147
}
148
120
=head3 clear
149
=head3 clear
121
150
122
    Clear internal cache.
151
    Clear internal cache.
123
- 

Return to bug 14769