12 |
use Text::Unaccent; |
use Text::Unaccent; |
13 |
|
|
14 |
use lib '..'; |
use lib '..'; |
15 |
use index_DBI; |
use index_DBI_cache; |
16 |
use back2html; |
use back2html; |
17 |
|
|
18 |
|
|
79 |
my $full = $q->param('full'); |
my $full = $q->param('full'); |
80 |
|
|
81 |
my @persist_vars = ( 'rm' ); |
my @persist_vars = ( 'rm' ); |
82 |
|
my @url_params = ( 'rm=results', 'show_full=1', 'last_PAGER_offset='.$q->param('PAGER_offset') || 0 ); |
83 |
|
|
84 |
for(my $i = 1; $i <=30; $i++) { |
for(my $i = 1; $i <=30; $i++) { |
85 |
|
|
91 |
push @persist_vars, "f$i"; |
push @persist_vars, "f$i"; |
92 |
push @persist_vars, "v$i"; |
push @persist_vars, "v$i"; |
93 |
|
|
94 |
|
push @url_params,"f$i=".$q->url_param("f$i"); |
95 |
|
push @url_params,"v$i=".$q->url_param("v$i"); |
96 |
|
|
97 |
# re-write query from +/- to and/and not |
# re-write query from +/- to and/and not |
98 |
my @param_vals = $q->param("v$i"); |
my @param_vals = $q->param("v$i"); |
99 |
my @swish_q; |
my @swish_q; |
112 |
$s.= ($s) ? "and " : ""; |
$s.= ($s) ? "and " : ""; |
113 |
$s.="not " if ($1 eq "-"); |
$s.="not " if ($1 eq "-"); |
114 |
$s.="$2* "; |
$s.="$2* "; |
115 |
} elsif (m/(and|or|not)/i) { |
} elsif (m/^\s*(and|or|not)\s*$/i) { |
116 |
$s.="$_ "; |
$s.="$_ "; |
117 |
# don't add * to words with less than x chars |
# don't add * to words with less than x chars |
118 |
} elsif (length($_) <= $MIN_WILDCARD) { |
} elsif (length($_) <= $MIN_WILDCARD) { |
129 |
push @s_arr, $q->param("f$i")."_swish=(".join(" or ",@swish_q).")"; |
push @s_arr, $q->param("f$i")."_swish=(".join(" or ",@swish_q).")"; |
130 |
} |
} |
131 |
|
|
132 |
my $tmpl = $self->load_tmpl('results.html'); |
my $tmpl = $self->load_tmpl('results.html', global_vars => 1); |
133 |
|
|
134 |
sub esc_html { |
sub esc_html { |
135 |
my $html = shift; |
my $html = shift; |
166 |
$sw_q .= join("\" or swishdocpath=\"",@path_arr); |
$sw_q .= join("\" or swishdocpath=\"",@path_arr); |
167 |
$sw_q .= "\")"; |
$sw_q .= "\")"; |
168 |
$tmpl->param('full',1); # show full records |
$tmpl->param('full',1); # show full records |
169 |
|
} else { |
170 |
|
$tmpl->param('full',0); |
171 |
} |
} |
172 |
|
|
173 |
my $hits = $sh->query($sw_q); |
my $hits = $sh->query($sw_q); |
178 |
$tmpl->param('PAGER_offset',$q->param("PAGER_offset") || 0); |
$tmpl->param('PAGER_offset',$q->param("PAGER_offset") || 0); |
179 |
$tmpl->param('last_PAGER_offset',$q->param("last_PAGER_offset") || 0); |
$tmpl->param('last_PAGER_offset',$q->param("last_PAGER_offset") || 0); |
180 |
|
|
181 |
|
$tmpl->param('url_params',"?".join("&",@url_params)); |
182 |
|
|
183 |
# create a Pager object |
# create a Pager object |
184 |
my $pager = HTML::Pager->new( |
my $pager = HTML::Pager->new( |
185 |
# required parameters |
# required parameters |
190 |
my @result; |
my @result; |
191 |
for (my $i=0; $i<$rows; $i++) { |
for (my $i=0; $i<$rows; $i++) { |
192 |
my $r = $swish_results[$offset+$i]; |
my $r = $swish_results[$offset+$i]; |
193 |
if ($r && $q->param('show_full')) { |
if ($r && $tmpl->param('full')) { |
194 |
push @result, $r; |
push @result, $r; |
195 |
} elsif ($r) { |
} elsif ($r) { |
196 |
# if not full output, skip html |
# if not full output, skip html |
243 |
return $html; |
return $html; |
244 |
} |
} |
245 |
|
|
246 |
my $tmpl = $self->load_tmpl('index_res.html'); |
my $tmpl = $self->load_tmpl('index_res.html', global_vars => 1); |
247 |
$tmpl->param('field',$field); |
$tmpl->param('field',$field); |
248 |
$tmpl->param('limit',$limit); |
$tmpl->param('limit',$limit); |
249 |
$tmpl->param('total',$total); |
$tmpl->param('total',$total); |