}
# FIXME: this is bound to be broken now
- if ( $query =~ /(\(|\)|:|=)/ ) { # sorry, too complex, assume CCL
+ if ( $query =~ /(\(|\))/ ) { # sorry, too complex, assume CCL
return ( undef, $query, $query_cgi, $query_search_desc, $limit, $limit_cgi, $limit_desc, 'ccl' );
}
# COMBINE OPERANDS, INDEXES AND OPERATORS
if ( $operands[$i] ) {
+
+ $weight_fields = 0 if $operands[$i] =~ /(:|=)/;
my $operand = $operands[$i];
+
+ my $sanatized_operand = $operands[$i];
+ $sanatized_operand =~ s/://g;
+
my $index = $indexes[$i];
# if there's no index, don't use one, it will throw a CCL error
$query .= " $operand";
$query_cgi .="&op=$operators[$i-1]";
$query_cgi .="&idx=$index" if $index;
- $query_cgi .="&q=$operands[$i]" if $operand;
+ $query_cgi .="&q=$sanatized_operand" if $sanatized_operand;
$query_search_desc .=" $operators[$i-1] $index_plus $operands[$i]";
}
$query .= "$index_plus " unless $indexes_set;
$query .= "$operand";
$query_cgi .="&op=and&idx=$index" if $index;
- $query_cgi .="&q=$operands[$i]" if $operand;
+ $query_cgi .="&q=$sanatized_operand" if $sanatized_operand;
$query_search_desc .= " and $index_plus $operands[$i]";
}
}
$query .= $operand;
$query_search_desc .= " $index_plus $operands[$i]";
$query_cgi.="&idx=$index" if $index;
- $query_cgi.="&q=$operands[$i]" if $operand;
+ $query_cgi.="&q=$sanatized_operand" if $sanatized_operand;
$previous_operand = 1;
}
# Params that can have more than one value
# sort by is used to sort the query
+# in theory can have more than one but generally there's just one
my @sort_by;
@sort_by = split("\0",$params->{'sort_by'}) if $params->{'sort_by'};
-
-# FIXME: this is a quick hack
foreach my $sort (@sort_by) {
$template->param($sort => 1);
}
## I. BUILD THE QUERY
( $error,$query,$simple_query,$query_cgi,$query_search_desc,$limit,$limit_cgi,$limit_desc,$query_type) = buildQuery(\@operators,\@operands,\@indexes,\@limits,\@sort_by);
+## parse the query_cgi string and put it into a form suitable for <input>s
+my @query_inputs;
+for my $this_cgi ( split('&',$query_cgi) ) {
+ next unless $this_cgi;
+ $this_cgi =~ m/(.*=)(.*)/;
+ my $input_name = $1;
+ my $input_value = $2;
+ $input_name =~ s/=$//;
+ push @query_inputs, { input_name => $input_name, input_value => $input_value };
+}
+$template->param ( QUERY_INPUTS => \@query_inputs );
+
+## parse the limit_cgi string and put it into a form suitable for <input>s
+my @limit_inputs;
+for my $this_cgi ( split('&',$limit_cgi) ) {
+ next unless $this_cgi;
+ $this_cgi =~ m/(.*=)(.*)/;
+ my $input_name = $1;
+ my $input_value = $2;
+ $input_name =~ s/=$//;
+ push @limit_inputs, { input_name => $input_name, input_value => $input_value };
+}
+$template->param ( LIMIT_INPUTS => \@limit_inputs );
+
## II. DO THE SEARCH AND GET THE RESULTS
my $total; # the total results for the whole set
my $facets; # this object stores the faceted results that display on the left-hand of the results page
<div id="searchresults">
<form action="/cgi-bin/koha/catalogue/search.pl" method="get" name="myform" id="mainform">
<!-- TMPL_IF NAME="searchdesc" -->
- <input type="hidden" name="q" value="<!-- TMPL_VAR NAME="searchdesc" escape="html" -->" />
+ <!-- TMPL_LOOP NAME="QUERY_INPUTS"-->
+ <input type="hidden" name="<!-- TMPL_VAR NAME="input_name" -->" value="<!-- TMPL_VAR NAME="input_value" -->"/>
+ <!-- /TMPL_LOOP -->
+ <!-- TMPL_LOOP NAME="LIMIT_INPUTS"-->
+ <input type="hidden" name="<!-- TMPL_VAR NAME="input_name" -->" value="<!-- TMPL_VAR NAME="input_value" -->"/>
+ <!-- /TMPL_LOOP -->
+
+
<!-- /TMPL_IF -->
<!-- RE-SORT START -->
<p>