my $query = _prepare_biblio_search_basics($cgi) || '';
- $query = ('#' . $_ . ' ' . $query) foreach ($cgi->param('modifier'));
+ foreach ($cgi->param('modifier')) {
+ # The unless bit is to avoid stacking modifiers.
+ $query = ('#' . $_ . ' ' . $query) unless $query =~ qr/\#\Q$_/;
+ }
# filters
foreach (grep /^fi:/, $cgi->param) {
$query .= " $1($term)" if length $term;
}
+ # sort is treated specially, even though it's actually a filter
if ($cgi->param('sort')) {
+ $query =~ s/sort\([^\)]*\)//g; # override existing sort(). no stacking.
my ($axis, $desc) = split /\./, $cgi->param('sort');
$query .= " sort($axis)";
- $query .= '#descending' if $desc;
+ if ($desc and not $query =~ /\#descending/) {
+ $query .= '#descending';
+ } elsif (not $desc) {
+ $query =~ s/\#descending//;
+ }
}
if ($cgi->param('pubdate') && $cgi->param('date1')) {
$ctx->{search_facets} = {};
$ctx->{page_size} = $limit;
$ctx->{hit_count} = $results->{count};
+ $ctx->{parsed_query} = $results->{parsed_query};
return Apache2::Const::OK if @$rec_ids == 0;
}
}
}
+function avail_change_adv_search(checkbox) {
+ if (checkbox.form._adv && !checkbox.checked) {
+ var search_box = document.getElementById("search_box");
+ search_box.value = search_box.value.replace(/#available ?/g, "");
+ }
+}
</div>
[% END %]
<div class="results_header_div"></div>
- [% UNLESS is_advanced || is_special %]
<div class="results_header_lbl">[% l('Sort by') %]</div>
[% INCLUDE "default/opac/parts/filtersort.tt2" value=CGI.param('sort') %]
<div class="results_header_div"></div>
<div class="results_header_div"></div>
<input type="checkbox" id="limit_to_available" name="modifier" value="available"
+ onchange="avail_change_adv_search(this)"
[% CGI.param('modifier').grep('available').size ? ' checked="checked"' : '' %] />
<label for="limit_to_available" class="results_header_lbl">
[% l('Limit to available items') %]
</label>
- [% END %]
<div class="clear-both"></div>
</div>
</div>