return $cgi->param('query') unless $cgi->param('qtype');
my %parts;
- my @part_names = qw/qtype contains query/;
+ my @part_names = qw/qtype contains query bool/;
$parts{$_} = [ $cgi->param($_) ] for (@part_names);
+ my $full_query = '';
my @chunks = ();
for (my $i = 0; $i < scalar @{$parts{'qtype'}}; $i++) {
- my ($qtype, $contains, $query) = map { $parts{$_}->[$i] } @part_names;
+ my ($qtype, $contains, $query, $bool) = map { $parts{$_}->[$i] } @part_names;
next unless $query =~ /\S/;
push(@chunks, $qtype . ':') unless $qtype eq 'keyword' and $i == 0;
$query =~ s/[\^\$]//g;
$query = '^' . $query . '$';
}
+
+ $bool = ($bool and $bool eq 'or') ? '||' : '&&';
+ $full_query = $full_query ? "($full_query $bool $query)" : $query;
push @chunks, $query;
}
- return join(' ', @chunks);
+ return $full_query;
}
sub _prepare_biblio_search {
];
contains = CGI.param('contains');
queries = CGI.param('query');
+ bools = CGI.param('bool') || ['and' x 3];
qtypes = CGI.param('qtype') || ['keyword' x 3];
FOR qtype IN qtypes;
c = contains.shift;
+ b = bools.shift;
q = queries.shift; %]
-<tr[% IF loop.first %] id="adv_global_row"[% END %]>
+
+<!-- tag the second row so the bool column won't be hidden -->
+<tr[% IF loop.index == 1 %] id="adv_global_row"[% END %]>
<td align='left' width='100%' nowrap='nowrap'>
+
+ <!-- bool selector. hide for first row. safe to ignore first bool value in form submission -->
+ <select name='bool' [% IF loop.first %] class='invisible' [% END %]>
+ <option value='and' [% b == 'and' ? 'selected="selected"' : '' %]>[% l('And') %]</option>
+ <option value='or' [% b == 'or' ? 'selected="selected"' : '' %]>[% l('Or') %]</option>
+ </select>
+
+ <!-- keyword, subject, etc. selector -->
<span class="opac-auto-078">
[% INCLUDE "default/opac/parts/qtype_selector.tt2"
query_type=qtype %]
</span>
+
<select name='contains' style='margin-right: 7px;'>
- [% FOR o IN contains_options;
- |l(o.value, o.label) -%]
- <option value="[_1]"[% c == o.value ? ' selected="selected"' : '' %]>[_2]</option>
- [% END; END %]
+ [% FOR o IN contains_options; -%]
+ <option value="[% o.value %]" [% c == o.value ? ' selected="selected"' : '' %]>[% o.label %]</option>
+ [% END %]
</select>
<input type='text' size='18' name='query' value="[% q | html %]" />
<a href="javascript:;" class="row-remover"