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
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 Koha::SuggestionEngine::Plugin::AuthorityFile - get suggestions from the authority file
29 Plugin to get suggestions from Koha's authority file
35 use base qw(Koha::SuggestionEngine::Base);
38 my $name = $plugin->NAME;
43 return 'AuthorityFile';
47 my $version = $plugin->VERSION;
55 =head2 get_suggestions
57 my $suggestions = $plugin->get_suggestions(\%param);
59 Return suggestions for the specified search by searching for the
60 search terms in the authority file and returning the results.
68 my $search = $param->{'search'};
70 # Remove any CCL. This does not handle CQL or PQF, which is unfortunate,
71 # but what can you do? At some point the search will have to be passed
72 # not as a string but as some sort of data structure, at which point it
73 # will be possible to support multiple search syntaxes.
75 $search =~ s/\w*[:=](\w*)/$1/g;
77 my @marclist = ['mainentry'];
80 my @operator = ['any'];
81 my @value = ["$search"];
83 # FIXME: calling into C4
84 require C4::AuthoritiesMarc;
85 my ( $searchresults, $count ) = C4::AuthoritiesMarc::SearchAuthorities(
86 @marclist, @and_or, @excluding, @operator,
87 @value, 0, $param->{'count'}, '',
92 foreach my $auth (@$searchresults) {
95 'search' => "an:$auth->{'authid'}",
96 relevance => $count--,
97 label => $auth->{summary}->{authorized}->[0]->{heading}