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.
22 C4::Linker - Base class for linking authorities to bibliographic records
26 use C4::Linker (%params );
30 Base class for C4::Linker::X. Subclasses need to provide the following methods
32 B<get_link ($field)> - return the authid for the authority that should be
33 linked to the provided MARC::Field object, and a boolean to indicate whether
34 the match is "fuzzy" (the semantics of "fuzzy" are up to the individual plugin).
35 In order to handle authority limits, get_link should always end with:
36 return $self->SUPER::_handle_auth_limit($authid), $fuzzy;
38 B<flip_heading ($field)> - return a MARC::Field object with the heading flipped
39 to the preferred form.
50 use base
qw(Class::Accessor);
52 __PACKAGE__
->mk_accessors(qw( ));
60 while ( my ( $key, $value ) = each %$param ) {
61 if ( $key eq 'auth_limit' && $value ) {
62 my $dbh = C4
::Context
->dbh;
64 "SELECT authid FROM auth_header WHERE $value ORDER BY authid ASC";
65 my $sth = $dbh->prepare($sql);
67 while ( my ($authid) = $sth->fetchrow_array() ) {
68 push @
{ $self->{'auths_to_link'} }, $authid;
71 elsif ( $key eq 'options' && $value ) {
72 foreach my $opt ( split( /\|/, $value ) ) {
77 $self->{$key} = $value;
85 =head2 _handle_auth_limit
87 return $self->SUPER::_handle_auth_limit($authid), $fuzzy;
89 Function to be called by subclasses to handle authority record limits.
93 sub _handle_auth_limit
{
97 if ( defined $self->{'auths_to_link'} && defined $authid && !grep { $_ == $authid }
98 @
{ $self->{'auths_to_link'} } )
115 Jared Camins-Esakov, C & P Bibliography Services, E<lt>jcamins@cpbibliography.comE<gt>