102 |
|
|
103 |
my $params = $c->req->params; |
my $params = $c->req->params; |
104 |
|
|
105 |
# oh, client didn't have ability to setup AJAX, fallback to |
# do full-page refresh for clients without JavaScript |
106 |
# page refresh |
$c->stash->{results} = $c->subreq('/search/results/ajax', {}, $params); |
107 |
if (! $params->{'_ajax'}) { |
$c->stash->{template} = 'search.tt'; |
|
$params->{_ajax} = 1; |
|
|
$c->stash->{results} = $c->subreq('/search/results/ajax', {}, $params); |
|
|
$c->stash->{template} = 'search.tt'; |
|
|
} else { |
|
|
$c->forward('/search/results/ajax'); |
|
|
} |
|
108 |
} |
} |
109 |
|
|
110 |
|
|
118 |
|
|
119 |
# specify all Hyper Estraier operators which should stop this module |
# specify all Hyper Estraier operators which should stop this module |
120 |
# from splitting search query and joining it with default operator |
# from splitting search query and joining it with default operator |
121 |
my $hest_op_regex = qr/(:?\[(:?BW|EW|RX)\]|AND|OR|ANDNOT)/o; |
my $hest_op_regex = '(:?\[(:?BW|EW|RX)\]|AND|OR|ANDNOT)'; |
122 |
|
|
123 |
sub results_ajax : Path( 'results/ajax' ) { |
sub results_ajax : Path( 'results/ajax' ) { |
124 |
my ( $self, $c ) = @_; |
my ( $self, $c ) = @_; |
146 |
my $v = $params->{$f} || next; |
my $v = $params->{$f} || next; |
147 |
|
|
148 |
if (my $op = $params->{ '_' . $f}) { |
if (my $op = $params->{ '_' . $f}) { |
149 |
if ($v =~ $hest_op_regex) { |
if ($v =~ /$hest_op_regex/) { |
150 |
# don't split words if there is Hyper Estraier |
# don't split words if there is Hyper Estraier |
151 |
# operator in them |
# operator in them |
152 |
push @words, $v; |
push @words, $v; |
164 |
} else { |
} else { |
165 |
map { |
map { |
166 |
push @attr, "$f ISTRINC $_"; |
push @attr, "$f ISTRINC $_"; |
167 |
} grep { ! $hest_op_regex } split(/\s+/, $v); |
} grep { ! /$hest_op_regex/ } split(/\s+/, $v); |
168 |
|
} |
169 |
|
} |
170 |
|
|
171 |
|
if ($params->{_database}) { |
172 |
|
my $type = $c->config->{hyperstraier}->{type} || 'search'; |
173 |
|
my $attr; |
174 |
|
if (ref($params->{_database}) eq 'ARRAY') { |
175 |
|
# FIXME do we need to add $ at end? |
176 |
|
$attr .= '(' . join("|",@{$params->{_database}}) . ')'; |
177 |
|
} else { |
178 |
|
$attr .= $params->{_database}; |
179 |
} |
} |
180 |
|
push @attr, '@uri STRRX /' . $type . '/' . $attr . '/'; |
181 |
} |
} |
182 |
|
|
183 |
my $q = join(" $operator ", @words); |
my $q = join(" $operator ", @words); |