Lines 1-5
Link Here
|
1 |
#!/usr/bin/perl |
|
|
2 |
|
3 |
# Copyright The National Library of Finland 2018 |
1 |
# Copyright The National Library of Finland 2018 |
4 |
# |
2 |
# |
5 |
# This file is part of Koha. |
3 |
# This file is part of Koha. |
Lines 17-27
Link Here
|
17 |
# You should have received a copy of the GNU General Public License |
15 |
# You should have received a copy of the GNU General Public License |
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
16 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
19 |
|
17 |
|
|
|
18 |
package Net::Z3950::RPN::Term; |
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
|
|
21 |
our @ISA = qw(Net::Z3950::RPN::Node); |
21 |
|
22 |
|
22 |
=head1 NAME |
23 |
=head1 NAME |
23 |
|
24 |
|
24 |
Koha::Z3950Responder::RPN |
25 |
Net::Z3950::RPN::Term |
25 |
|
26 |
|
26 |
=head1 SYNOPSIS |
27 |
=head1 SYNOPSIS |
27 |
|
28 |
|
Lines 30-41
converts the query to a syntax that C<Koha::SearchEngine> understands.
Link Here
|
30 |
|
31 |
|
31 |
=head1 DESCRIPTION |
32 |
=head1 DESCRIPTION |
32 |
|
33 |
|
33 |
The method used here is described in C<samples/render-search.pl> of |
34 |
The previous method used is described in C<samples/render-search.pl> of |
34 |
C<Net::Z3950::SimpleServer>. |
35 |
C<Net::Z3950::SimpleServer>, but Perl critic doesn't like it, so |
|
|
36 |
we are using whole package overrides here. |
37 |
|
38 |
=cut |
39 |
|
40 |
=head2 to_koha |
41 |
|
42 |
Convert query to a syntax that C<Koha::SearchEngine> understands. |
35 |
|
43 |
|
36 |
=cut |
44 |
=cut |
37 |
|
45 |
|
38 |
package Net::Z3950::RPN::Term; |
|
|
39 |
sub to_koha { |
46 |
sub to_koha { |
40 |
my ($self, $mappings) = @_; |
47 |
my ($self, $mappings) = @_; |
41 |
|
48 |
|
Lines 93-98
sub to_koha {
Link Here
|
93 |
return '(' . join(' OR ', @terms) . ')'; |
100 |
return '(' . join(' OR ', @terms) . ')'; |
94 |
} |
101 |
} |
95 |
|
102 |
|
|
|
103 |
=head2 escape |
104 |
|
105 |
Escape the term |
106 |
|
107 |
=cut |
108 |
|
96 |
sub escape { |
109 |
sub escape { |
97 |
my ($self, $term) = @_; |
110 |
my ($self, $term) = @_; |
98 |
|
111 |
|
Lines 100-127
sub escape {
Link Here
|
100 |
return $term; |
113 |
return $term; |
101 |
} |
114 |
} |
102 |
|
115 |
|
103 |
package Net::Z3950::RPN::And; |
|
|
104 |
sub to_koha { |
105 |
my ($self, $mappings) = @_; |
106 |
|
107 |
return '(' . $self->[0]->to_koha($mappings) . ' AND ' . |
108 |
$self->[1]->to_koha($mappings) . ')'; |
109 |
} |
110 |
|
111 |
package Net::Z3950::RPN::Or; |
112 |
sub to_koha { |
113 |
my ($self, $mappings) = @_; |
114 |
|
115 |
return '(' . $self->[0]->to_koha($mappings) . ' OR ' . |
116 |
$self->[1]->to_koha($mappings) . ')'; |
117 |
} |
118 |
|
119 |
package Net::Z3950::RPN::AndNot; |
120 |
sub to_koha { |
121 |
my ($self, $mappings) = @_; |
122 |
|
123 |
return '(' . $self->[0]->to_koha($mappings) . ' NOT ' . |
124 |
$self->[1]->to_koha($mappings) . ')'; |
125 |
} |
126 |
|
127 |
1; |
116 |
1; |
128 |
- |
|
|