}
}
- my $site;
+ my (@naive_query_re, $site);
+
my $org = $ctx->{search_ou};
if (defined($org) and $org ne '' and ($org ne $ctx->{aou_tree}->()->id) and not $query =~ /site\(\S+\)/) {
- $site = $ctx->{get_aou}->($org)->shortname;
- $query .= " site($site)";
+ my $thing = " site(" . $ctx->{get_aou}->($org)->shortname . ")";
+
+ $query .= $thing;
+ push @naive_query_re, $thing;
}
my $pref_ou = $ctx->{pref_ou};
my ($org) = grep { $_->shortname eq $site } @{$ctx->{aou_list}->()};
$depth = $org->ou_type->depth;
}
- $query .= " depth($depth)";
+ my $thing = " depth($depth)";
+
+ $query .= $thing;
+ push @naive_query_re, $thing;
}
+ # This gives templates a way to take site() and depth() back out of
+ # query strings when they shouldn't be there (because they're controllable
+ # with other widgets).
+ $ctx->{naive_query_scrub} = sub {
+ my ($query) = @_;
+ $query =~ s/\Q$_\E// foreach (@naive_query_re);
+ return $query;
+ };
+
$logger->info("tpac: site=$site, depth=$depth, query=$query");
return ($query, $site, $depth);
%]
<span class='search_box_wrapper'>
<input type="text" id="search_box" name="query"
- value="[% is_advanced ? ctx.processed_search_query : CGI.param('query') | html %]"
+ value="[% is_advanced ? ctx.naive_query_scrub(ctx.processed_search_query) : CGI.param('query') | html %]"
[%- IF use_autosuggest.enabled == "t" %]
dojoType="openils.widget.AutoSuggest" type_selector="'qtype'"
submitter="this.textbox.form.submit();"