View | Details | Raw Unified | Return to bug 8726
Collapse All | Expand All

(-)a/Koha/SuggestionEngine.pm (-2 / +5 lines)
Lines 87-93 sub new { Link Here
87
    my $options = $param->{options} || '';
87
    my $options = $param->{options} || '';
88
    my @plugins = ();
88
    my @plugins = ();
89
89
90
    foreach my $plugin ( $param->{plugins} ) {
90
    foreach my $plugin ( @{$param->{plugins}} ) {
91
        next unless $plugin;
91
        next unless $plugin;
92
        my $plugin_module =
92
        my $plugin_module =
93
            $plugin =~ m/:/
93
            $plugin =~ m/:/
Lines 141-155 sub get_suggestions { Link Here
141
141
142
    my %suggestions;
142
    my %suggestions;
143
143
144
    my $index = scalar @{ $self->plugins };
145
144
    foreach my $pluginobj ( @{ $self->plugins } ) {
146
    foreach my $pluginobj ( @{ $self->plugins } ) {
145
        next unless $pluginobj;
147
        next unless $pluginobj;
146
        my $pluginres = $pluginobj->get_suggestions($param);
148
        my $pluginres = $pluginobj->get_suggestions($param);
147
        foreach my $suggestion (@$pluginres) {
149
        foreach my $suggestion (@$pluginres) {
148
            $suggestions{ $suggestion->{'search'} }->{'relevance'} +=
150
            $suggestions{ $suggestion->{'search'} }->{'relevance'} +=
149
              $suggestion->{'relevance'};
151
              $suggestion->{'relevance'} * $index;
150
            $suggestions{ $suggestion->{'search'} }->{'label'} |=
152
            $suggestions{ $suggestion->{'search'} }->{'label'} |=
151
              $suggestion->{'label'};
153
              $suggestion->{'label'};
152
        }
154
        }
155
        $index--;
153
    }
156
    }
154
157
155
    my @results = ();
158
    my @results = ();
(-)a/Koha/SuggestionEngine/Base.pm (-2 / +42 lines)
Lines 60-67 use base qw(Class::Accessor); Link Here
60
60
61
__PACKAGE__->mk_ro_accessors(qw( name version ));
61
__PACKAGE__->mk_ro_accessors(qw( name version ));
62
__PACKAGE__->mk_accessors(qw( params ));
62
__PACKAGE__->mk_accessors(qw( params ));
63
our $NAME    = 'Base';
64
our $VERSION = '1.0';
65
63
66
=head2 new
64
=head2 new
67
65
Lines 125-128 sub get_suggestions { Link Here
125
    return;
123
    return;
126
}
124
}
127
125
126
=head2 NAME
127
128
    my $name = $plugin->NAME;
129
130
Getter function for plugin names.
131
132
=cut
133
134
sub NAME {
135
    my $self = shift;
136
    my $package = ref $self || $self;
137
    return eval '$' . $package . '::NAME';
138
}
139
140
=head2 VERSION
141
142
    my $version = $plugin->VERSION;
143
144
Getter function for plugin versions.
145
146
=cut
147
148
sub VERSION {
149
    my $self = shift;
150
    my $package = ref $self || $self;
151
    return eval '$' . $package . '::VERSION';
152
}
153
154
=head2 DESCRIPTION
155
156
    my $description = $plugin->DESCRIPTION;
157
158
Getter function for plugin descriptions.
159
160
=cut
161
162
sub DESCRIPTION {
163
    my $self = shift;
164
    my $package = ref $self || $self;
165
    return eval '$' . $package . '::DESCRIPTION';
166
}
167
128
1;
168
1;
(-)a/Koha/SuggestionEngine/Plugin/ExplodedTerms.pm (+87 lines)
Line 0 Link Here
1
package Koha::SuggestionEngine::Plugin::ExplodedTerms;
2
3
# Copyright 2012 C & P Bibliography Services
4
#
5
# This file is part of Koha.
6
#
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
10
# version.
11
#
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.
15
#
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.
19
20
=head1 NAME
21
22
Koha::SuggestionEngine::Plugin::ExplodedTerms - suggest searches for broader/narrower/related subjects
23
24
=head1 SYNOPSIS
25
26
27
=head1 DESCRIPTION
28
29
Plugin to suggest expanding the search by adding broader/narrower/related
30
subjects to subject searches.
31
32
=cut
33
34
use strict;
35
use warnings;
36
use Carp;
37
use C4::Templates qw(gettemplate); # This is necessary for translatability
38
39
use base qw(Koha::SuggestionEngine::Base);
40
our $NAME    = 'ExplodedTerms';
41
our $VERSION = '1.0';
42
43
=head2 get_suggestions
44
45
    my $suggestions = $plugin->get_suggestions(\%param);
46
47
Return suggestions for the specified search that add broader/narrower/related
48
terms to the search.
49
50
=cut
51
52
sub get_suggestions {
53
    my $self  = shift;
54
    my $param = shift;
55
56
    my $search = $param->{'search'};
57
58
    return if ( $search =~ m/^(ccl=|cql=|pqf=)/ );
59
    $search =~ s/(su|su-br|su-na|su-rl)[:=](\w*)/OP!$2/g;
60
    return if ( $search =~ m/\w+[:=]\w+/ );
61
62
    my @indexes = (
63
        'su-na',
64
        'su-br',
65
        'su-rl'
66
    );
67
    my $cgi = new CGI;
68
    my $template = C4::Templates::gettemplate('text/explodedterms.tt', 'opac', $cgi);
69
    my @results;
70
    foreach my $index (@indexes) {
71
        my $thissearch = $search;
72
        $thissearch = "$index=$thissearch"
73
          unless ( $thissearch =~ s/OP!/$index=/g );
74
        $template->{VARS}->{index} = $index;
75
        my $label = pack("U0a*", $template->output); #FIXME: C4::Templates is
76
        # returning incorrectly-marked UTF-8. This fixes the problem, but is
77
        # an annoying workaround.
78
        push @results,
79
        {
80
            'search'  => $thissearch,
81
            relevance => 100,
82
                # FIXME: it'd be nice to have some empirical measure of
83
                #        "relevance" in this case, but we don't.
84
            label => $label
85
        };
86
    } return \@results;
87
}
(-)a/admin/didyoumean.pl (+37 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
use strict;
4
use warnings;
5
use CGI;
6
use C4::Context;
7
use C4::Auth;
8
use C4::Output;
9
use Koha::SuggestionEngine;
10
use Module::Load::Conditional qw(can_load);
11
use JSON;
12
13
my $input = new CGI;
14
15
my ($template, $loggedinuser, $cookie)
16
    = get_template_and_user({template_name => "admin/didyoumean.tt",
17
            query => $input,
18
            type => "intranet",
19
            authnotrequired => 0,
20
            flagsrequired => {parameters => 'parameters_remaining_permissions'},
21
            debug => 1,
22
            });
23
24
my $opacplugins = from_json(C4::Context->preference('OPACdidyoumean') || '[]');
25
26
my $intraplugins = from_json(C4::Context->preference('INTRAdidyoumean') || '[]');
27
28
my @pluginlist = Koha::SuggestionEngine::AvailablePlugins();
29
foreach my $plugin (@pluginlist) {
30
    next if $plugin eq 'Koha::SuggestionEngine::Plugin::Null';
31
    next unless (can_load( modules => { "$plugin" => undef } ));
32
    push @$opacplugins, { name => $plugin->NAME } unless grep { $_->{name} eq $plugin->NAME } @$opacplugins;
33
    push @$intraplugins, { name => $plugin->NAME } unless grep { $_->{name} eq $plugin->NAME } @$intraplugins;
34
}
35
$template->{VARS}->{OPACpluginlist} = $opacplugins;
36
$template->{VARS}->{INTRApluginlist} = $intraplugins;
37
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/installer/data/mysql/sysprefs.sql (-1 / +2 lines)
Lines 376-384 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' Link Here
376
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SubfieldsToUseWhenPrefill','','Define a list of subfields to use when prefilling items (separated by space)','','Free');
376
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SubfieldsToUseWhenPrefill','','Define a list of subfields to use when prefilling items (separated by space)','','Free');
377
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionMarker','','Markers for age restriction indication, e.g. FSK|PEGI|Age|',NULL,'free');
377
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionMarker','','Markers for age restriction indication, e.g. FSK|PEGI|Age|',NULL,'free');
378
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionOverride',0,'Allow staff to check out an item with age restriction.',NULL,'YesNo');
378
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('AgeRestrictionOverride',0,'Allow staff to check out an item with age restriction.',NULL,'YesNo');
379
INSERT INTO systempreferences (variable,value,explanation,type) VALUES('DidYouMeanFromAuthorities','0','Suggest searches based on authority file.','YesNo');
380
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('IncludeSeeFromInSearches','0','','Include see-from references in searches.','YesNo');
379
INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('IncludeSeeFromInSearches','0','','Include see-from references in searches.','YesNo');
381
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OPACMobileUserCSS','','Include the following CSS for the mobile view on all pages in the OPAC:',NULL,'free');
380
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OPACMobileUserCSS','','Include the following CSS for the mobile view on all pages in the OPAC:',NULL,'free');
382
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacMainUserBlockMobile','','Show the following HTML in its own column on the main page of the OPAC (mobile version):',NULL,'free');
381
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacMainUserBlockMobile','','Show the following HTML in its own column on the main page of the OPAC (mobile version):',NULL,'free');
383
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacShowLibrariesPulldownMobile','1','Show the libraries pulldown on the mobile version of the OPAC.',NULL,'YesNo');
382
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacShowLibrariesPulldownMobile','1','Show the libraries pulldown on the mobile version of the OPAC.',NULL,'YesNo');
384
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacShowFiltersPulldownMobile','1','Show the search filters pulldown on the mobile version of the OPAC.',NULL,'YesNo');
383
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacShowFiltersPulldownMobile','1','Show the search filters pulldown on the mobile version of the OPAC.',NULL,'YesNo');
384
INSERT INTO systempreferences (variable,value,explanation,type) VALUES('OPACdidyoumean',NULL,'Did you mean? configuration for the OPAC. Do not change, as this is controlled by /cgi-bin/koha/admin/didyoumean.pl.','Free');
385
INSERT INTO systempreferences (variable,value,explanation,type) VALUES('INTRAdidyoumean',NULL,'Did you mean? configuration for the Intranet. Do not change, as this is controlled by /cgi-bin/koha/admin/didyoumean.pl.','Free');
(-)a/installer/data/mysql/updatedatabase.pl (-1 / +9 lines)
Lines 5769-5775 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
5769
    SetVersion($DBversion);
5769
    SetVersion($DBversion);
5770
}
5770
}
5771
5771
5772
5773
$DBversion = '3.09.00.044';
5772
$DBversion = '3.09.00.044';
5774
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5773
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
5775
    $dbh->do("ALTER TABLE statistics ADD COLUMN ccode VARCHAR ( 10 ) NULL AFTER associatedborrower");
5774
    $dbh->do("ALTER TABLE statistics ADD COLUMN ccode VARCHAR ( 10 ) NULL AFTER associatedborrower");
Lines 5953-5958 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
5953
}
5952
}
5954
5953
5955
5954
5955
$DBversion ="3.09.00.XXX";
5956
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
5957
    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,type) VALUES('OPACdidyoumean',NULL,'Did you mean? configuration for the OPAC. Do not change, as this is controlled by /cgi-bin/koha/admin/didyoumean.pl.','Free');");
