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);
40 my $name = $plugin->NAME;
45 return 'AuthorityFile';
49 my $version = $plugin->VERSION;
57 =head2 get_suggestions
59 my $suggestions = $plugin->get_suggestions(\%param);
61 Return suggestions for the specified search by searching for the
62 search terms in the authority file and returning the results.
70 my $search = $param->{'search'};
72 # Remove any CCL. This does not handle CQL or PQF, which is unfortunate,
73 # but what can you do? At some point the search will have to be passed
74 # not as a string but as some sort of data structure, at which point it
75 # will be possible to support multiple search syntaxes.
77 $search =~ s/\w*[:=](\w*)/$1/g;
79 my @marclist = ['mainentry'];
82 my @operator = ['any'];
83 my @value = ["$search"];
85 # FIXME: calling into C4
86 require C4::AuthoritiesMarc;
87 my ( $searchresults, $count ) = C4::AuthoritiesMarc::SearchAuthorities(
88 \@marclist, \@and_or, \@excluding, \@operator,
89 @value, 0, $param->{'count'}, '',
94 foreach my $auth (@$searchresults) {
97 'search' => "an=$auth->{'authid'}",
98 relevance => $count--,
99 label => $auth->{summary}->{authorized}->[0]->{heading}