1 package Koha::SuggestionEngine::Plugin::AuthorityFile;
3 # Copyright 2012 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 Koha::SuggestionEngine::Plugin::AuthorityFile - get suggestions from the authority file
29 Plugin to get suggestions from Koha's authority file
37 use base qw(Koha::SuggestionEngine::Base);
38 our $NAME = 'AuthorityFile';
41 =head2 get_suggestions
43 my $suggestions = $plugin->get_suggestions(\%param);
45 Return suggestions for the specified search by searching for the
46 search terms in the authority file and returning the results.
54 my $search = $param->{'search'};
56 # Remove any CCL. This does not handle CQL or PQF, which is unfortunate,
57 # but what can you do? At some point the search will have to be passed
58 # not as a string but as some sort of data structure, at which point it
59 # will be possible to support multiple search syntaxes.
61 $search =~ s/\w*[:=](\w*)/$1/g;
63 my @marclist = ['mainentry'];
66 my @operator = ['any'];
67 my @value = ["$search"];
69 # FIXME: calling into C4
70 require C4::AuthoritiesMarc;
71 my ( $searchresults, $count ) = C4::AuthoritiesMarc::SearchAuthorities(
72 \@marclist, \@and_or, \@excluding, \@operator,
73 @value, 0, $param->{'count'}, '',
78 foreach my $auth (@$searchresults) {
81 'search' => "an=$auth->{'authid'}",
82 relevance => $count--,
83 label => $auth->{summary}->{authorized}->[0]