5958
    $dbh->do("INSERT INTO systempreferences (variable,value,explanation,type) VALUES('INTRAdidyoumean',NULL,'Did you mean? configuration for the Intranet. Do not change, as this is controlled by /cgi-bin/koha/admin/didyoumean.pl.','Free');");
5959
    print "Upgrade to $DBversion done (Add Did You Mean? configuration)\n";
5960
    SetVersion($DBversion);
5961
}
5962
5963
5956
=head1 FUNCTIONS
5964
=head1 FUNCTIONS
5957
5965
5958
=head2 TableExists($table)
5966
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css (+36 lines)
Lines 2424-2429 ul.ui-tabs-nav li { Link Here
2424
    display: inline;
2424
    display: inline;
2425
}
2425
}
2426
2426
2427
#didyoumeanopac, #didyoumeanintranet {
2428
    float: left;
2429
    width: 260px;
2430
}
2431
2432
#didyoumeanlegend {
2433
    float: right;
2434
}
2435
2436
.pluginlist {
2437
    padding-bottom: 10px;
2438
}
2439
.plugin {
2440
    margin: 0 1em 1em 0;
2441
}
2442
.pluginname {
2443
    margin: 0.3em;
2444
    padding-bottom: 4px;
2445
    padding-left: 0.2em;
2446
    background-color: #E6F0F2;
2447
}
2448
.pluginname .ui-icon {
2449
    float: right;
2450
}
2451
.plugindesc {
2452
    padding: 0.4em;
2453
}
2454
.ui-sortable-placeholder {
2455
    border: 1px dotted black;
2456
    visibility: visible !important;
2457
    height: 80px !important;
2458
}
2459
.ui-sortable-placeholder * {
2460
    visibility: hidden;
2461
}
2462
2427
/* jQuery UI Datepicker */
2463
/* jQuery UI Datepicker */
2428
.ui-datepicker table {
2464
.ui-datepicker table {
2429
    width: 100%;
2465
    width: 100%;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc (+1 lines)
Lines 62-67 Link Here
62
    [% IF ( NoZebra ) %]<li><a href="/cgi-bin/koha/admin/stopwords.pl">Stop words</a></li>[% END %]
62
    [% IF ( NoZebra ) %]<li><a href="/cgi-bin/koha/admin/stopwords.pl">Stop words</a></li>[% END %]
63
	<!-- <li><a href="/cgi-bin/koha/admin/printers.pl">Network Printers</a></li> -->
63
	<!-- <li><a href="/cgi-bin/koha/admin/printers.pl">Network Printers</a></li> -->
64
    <li><a href="/cgi-bin/koha/admin/z3950servers.pl">Z39.50 client targets</a></li>
64
    <li><a href="/cgi-bin/koha/admin/z3950servers.pl">Z39.50 client targets</a></li>
65
    <li><a href="/cgi-bin/koha/admin/didyoumean.pl">Did you mean?</a></li>
65
</ul>
66
</ul>
66
</div>
67
</div>
67
</div>
68
</div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt (+2 lines)
Lines 107-112 Link Here
107
	<dd>Printers (UNIX paths).</dd> -->
107
	<dd>Printers (UNIX paths).</dd> -->
108
    <dt><a href="/cgi-bin/koha/admin/z3950servers.pl">Z39.50 client targets</a></dt>
108
    <dt><a href="/cgi-bin/koha/admin/z3950servers.pl">Z39.50 client targets</a></dt>
109
	<dd>Define which servers to query for MARC data in the integrated Z39.50 client.</dd>
109
	<dd>Define which servers to query for MARC data in the integrated Z39.50 client.</dd>
110
    <dt><a href="/cgi-bin/koha/admin/didyoumean.pl">Did you mean?</a></dt>
111
    <dd>Choose which plugins to use to suggest searches to patrons and staff.</dd>
110
</dl>
112
</dl>
111
</div>
113
</div>
112
114
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/didyoumean.tt (+104 lines)
Line 0 Link Here
1
[% BLOCK pluginlist %]
2
<div class="pluginlist">
3
[% FOREACH plugin IN plugins %]
4
    <div class="plugin">
5
        <div class="pluginname">
6
            [% IF plugin.enabled %]<input type="checkbox" checked="checked" id="checkbox_[% plugin.name %]">[% ELSE %]<input type="checkbox" id="checkbox_[% plugin.name %]">[% END %]
7
            <label class='pluginlabel' for="checkbox_[% plugin.name %]">[% plugin.name %]</label></div>
8
        <div class="plugindesc">
9
        [% SWITCH plugin.name %]
10
        [% CASE 'AuthorityFile' %]
11
            Suggest authorities which are relevant to the term the user searched for.
12
        [% CASE 'ExplodedTerms' %]
13
            Suggest that patrons expand their searches to include
14
            broader/narrower/related terms.
15
        [% END %]
16
        </div>
17
    </div>
18
[% END %]
19
</div>
20
[% END %]
21
[% INCLUDE 'doc-head-open.inc' %]
22
<title>Koha &rsaquo; Administration &rsaquo; Did you mean?</title>
23
[% INCLUDE 'doc-head-close.inc' %]
24
<script>
25
    $(document).ready(function() {
26
        $( ".pluginlist" ).sortable();
27
        $( ".plugin" ).addClass( "ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" )
28
            .find( ".pluginname" )
29
                    .addClass( "ui-widget-header ui-corner-all" )
30
                    .end()
31
            .find( ".plugindesc" );
32
    });
33
34
    function yesimeant() {
35
        var OPACdidyoumean = serialize_plugins('opac');
36
        var INTRAdidyoumean = serialize_plugins('intranet');
37
38
        var data = "pref_OPACdidyoumean=" + encodeURIComponent(OPACdidyoumean) + "&pref_INTRAdidyoumean=" + encodeURIComponent(INTRAdidyoumean);
39
40
        $.ajax({
41
            data: data,
42
            type: 'POST',
43
            url: '/cgi-bin/koha/svc/config/systempreferences/',
44
            success: function () { alert("Successfully saved configuration"); },
45
        });
46
        return false;
47
    }
48
49
    function serialize_plugins(interface) {
50
        var serializedconfig = '[';
51
        $('#didyoumean' + interface + ' .pluginlist .plugin').each(function(index) {
52
            var name = $(this).find('.pluginlabel').text();
53
            var enabled = $(this).find('#checkbox_' + name).attr('checked') == 'checked' ?
54
                          ', "enabled": 1' : '';
55
            serializedconfig += '{ "name": "' + name + '"' + enabled + '}, ';
56
            });
57
            serializedconfig = serializedconfig.substring(0, serializedconfig.length - 2);
58
            serializedconfig += ']';
59
            return serializedconfig;
60
    }
61
</script>
62
</head>
63
<body id="admin_didyoumean" class="admin">
64
[% INCLUDE 'header.inc' %]
65
[% INCLUDE 'cat-search.inc' %]
66
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; Did you mean?</div>
67
68
<div id="doc3" class="yui-t2">
69
70
    <div id="bd">
71
    <div id="yui-main">
72
    <div class="yui-b">
73
        <h3>Did you mean?</h3>
74
        <noscript><div class="dialog alert"><strong>Please enable Javascript:</strong>
75
            Configuring <em>Did you mean?</em> plugins requires Javascript. If
76
            you are unable to use Javascript, you may be able to enter the
77
            configuration (which is stored in JSON in the OPACdidyoumean and
78
            INTRAdidyoumean system preferences) in the Local Preferences tab in
79
            the system preference editor, but this is unsupported, not
80
            recommended, and likely will not work.</div></noscript>
81
        <div id="didyoumeanlegend">
82
            Please put the <em>Did you mean?</em> plugins in order by significance, from
83
            most significant to least significant, and check the box to enable those
84
            plugins that you want to use.
85
        </div>
86
        <form action="/cgi-bin/koha/admin/didyoumean.pl" method="post">
87
            <fieldset id="didyoumeanopac">
88
                <legend>OPAC</legend>
89
                [% PROCESS pluginlist plugins=OPACpluginlist %]
90
            </fieldset>
91
            <fieldset id="didyoumeanintranet">
92
                <legend>Intranet</legend>
93
                [% PROCESS pluginlist plugins=INTRApluginlist %]
94
            </fieldset>
95
            <fieldset class="action"><button class="save-all submit" onclick="yesimeant();return false;" type="submit">Save configuration</button> <a href="#" onclick="window.location.reload(true);" class="cancel">Cancel</a></fieldset>
96
        </form>
97
98
        </div>
99
        </div>
100
<div class="yui-b">
101
[% INCLUDE 'admin-menu.inc' %]
102
</div>
103
</div>
104
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt (-1 / +1 lines)
Lines 285-291 $(document).ready(function(){ Link Here
285
    <div id="yui-main">
285
    <div id="yui-main">
286
    <div class="yui-b">
286
    <div class="yui-b">
287
    <div id="userresults" class="container">
287
    <div id="userresults" class="container">
288
    [% IF ( DidYouMeanFromAuthorities ) %]
288
    [% IF ( DidYouMean ) %]
289
        <div id='didyoumean'>Not what you expected? Check for <a href='/cgi-bin/koha/svc/suggestion?render=standalone&q=[% querystring | uri %]'>suggestions</a></div>
289
        <div id='didyoumean'>Not what you expected? Check for <a href='/cgi-bin/koha/svc/suggestion?render=standalone&q=[% querystring | uri %]'>suggestions</a></div>
290
    [% END %]
290
    [% END %]
291
    [% INCLUDE 'page-numbers.inc' %]<br />
291
    [% INCLUDE 'page-numbers.inc' %]<br />
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/text/explodedterms.tt (+8 lines)
Line 0 Link Here
1
[%- SWITCH index -%]
2
[%- CASE 'su-na' -%]
3
Search also for narrower subjects
4
[%- CASE 'su-br' -%]
5
Search also for broader subjects
6
[%- CASE 'su-rl' -%]
7
Search also for related subjects
8
[%- END -%]
(-)a/opac/opac-search.pl (-1 / +1 lines)
Lines 823-829 if (C4::Context->preference('GoogleIndicTransliteration')) { Link Here
823
        $template->param('GoogleIndicTransliteration' => 1);
823
        $template->param('GoogleIndicTransliteration' => 1);
824
}
824
}
825
825
826
$template->{VARS}->{DidYouMeanFromAuthorities} = C4::Context->preference('DidYouMeanFromAuthorities');
826
$template->{VARS}->{DidYouMean} = C4::Context->preference('OPACdidyoumean') =~ m/enable/;
827
827
828
    $template->param( borrowernumber    => $borrowernumber);
828
    $template->param( borrowernumber    => $borrowernumber);
829
output_with_http_headers $cgi, $cookie, $template->output, $content_type;
829
output_with_http_headers $cgi, $cookie, $template->output, $content_type;
(-)a/opac/svc/suggestion (-2 / +10 lines)
Lines 80-91 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
80
    }
80
    }
81
);
81
);
82
82
83
unless ( C4::Context->preference('DidYouMeanFromAuthorities') ) {
83
my @plugins = ();
84
85
my $pluginsconfig = from_json(C4::Context->preference('OPACdidyoumean') || '[]');
86
87
foreach my $plugin (@$pluginsconfig) {
88
    push @plugins, $plugin->{name} if ($plugin->{enabled});
89
}
90
91
unless ( @plugins ) {
84
    print $query->header;
92
    print $query->header;
85
    exit;
93
    exit;
86
}
94
}
87
95
88
my $suggestor = Koha::SuggestionEngine->new( { plugins => ('AuthorityFile') } );
96
my $suggestor = Koha::SuggestionEngine->new( { plugins => \@plugins } );
89
97
90
my $suggestions =
98
my $suggestions =
91
  $suggestor->get_suggestions( { search => $search, count => $count } );
