|
Lines 1194-1204
sub parseQuery {
Link Here
|
| 1194 |
} |
1194 |
} |
| 1195 |
foreach my $limit (@limits) { |
1195 |
foreach my $limit (@limits) { |
| 1196 |
} |
1196 |
} |
| 1197 |
foreach my $modifier (@sort_by) { |
1197 |
if (scalar (@sort_by) > 0) { |
| 1198 |
$query .= " #$modifier"; |
1198 |
my $modifier_re = '#(' . join( '|', @{$QParser->modifiers}) . ')'; |
|
|
1199 |
$query =~ s/$modifier_re//g; |
| 1200 |
foreach my $modifier (@sort_by) { |
| 1201 |
$query .= " #$modifier"; |
| 1202 |
} |
| 1199 |
} |
1203 |
} |
| 1200 |
|
1204 |
|
| 1201 |
$query_desc = $query; |
1205 |
$query_desc = $query; |
|
|
1206 |
$query_desc =~ s/\s+/ /g; |
| 1202 |
if ( C4::Context->preference("QueryWeightFields") ) { |
1207 |
if ( C4::Context->preference("QueryWeightFields") ) { |
| 1203 |
} |
1208 |
} |
| 1204 |
$QParser->add_bib1_filter_map( 'biblioserver', 'su-br', { 'callback' => \&_handle_exploding_index }); |
1209 |
$QParser->add_bib1_filter_map( 'biblioserver', 'su-br', { 'callback' => \&_handle_exploding_index }); |
|
Lines 1206-1214
sub parseQuery {
Link Here
|
| 1206 |
$QParser->add_bib1_filter_map( 'biblioserver', 'su-rl', { 'callback' => \&_handle_exploding_index }); |
1211 |
$QParser->add_bib1_filter_map( 'biblioserver', 'su-rl', { 'callback' => \&_handle_exploding_index }); |
| 1207 |
$QParser->parse( $query ); |
1212 |
$QParser->parse( $query ); |
| 1208 |
$operands[0] = "pqf=" . $QParser->target_syntax('biblioserver'); |
1213 |
$operands[0] = "pqf=" . $QParser->target_syntax('biblioserver'); |
| 1209 |
# TODO: once we are using QueryParser, all this special case code for |
1214 |
} else { |
| 1210 |
# exploded search indexes will be replaced by a callback to |
1215 |
my $modifier_re = '#(' . join( '|', @{Koha::QueryParser::Driver::PQF->modifiers}) . ')'; |
| 1211 |
# _handle_exploding_index |
1216 |
s/$modifier_re//g for @operands; |
| 1212 |
} |
1217 |
} |
| 1213 |
|
1218 |
|
| 1214 |
return ( $operators, \@operands, $indexes, $limits, $sort_by, $scan, $lang, $query_desc); |
1219 |
return ( $operators, \@operands, $indexes, $limits, $sort_by, $scan, $lang, $query_desc); |
|
Lines 1292-1308
sub buildQuery {
Link Here
|
| 1292 |
if ( @limits ) { |
1297 |
if ( @limits ) { |
| 1293 |
$q .= ' and '.join(' and ', @limits); |
1298 |
$q .= ' and '.join(' and ', @limits); |
| 1294 |
} |
1299 |
} |
| 1295 |
return ( undef, $q, $q, "q=ccl=$q", $q, '', '', '', '', 'ccl' ); |
1300 |
return ( undef, $q, $q, "q=ccl=".uri_escape($q), $q, '', '', '', '', 'ccl' ); |
| 1296 |
} |
1301 |
} |
| 1297 |
if ( $query =~ /^cql=/ ) { |
1302 |
if ( $query =~ /^cql=/ ) { |
| 1298 |
return ( undef, $', $', "q=cql=$'", $', '', '', '', '', 'cql' ); |
1303 |
return ( undef, $', $', "q=cql=".uri_escape($'), $', '', '', '', '', 'cql' ); |
| 1299 |
} |
1304 |
} |
| 1300 |
if ( $query =~ /^pqf=/ ) { |
1305 |
if ( $query =~ /^pqf=/ ) { |
| 1301 |
if ($query_desc) { |
1306 |
if ($query_desc) { |
| 1302 |
$query_cgi = "q=$query_desc"; |
1307 |
$query_cgi = "q=".uri_escape($query_desc); |
| 1303 |
} else { |
1308 |
} else { |
| 1304 |
$query_desc = $'; |
1309 |
$query_desc = $'; |
| 1305 |
$query_cgi = "q=pqf=$'"; |
1310 |
$query_cgi = "q=pqf=".uri_escape($'); |
| 1306 |
} |
1311 |
} |
| 1307 |
return ( undef, $', $', $query_cgi, $query_desc, '', '', '', '', 'pqf' ); |
1312 |
return ( undef, $', $', $query_cgi, $query_desc, '', '', '', '', 'pqf' ); |
| 1308 |
} |
1313 |
} |
|
Lines 1474-1482
sub buildQuery {
Link Here
|
| 1474 |
$query .= " $operators[$i-1] "; |
1479 |
$query .= " $operators[$i-1] "; |
| 1475 |
$query .= " $index_plus " unless $indexes_set; |
1480 |
$query .= " $index_plus " unless $indexes_set; |
| 1476 |
$query .= " $operand"; |
1481 |
$query .= " $operand"; |
| 1477 |
$query_cgi .= "&op=$operators[$i-1]"; |
1482 |
$query_cgi .= "&op=".uri_escape($operators[$i-1]); |
| 1478 |
$query_cgi .= "&idx=$index" if $index; |
1483 |
$query_cgi .= "&idx=".uri_escape($index) if $index; |
| 1479 |
$query_cgi .= "&q=$operands[$i]" if $operands[$i]; |
1484 |
$query_cgi .= "&q=".uri_escape($operands[$i]) if $operands[$i]; |
| 1480 |
$query_desc .= |
1485 |
$query_desc .= |
| 1481 |
" $operators[$i-1] $index_plus $operands[$i]"; |
1486 |
" $operators[$i-1] $index_plus $operands[$i]"; |
| 1482 |
} |
1487 |
} |
|
Lines 1486-1493
sub buildQuery {
Link Here
|
| 1486 |
$query .= " and "; |
1491 |
$query .= " and "; |
| 1487 |
$query .= "$index_plus " unless $indexes_set; |
1492 |
$query .= "$index_plus " unless $indexes_set; |
| 1488 |
$query .= "$operand"; |
1493 |
$query .= "$operand"; |
| 1489 |
$query_cgi .= "&op=and&idx=$index" if $index; |
1494 |
$query_cgi .= "&op=and&idx=".uri_escape($index) if $index; |
| 1490 |
$query_cgi .= "&q=$operands[$i]" if $operands[$i]; |
1495 |
$query_cgi .= "&q=".uri_escape($operands[$i]) if $operands[$i]; |
| 1491 |
$query_desc .= " and $index_plus $operands[$i]"; |
1496 |
$query_desc .= " and $index_plus $operands[$i]"; |
| 1492 |
} |
1497 |
} |
| 1493 |
} |
1498 |
} |
|
Lines 1499-1506
sub buildQuery {
Link Here
|
| 1499 |
$query .= " $index_plus " unless $indexes_set; |
1504 |
$query .= " $index_plus " unless $indexes_set; |
| 1500 |
$query .= $operand; |
1505 |
$query .= $operand; |
| 1501 |
$query_desc .= " $index_plus $operands[$i]"; |
1506 |
$query_desc .= " $index_plus $operands[$i]"; |
| 1502 |
$query_cgi .= "&idx=$index" if $index; |
1507 |
$query_cgi .= "&idx=".uri_escape($index) if $index; |
| 1503 |
$query_cgi .= "&q=$operands[$i]" if $operands[$i]; |
1508 |
$query_cgi .= "&q=".uri_escape($operands[$i]) if $operands[$i]; |
| 1504 |
$previous_operand = 1; |
1509 |
$previous_operand = 1; |
| 1505 |
} |
1510 |
} |
| 1506 |
} #/if $operands |
1511 |
} #/if $operands |