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

(-)a/Koha/SuggestionEngine/Base.pm (-45 / +3 lines)
Lines 34-42 B<get_suggestions (\%param)> - get suggestions for the search described Link Here
34
in $param->{'search'}, and return them in a hashref with the suggestions
34
in $param->{'search'}, and return them in a hashref with the suggestions
35
as keys and relevance as values.
35
as keys and relevance as values.
36
36
37
The following variables must be defined in each filter:
37
B<NAME> - return a string with the name of the plugin.
38
  our $NAME ='Filter';
38
39
  our $VERSION = '1.0';
39
B<VERSION> - return a string with the version of the plugin.
40
40
41
These methods may be overriden:
41
These methods may be overriden:
42
42
Lines 123-168 sub get_suggestions { Link Here
123
    return;
123
    return;
124
}
124
}
125
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
168
1;
126
1;
(-)a/Koha/SuggestionEngine/Plugin/AuthorityFile.pm (-2 / +20 lines)
Lines 35-42 use warnings; Link Here
35
use Carp;
35
use Carp;
36
36
37
use base qw(Koha::SuggestionEngine::Base);
37
use base qw(Koha::SuggestionEngine::Base);
38
our $NAME    = 'AuthorityFile';
38
39
our $VERSION = '1.0';
39
=head2 NAME
40
    my $name = $plugin->NAME;
41
42
=cut
43
44
sub NAME {
45
    return 'AuthorityFile';
46
}
47
48
=head2 VERSION
49
    my $version = $plugin->VERSION;
50
51
=cut
52
53
sub VERSION {
54
    return '1.1';
55
}
40
56
41
=head2 get_suggestions
57
=head2 get_suggestions
42
58
Lines 85-87 sub get_suggestions { Link Here
85
    }
101
    }
86
    return \@results;
102
    return \@results;
87
}
103
}
104
105
1;
(-)a/Koha/SuggestionEngine/Plugin/ExplodedTerms.pm (-2 / +20 lines)
Lines 37-44 use Carp; Link Here
37
use C4::Templates qw(gettemplate); # This is necessary for translatability
37
use C4::Templates qw(gettemplate); # This is necessary for translatability
38
38
39
use base qw(Koha::SuggestionEngine::Base);
39
use base qw(Koha::SuggestionEngine::Base);
40
our $NAME    = 'ExplodedTerms';
40
41
our $VERSION = '1.0';
41
=head2 NAME
42
    my $name = $plugin->NAME;
43
44
=cut
45
46
sub NAME {
47
    return 'ExplodedTerms';
48
}
49
50
=head2 VERSION
51
    my $version = $plugin->VERSION;
52
53
=cut
54
55
sub VERSION {
56
    return '1.0';
57
}
42
58
43
=head2 get_suggestions
59
=head2 get_suggestions
44
60
Lines 85-87 sub get_suggestions { Link Here
85
        };
101
        };
86
    } return \@results;
102
    } return \@results;
87
}
103
}
104
105
1;
(-)a/Koha/SuggestionEngine/Plugin/Null.pm (-2 / +20 lines)
Lines 36-43 use warnings; Link Here
36
use Carp;
36
use Carp;
37
37
38
use base qw(Koha::SuggestionEngine::Base);
38
use base qw(Koha::SuggestionEngine::Base);
39
our $NAME    = 'Null';
39
40
our $VERSION = '1.0';
40
=head2 NAME
41
    my $name = $plugin->NAME;
42
43
=cut
44
45
sub NAME {
46
    return 'Null';
47
}
48
49
=head2 VERSION
50
    my $version = $plugin->VERSION;
51
52
=cut
53
54
sub VERSION {
55
    return '1.1';
56
}
41
57
42
=head2 get_suggestions
58
=head2 get_suggestions
43
59
Lines 58-60 sub get_suggestions { Link Here
58
74
59
    return \@result;
75
    return \@result;
60
}
76
}
77
78
1;
(-)a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css (-4 lines)
Lines 2429-2438 ul.ui-tabs-nav li { Link Here
2429
    width: 260px;
2429
    width: 260px;
2430
}
2430
}
2431
2431
2432
#didyoumeanlegend {
2433
    float: right;
