28 |
my $ON_PAGE =$cfg_global->val('webpac', 'on_page') || 10; |
my $ON_PAGE =$cfg_global->val('webpac', 'on_page') || 10; |
29 |
my $MIN_WILDCARD =$cfg_global->val('webpac', 'min_wildcard') || 1; |
my $MIN_WILDCARD =$cfg_global->val('webpac', 'min_wildcard') || 1; |
30 |
my $TEMPLATE =$cfg_global->val('webpac', 'template'); |
my $TEMPLATE =$cfg_global->val('webpac', 'template'); |
31 |
|
my $UNAC_FILTER =$cfg_global->val('global', 'unac_filter'); |
32 |
|
|
33 |
|
if ($UNAC_FILTER) { |
34 |
|
require $UNAC_FILTER; |
35 |
|
} |
36 |
|
|
37 |
Text::Iconv->raise_error(0); # Conversion errors raise exceptions |
Text::Iconv->raise_error(0); # Conversion errors raise exceptions |
38 |
|
|
99 |
my @persist_vars = ( 'rm' ); |
my @persist_vars = ( 'rm' ); |
100 |
my @url_params = ( 'rm=results', 'show_full=1', 'last_PAGER_offset='.$q->param('PAGER_offset') || 0 ); |
my @url_params = ( 'rm=results', 'show_full=1', 'last_PAGER_offset='.$q->param('PAGER_offset') || 0 ); |
101 |
|
|
102 |
for(my $i = 1; $i <=30; $i++) { |
# support parametars "f" and "v" for start |
103 |
|
for(my $i = ""; $i <=30; $i++) { |
104 |
|
|
105 |
return show_index($self, $i) if ($q->param("f".$i."_index")); |
return show_index($self, $i) if ($q->param("f".$i."_index")); |
106 |
|
|
109 |
|
|
110 |
push @persist_vars, "f$i"; |
push @persist_vars, "f$i"; |
111 |
push @persist_vars, "v$i"; |
push @persist_vars, "v$i"; |
112 |
|
push @persist_vars, "e$i" if ($q->param("e$i")); |
113 |
|
|
114 |
push @url_params,"f$i=".$q->url_param("f$i"); |
push @url_params,"f$i=".$q->url_param("f$i"); |
115 |
push @url_params,"v$i=".$q->url_param("v$i"); |
foreach my $v ($q->url_param("v$i")) { |
116 |
|
push @url_params,"v$i=$v"; |
117 |
|
} |
118 |
|
push @url_params,"e$i=".$q->url_param("e$i"); |
119 |
|
|
120 |
|
my $wc="*"; # swish wildcard |
121 |
|
$wc="" if ($i eq ""); # don't apply wildcard on field 0 |
122 |
|
|
123 |
# re-write query from +/- to and/and not |
# re-write query from +/- to and/and not |
124 |
my @param_vals = $q->param("v$i"); |
my @param_vals = $q->param("v$i"); |
125 |
my @swish_q; |
my @swish_q; |
126 |
|
my ($pre,$post,$exact) = ('','',''); |
127 |
while (my $search = shift @param_vals) { |
while (my $search = shift @param_vals) { |
128 |
my $s; |
my $s; |
129 |
# remove accents |
# remove accents |
134 |
$search =~ s/^\s+//; |
$search =~ s/^\s+//; |
135 |
$search =~ s/\s+$//; |
$search =~ s/\s+$//; |
136 |
|
|
137 |
|
# filed e[nr] is exact match bitmask |
138 |
|
# 1 = beginning, 2=end, 3=both |
139 |
|
$pre = '"xxbxx ' if ($q->param("e$i") & 1); |
140 |
|
$post = ' xxexx"' if ($q->param("e$i") & 2); |
141 |
|
# add qotes on other side |
142 |
|
if ($q->param("e$i")) { |
143 |
|
$pre = '"' if (! $pre); |
144 |
|
$post = '"' if (! $post); |
145 |
|
# what about wildcards? |
146 |
|
$wc = ''; |
147 |
|
$wc = '*' if ($q->param("e$i") & 4); |
148 |
|
$exact = '_exact'; |
149 |
|
} |
150 |
|
|
151 |
foreach (split(/\s+/,$search)) { |
foreach (split(/\s+/,$search)) { |
152 |
if (m/^([+-])(\S+)/) { |
if (m/^([+-])(\S+)/) { |
153 |
$s.= ($s) ? "and " : ""; |
$s.= ($s) ? "and " : ""; |
154 |
$s.="not " if ($1 eq "-"); |
$s.="not " if ($1 eq "-"); |
155 |
$s.="$2* "; |
$s.=$2.$wc." "; |
156 |
} elsif (m/^\s*(and|or|not)\s*$/i) { |
} elsif (m/^\s*(and|or|not)\s*$/i) { |
157 |
$s.="$_ "; |
$s.=$_." "; |
158 |
# don't add * to words with less than x chars |
# don't add * to words with less than x chars |
159 |
} elsif (length($_) <= $MIN_WILDCARD) { |
} elsif (length($_) <= $MIN_WILDCARD) { |
160 |
$s.="$_ "; |
$s.=$_." "; |
161 |
} else { |
} else { |
162 |
$s.="$_* "; |
$s.=$_.$wc." "; |
163 |
} |
} |
164 |
} |
} |
165 |
$s =~ s/\*+/*/g; |
$s =~ s/\*+/*/g; |
166 |
|
$s = $pre.$s.$post if ($q->param("e$i")); |
167 |
push @swish_q,$s; |
push @swish_q,$s; |
168 |
} |
} |
169 |
# FIXME default operator for multi-value fields is or. There is |
# FIXME default operator for multi-value fields is or. There is |
170 |
# no way to change it, except here for now. Is there need? |
# no way to change it, except here for now. Is there need? |
171 |
push @s_arr, $q->param("f$i")."_swish=(".join(" or ",@swish_q).")"; |
push @s_arr, $q->param("f$i")."_swish".$exact."=(".join(" or ",@swish_q).")"; |
172 |
} |
} |
173 |
|
|
174 |
my $tmpl = $self->load_tmpl('results.html', global_vars => 1); |
my $tmpl = $self->load_tmpl('results.html', global_vars => 1); |