Lines 42-48
sub to_koha {
Link Here
|
42 |
my $attrs = $self->{'attributes'}; |
42 |
my $attrs = $self->{'attributes'}; |
43 |
my $fields = $mappings->{use}{default} // '_all'; |
43 |
my $fields = $mappings->{use}{default} // '_all'; |
44 |
my $split = 0; |
44 |
my $split = 0; |
45 |
my $quote = ''; |
|
|
46 |
my $prefix = ''; |
45 |
my $prefix = ''; |
47 |
my $suffix = ''; |
46 |
my $suffix = ''; |
48 |
my $term = $self->{'term'}; |
47 |
my $term = $self->{'term'}; |
Lines 54-60
sub to_koha {
Link Here
|
54 |
$fields = $mappings->{use}{$use} if defined $mappings->{use}{$use}; |
53 |
$fields = $mappings->{use}{$use} if defined $mappings->{use}{$use}; |
55 |
} elsif ($attr->{'attributeType'} == 4) { # structure |
54 |
} elsif ($attr->{'attributeType'} == 4) { # structure |
56 |
$split = 1 if ($attr->{'attributeValue'} == 2); |
55 |
$split = 1 if ($attr->{'attributeValue'} == 2); |
57 |
$quote = '"' if ($attr->{'attributeValue'} == 1); |
|
|
58 |
} elsif ($attr->{'attributeType'} == 5) { # truncation |
56 |
} elsif ($attr->{'attributeType'} == 5) { # truncation |
59 |
my $truncation = $attr->{'attributeValue'}; |
57 |
my $truncation = $attr->{'attributeValue'}; |
60 |
$prefix = '*' if ($truncation == 2 || $truncation == 3); |
58 |
$prefix = '*' if ($truncation == 2 || $truncation == 3); |
Lines 71-76
sub to_koha {
Link Here
|
71 |
$word =~ s/^[\,\.;:\\\/\"\'\-\=]+//g; |
69 |
$word =~ s/^[\,\.;:\\\/\"\'\-\=]+//g; |
72 |
$word =~ s/[\,\.;:\\\/\"\'\-\=]+$//g; |
70 |
$word =~ s/[\,\.;:\\\/\"\'\-\=]+$//g; |
73 |
next if (!$word); |
71 |
next if (!$word); |
|
|
72 |
$word = $self->escape($word); |
74 |
my @words; |
73 |
my @words; |
75 |
foreach my $field (@{$fields}) { |
74 |
foreach my $field (@{$fields}) { |
76 |
push(@words, "$field:($prefix$word$suffix)"); |
75 |
push(@words, "$field:($prefix$word$suffix)"); |
Lines 81-95
sub to_koha {
Link Here
|
81 |
} |
80 |
} |
82 |
|
81 |
|
83 |
my @terms; |
82 |
my @terms; |
|
|
83 |
$term = $self->escape($term); |
84 |
foreach my $field (@{$fields}) { |
84 |
foreach my $field (@{$fields}) { |
85 |
push(@terms, "$field:($prefix$term$suffix)"); |
85 |
push(@terms, "$field:($prefix$term$suffix)"); |
86 |
} |
86 |
} |
87 |
return '(' . join(' OR ', @terms) . ')'; |
87 |
return '(' . join(' OR ', @terms) . ')'; |
88 |
} |
88 |
} |
89 |
|
89 |
|
|
|
90 |
sub escape { |
91 |
my ($self, $term) = @_; |
92 |
|
93 |
$term =~ s/([()])/\\$1/g; |
94 |
return $term; |
95 |
} |
96 |
|
90 |
package Net::Z3950::RPN::And; |
97 |
package Net::Z3950::RPN::And; |
91 |
sub to_koha |
98 |
sub to_koha { |
92 |
{ |
|
|
93 |
my ($self, $mappings) = @_; |
99 |
my ($self, $mappings) = @_; |
94 |
|
100 |
|
95 |
return '(' . $self->[0]->to_koha($mappings) . ' AND ' . |
101 |
return '(' . $self->[0]->to_koha($mappings) . ' AND ' . |
Lines 97-104
sub to_koha
Link Here
|
97 |
} |
103 |
} |
98 |
|
104 |
|
99 |
package Net::Z3950::RPN::Or; |
105 |
package Net::Z3950::RPN::Or; |
100 |
sub to_koha |
106 |
sub to_koha { |
101 |
{ |
|
|
102 |
my ($self, $mappings) = @_; |
107 |
my ($self, $mappings) = @_; |
103 |
|
108 |
|
104 |
return '(' . $self->[0]->to_koha($mappings) . ' OR ' . |
109 |
return '(' . $self->[0]->to_koha($mappings) . ' OR ' . |
Lines 106-113
sub to_koha
Link Here
|
106 |
} |
111 |
} |
107 |
|
112 |
|
108 |
package Net::Z3950::RPN::AndNot; |
113 |
package Net::Z3950::RPN::AndNot; |
109 |
sub to_koha |
114 |
sub to_koha { |
110 |
{ |
|
|
111 |
my ($self, $mappings) = @_; |
115 |
my ($self, $mappings) = @_; |
112 |
|
116 |
|
113 |
return '(' . $self->[0]->to_koha($mappings) . ' NOT ' . |
117 |
return '(' . $self->[0]->to_koha($mappings) . ' NOT ' . |