1 package C4
::Linker
::Default
;
3 # Copyright 2011 C & P Bibliography Services
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 use base
qw(C4::Linker);
31 my $behavior = shift || 'default';
32 my $search_form = $heading->search_form();
36 if ( $self->{'cache'}->{$search_form}->{'cached'} ) {
37 $authid = $self->{'cache'}->{$search_form}->{'authid'};
38 $fuzzy = $self->{'cache'}->{$search_form}->{'fuzzy'};
42 # look for matching authorities
43 my $authorities = $heading->authorities(1); # $skipmetadata = true
45 if ( $behavior eq 'default' && $#{$authorities} == 0 ) {
46 $authid = $authorities->[0]->{'authid'};
48 elsif ( $behavior eq 'first' && $#{$authorities} >= 0 ) {
49 $authid = $authorities->[0]->{'authid'};
50 $fuzzy = $#{$authorities} > 0;
52 elsif ( $behavior eq 'last' && $#{$authorities} >= 0 ) {
53 $authid = $authorities->[ $#{$authorities} ]->{'authid'};
54 $fuzzy = $#{$authorities} > 0;
57 if ( !defined $authid && $self->{'broader_headings'} ) {
58 my $field = $heading->field();
59 my @subfields = grep { $_->[0] ne '9' } $field->subfields();
60 if ( scalar @subfields > 1 ) {
67 map { $_->[0] => $_->[1] } @subfields
70 $self->get_link( C4
::Heading
->new_from_bib_field($field),
75 $self->{'cache'}->{$search_form}->{'cached'} = 1;
76 $self->{'cache'}->{$search_form}->{'authid'} = $authid;
77 $self->{'cache'}->{$search_form}->{'fuzzy'} = $fuzzy;
79 return $self->SUPER::_handle_auth_limit
($authid), $fuzzy;
94 C4::Linker::Default - match only if there is a single matching auth