sub _prepare_biblio_search {
my ($cgi, $ctx) = @_;
- my $query = _prepare_biblio_search_basics($cgi) || '';
+ my $basic_query = _prepare_biblio_search_basics($cgi) || '';
+ my $query = $basic_query;
$query .= ' ' . $ctx->{global_search_filter} if $ctx->{global_search_filter};
return $query;
};
- $logger->info("tpac: site=$site, depth=$depth, query=$query");
+ $logger->info("tpac: site=$site, depth=$depth, query=$query, basic query=$basic_query");
- return ($query, $site, $depth);
+ return ($query, $site, $depth, $basic_query);
}
sub _get_search_limit {
$offset = 0;
}
- my ($query, $site, $depth) = _prepare_biblio_search($cgi, $ctx);
+ my ($query, $site, $depth, $basic_query) = _prepare_biblio_search($cgi, $ctx);
$self->get_staff_search_settings;
# Stuff these into the TT context so that templates can use them in redrawing forms
$ctx->{processed_search_query} = $query;
+ $ctx->{processed_basic_search_query} = $basic_query;
$query .= " $_" for @facets;
--- /dev/null
+[%-
+IF !attr.size; attr = [attr]; END;
+all_values = [];
+FOR attr_class IN attr;
+ all_values = ctx.search_ccvm('ctype', attr_class, 'opac_visible', 't');
+ IF all_values.size > 0; LAST; END;
+END;
+name = name || "fi:" _ attr_class;
+values = values || CGI.param(name);
+
+sorter = [];
+FOR o IN all_values;
+ IF values.grep('^' _ o.code _ '$').size;
+ display_value = (o.search_label ? o.search_label : o.value) | html;
+ sorter.push({code => o.code, value => display_value});
+ END;
+END;
+IF sorter.size;
+ sorter = sorter.sort('value');
+ joiner = '';
+ display_value = '';
+ FOR o IN sorter;
+ IF joiner != '';
+ display_value = display_value _ joiner;
+ ELSE;
+ joiner = ', ';
+ END;
+ display_value = display_value _ o.value;
+ -%]
+<input type="hidden" name="[% name %]" value="[% o.code | html | replace("'","%#39;") %]"/>
+[%-
+ END;
+ display_value;
+END -%]
--- /dev/null
+[%-
+IF !filter_group.size; filter_group = [filter_group]; END;
+group = '';
+FOR code IN filter_group;
+ group = ctx.search_filter_groups.$code;
+ LAST IF group AND group.entries.size;
+END;
+name = name || "fg:" _ group.code;
+values = values || CGI.param(name);
+-%]
+
+sorter = [];
+FOR o IN group.entries;
+ IF values.grep('^' _ o.id _ '$').size;
+ display_value = o.query.label | html;
+ sorter.push({id => o.id, label => display_value, pos => o.pos});
+ END;
+END;
+IF sorter.size;
+ sorter = sorter.sort('pos');
+ joiner = '';
+ display_value = '';
+ FOR o IN sorter;
+ IF joiner != '';
+ display_value = display_value _ joiner;
+ ELSE;
+ joiner = ', ';
+ END;
+ display_value = display_value _ o.label;
+-%]
+<input type="hidden" name="[% name %]" value="[% o.id %] />
+[%-
+ END;
+ display_value;
+END -%]
id="home_adv_search_link"><span
class="adv_search_font">[% l('Advanced Search') %]</span></a>
</div>
- <div class="searchbar">[%- l('Search ');
- IF search.basic_config.type == 'attr';
- INCLUDE "opac/parts/coded_value_selector.tt2"
- attr=search.basic_config.group none_ok=1 none_label=search.basic_config.none_label;
- ELSIF search.basic_config.type == 'filter';
- INCLUDE "opac/parts/filter_group_selector.tt2"
- filter_group=search.basic_config.group none_ok=1 none_label=search.basic_config.none_label;
- END;
+ <div class="searchbar">[%-
+ IF NOT is_advanced;
+ l('Search ');
+ IF search.basic_config.type == 'attr';
+ INCLUDE "opac/parts/coded_value_selector.tt2"
+ attr=search.basic_config.group none_ok=1 none_label=search.basic_config.none_label;
+ ELSIF search.basic_config.type == 'filter';
+ INCLUDE "opac/parts/filter_group_selector.tt2"
+ filter_group=search.basic_config.group none_ok=1 none_label=search.basic_config.none_label;
+ END;
l(' for ');
+ END;
%]
<span class='search_box_wrapper'>
<input type="text" id="search_box" name="query"
- value="[% is_advanced ? ctx.naive_query_scrub(ctx.processed_search_query) : CGI.param('query') | html %]"
+ value="[% is_special ? '' : (is_advanced ? ctx.processed_basic_search_query : CGI.param('query')) | html %]"
[%- IF use_autosuggest.enabled == "t" %]
dojoType="openils.widget.AutoSuggest" type_selector="'qtype'"
submitter="this.textbox.form.submit();"
[% IF basic_search != "f" %] autofocus [% END %] x-webkit-speech
[%- END # autosuggest enabled %] />
</span>
- [%- INCLUDE "opac/parts/qtype_selector.tt2" id="qtype";
- l(' in '); INCLUDE build_org_selector show_loc_groups=1
+ [%-
+ IF NOT is_advanced;
+ INCLUDE "opac/parts/qtype_selector.tt2" id="qtype";
+ ELSE;
+ -%]<input type="hidden" name="qtype" value="keyword" />[%-
+ END;
+ l(' in '); INCLUDE build_org_selector show_loc_groups=1
%]
<span>
<input id='search-submit-go' type="submit" value="[% l('Search') %]" alt="[% l('Search') %]" class="opac-button"
[% END %]
</div>
[%- END %]
- [% UNLESS took_care_of_form %]</form>[% END %]
[% IF (is_advanced AND NOT is_special) AND CGI.param('qtype') %]
<div class="opac-auto-102">
+ [%-
+ summary_items = [];
+ FOR adv_chunk IN search.adv_config;
+ NEXT IF adv_chunk.adv_hide;
+ summary_text = '';
+ IF adv_chunk.adv_special;
+ SWITCH adv_chunk.adv_special;
+ CASE "lib_selector";
+ # We do nothing with the lib selector right now
+ CASE "pub_year";
+ IF CGI.param('pubdate') AND CGI.param('date1');
+ SWITCH CGI.param('pubdate');
+ CASE "is";
+ summary_text = l("Is [_1]", CGI.param('date1')) | html;
+ CASE "before";
+ summary_text = l("Before [_1]", CGI.param('date1')) | html;
+ CASE "after";
+ summary_text = l("After [_1]", CGI.param('date1')) | html;
+ CASE "between";
+ summary_text = l("Between [_1] and [_2]", CGI.param('date1'), CGI.param('date2')) | html;
+ END;
+ IF summary_text;
+ value_html = CGI.param('pubdate') | html;
+ summary_text = summary_text _ "<input type='hidden' name='pubdate' value='" _ value_html _ "' />";
+ value_html = CGI.param('date1') | html;
+ summary_text = summary_text _ "<input type='hidden' name='date1' value='" _ value_html _ "' />";
+ value_html = CGI.param('date2') | html;
+ summary_text = summary_text _ "<input type='hidden' name='date2' value='" _ value_html _ "' />";
+ END;
+ END;
+ CASE "sort_selector";
+ # We do nothing for sorting right now
+ END;
+ ELSIF adv_chunk.adv_attr;
+ summary_text = INCLUDE "opac/parts/coded_value_summary.tt2"
+ attr=adv_chunk.adv_attr;
+ ELSIF adv_chunk.adv_filter;
+ summary_text = INCLUDE "opac/parts/filter_group_summary.tt2"
+ filter_group=adv_chunk.adv_filter;
+ END;
+ IF summary_text;
+ summary_text = "<span class='search_summary_label'>" _ adv_chunk.adv_label _ " :</span> <span class='search_summary_value'>" _ summary_text _ "</span>";
+ summary_items.push(summary_text);
+ END;
+ END;
+ IF summary_items.size;
+ %] <span class='search_summary_filters_label'>[% l('Active Filters:'); %]</span> [%
+ summary_items.join(' | ');
+ %]<br />[%
+ END; %]
[ <a href="[% mkurl(ctx.opac_root _ '/advanced') %]">[%
l('Refine My Original Search')
%]</a> ]
</div>
[% END %]
+ [% UNLESS took_care_of_form %]</form>[% END %]
<!--
<div id="breadcrumb">
<a href="[% ctx.opac_root %]/home">[% l('Catalog Home') %]</a> >