99
  $suggestor->get_suggestions( { search => $search, count => $count } );
(-)a/t/SuggestionEngine_ExplodedTerms.t (-1 / +31 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
use strict;
4
use warnings;
5
6
use Test::More;
7
8
BEGIN {
9
        use_ok('Koha::SuggestionEngine');
10
}
11
12
my $suggestor = Koha::SuggestionEngine->new( { plugins => ( 'ExplodedTerms' ) } );
13
is(ref($suggestor), 'Koha::SuggestionEngine', 'Created suggestion engine');
14
15
my $result = $suggestor->get_suggestions({search => 'Cookery'});
16
17
ok((grep { $_->{'search'} eq 'su-na=Cookery' } @$result) && (grep { $_->{'search'} eq 'su-br=Cookery' } @$result) && (grep { $_->{'search'} eq 'su-rl=Cookery' } @$result), "Suggested correct alternatives for keyword search 'Cookery'");
18
19
$result = $suggestor->get_suggestions({search => 'su:Cookery'});
20
21
ok((grep { $_->{'search'} eq 'su-na=Cookery' } @$result) && (grep { $_->{'search'} eq 'su-br=Cookery' } @$result) && (grep { $_->{'search'} eq 'su-rl=Cookery' } @$result), "Suggested correct alternatives for subject search 'Cookery'");
22
23
$result = $suggestor->get_suggestions({search => 'nt:Cookery'});
24
25
is(scalar @$result, 0, "No suggestions for fielded search");
26
27
$result = $suggestor->get_suggestions({search => 'ccl=su:Cookery'});
28
29
is(scalar @$result, 0, "No suggestions for CCL search");
30
31
done_testing();

Return to bug 8726