6 use C4::Auth qw( get_template_and_user );
7 use C4::Output qw( output_html_with_http_headers );
8 use Koha::SuggestionEngine;
9 use Module::Load::Conditional qw( can_load );
10 use JSON qw( from_json );
14 my ($template, $loggedinuser, $cookie)
15 = get_template_and_user({template_name => "admin/didyoumean.tt",
18 flagsrequired => {parameters => 'manage_didyoumean'},
21 my $opacplugins = from_json(C4::Context->preference('OPACdidyoumean') || '[]');
23 my @pluginlist = Koha::SuggestionEngine::AvailablePlugins();
24 foreach my $plugin (@pluginlist) {
25 next if $plugin eq 'Koha::SuggestionEngine::Plugin::Null';
26 next unless (can_load( modules => { "$plugin" => undef } ));
27 push @$opacplugins, { name => $plugin->NAME } unless grep { $_->{name} eq $plugin->NAME } @$opacplugins;
29 $template->{VARS}->{OPACpluginlist} = $opacplugins;
31 output_html_with_http_headers $input, $cookie, $template->output;