2434
}
2435
2436
.pluginlist {
2432
.pluginlist {
2437
    padding-bottom: 10px;
2433
    padding-bottom: 10px;
2438
}
2434
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/didyoumean.tt (-5 / +6 lines)
Lines 3-10 Link Here
3
[% FOREACH plugin IN plugins %]
3
[% FOREACH plugin IN plugins %]
4
    <div class="plugin">
4
    <div class="plugin">
5
        <div class="pluginname">
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 %]
6
            [% IF plugin.enabled %]<input type="checkbox" checked="checked" id="checkbox_[% type %][% plugin.name %]">[% ELSE %]<input type="checkbox" id="checkbox_[% type %][% plugin.name %]">[% END %]
7
            <label class='pluginlabel' for="checkbox_[% plugin.name %]">[% plugin.name %]</label></div>
7
            <label class='pluginlabel' for="checkbox_[% type %][% plugin.name %]">[% plugin.name %]</label></div>
8
        <div class="plugindesc">
8
        <div class="plugindesc">
9
        [% SWITCH plugin.name %]
9
        [% SWITCH plugin.name %]
10
        [% CASE 'AuthorityFile' %]
10
        [% CASE 'AuthorityFile' %]
Lines 81-96 Link Here
81
        <div id="didyoumeanlegend">
81
        <div id="didyoumeanlegend">
82
            Please put the <em>Did you mean?</em> plugins in order by significance, from
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
83
            most significant to least significant, and check the box to enable those
84
            plugins that you want to use.
84
            plugins that you want to use. (NOTE: <em>Did you mean?</em> functionality
85
            is not yet enabled on the staff client)
85
        </div>
86
        </div>
86
        <form action="/cgi-bin/koha/admin/didyoumean.pl" method="post">
87
        <form action="/cgi-bin/koha/admin/didyoumean.pl" method="post">
87
            <fieldset id="didyoumeanopac">
88
            <fieldset id="didyoumeanopac">
88
                <legend>OPAC</legend>
89
                <legend>OPAC</legend>
89
                [% PROCESS pluginlist plugins=OPACpluginlist %]
90
                [% PROCESS pluginlist plugins=OPACpluginlist type='opac' %]
90
            </fieldset>
91
            </fieldset>
91
            <fieldset id="didyoumeanintranet">
92
            <fieldset id="didyoumeanintranet">
92
                <legend>Intranet</legend>
93
                <legend>Intranet</legend>
93
                [% PROCESS pluginlist plugins=INTRApluginlist %]
94
                [% PROCESS pluginlist plugins=INTRApluginlist type='intranet' %]
94
            </fieldset>
95
            </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
            <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
        </form>
(-)a/t/SuggestionEngine.t (-4 / +4 lines)
Lines 20-34 foreach my $plugin (@installed_plugins) { Link Here
20
    ok(grep($plugin, @available_plugins), "Found plugin $plugin");
20
    ok(grep($plugin, @available_plugins), "Found plugin $plugin");
21
}
21
}
22
22
23
my $suggestor = Koha::SuggestionEngine->new( { plugins => ( 'ABCD::EFGH::IJKL' ) } );
23
my $suggestor = Koha::SuggestionEngine->new( { plugins => [ 'ABCD::EFGH::IJKL' ] } );
24
24
25
is(ref($suggestor), 'Koha::SuggestionEngine', 'Created suggestion engine with invalid plugin');
25
is(ref($suggestor), 'Koha::SuggestionEngine', 'Created suggestion engine with invalid plugin');
26
is(scalar @{ $suggestor->get_suggestions({ 'search' => 'books' }) }, 0 , 'Request suggestions with empty suggestor');
26
is(scalar @{ $suggestor->get_suggestions({ 'search' => 'books' }) }, 0 , 'Request suggestions with empty suggestor');
27
27
28
$suggestor = Koha::SuggestionEngine->new( { plugins => ( 'Null' ) } );
28
$suggestor = Koha::SuggestionEngine->new( { plugins => [ 'Null' ] } );
29
is(ref($suggestor->plugins->[0]), 'Koha::SuggestionEngine::Plugin::Null', 'Created record suggestor with implicitly scoped Null filter');
29
is(ref($suggestor->plugins->[0]), 'Koha::SuggestionEngine::Plugin::Null', 'Created record suggestor with implicitly scoped Null filter');
30
30
31
$suggestor = Koha::SuggestionEngine->new( { plugins => ( 'Koha::SuggestionEngine::Plugin::Null' ) } );
31
$suggestor = Koha::SuggestionEngine->new( { plugins => [ 'Koha::SuggestionEngine::Plugin::Null' ] } );
32
is(ref($suggestor->plugins->[0]), 'Koha::SuggestionEngine::Plugin::Null', 'Created record suggestor with explicitly scoped Null filter');
32
is(ref($suggestor->plugins->[0]), 'Koha::SuggestionEngine::Plugin::Null', 'Created record suggestor with explicitly scoped Null filter');
33
33
34
my $suggestions = $suggestor->get_suggestions({ 'search' => 'books' });
34
my $suggestions = $suggestor->get_suggestions({ 'search' => 'books' });
Lines 38-44 is_deeply($suggestions->[0], { 'search' => 'book', label => 'Book!', relevance = Link Here
38
$suggestions = $suggestor->get_suggestions({ 'search' => 'silliness' });
38
$suggestions = $suggestor->get_suggestions({ 'search' => 'silliness' });
39
39
40
eval {
40
eval {
41
    $suggestor = Koha::SuggestionEngine->new( { plugins => ( 'Koha::SuggestionEngine::Plugin::Null' ) } );
41
    $suggestor = Koha::SuggestionEngine->new( { plugins => [ 'Koha::SuggestionEngine::Plugin::Null' ] } );
42
    undef $suggestor;
42
    undef $suggestor;
43
};
43
};
44
ok(!$@, 'Destroyed suggestor successfully');
44
ok(!$@, 'Destroyed suggestor successfully');
(-)a/t/SuggestionEngine_AuthorityFile.t (-1 / +1 lines)
Lines 33-39 $module->mock('SearchAuthorities', sub { Link Here
33
                } ], 1
33
                } ], 1
34
});
34
});
35
35
36
my $suggestor = Koha::SuggestionEngine->new( { plugins => ( 'AuthorityFile' ) } );
36
my $suggestor = Koha::SuggestionEngine->new( { plugins => [ 'AuthorityFile' ] } );
37
is(ref($suggestor), 'Koha::SuggestionEngine', 'Created suggestion engine');
37
is(ref($suggestor), 'Koha::SuggestionEngine', 'Created suggestion engine');
38
38
39
my $result = $suggestor->get_suggestions({search => 'Cookery'});
39
my $result = $suggestor->get_suggestions({search => 'Cookery'});
(-)a/t/SuggestionEngine_ExplodedTerms.t (-2 / +1 lines)
Lines 9-15 BEGIN { Link Here
9
        use_ok('Koha::SuggestionEngine');
9
        use_ok('Koha::SuggestionEngine');
10
}
10
}
11
11
12
my $suggestor = Koha::SuggestionEngine->new( { plugins => ( 'ExplodedTerms' ) } );
12
my $suggestor = Koha::SuggestionEngine->new( { plugins => [ 'ExplodedTerms' ] } );
13
is(ref($suggestor), 'Koha::SuggestionEngine', 'Created suggestion engine');
13
is(ref($suggestor), 'Koha::SuggestionEngine', 'Created suggestion engine');
14
14
15
my $result = $suggestor->get_suggestions({search => 'Cookery'});
15
my $result = $suggestor->get_suggestions({search => 'Cookery'});
16
- 

Return to bug 8726