From 92a1b454d84ad7ff5958b2311aa1391140d14746 Mon Sep 17 00:00:00 2001 From: senator Date: Thu, 24 Feb 2011 18:11:04 -0500 Subject: [PATCH] lot of things, including: - crib subjects support from regular opac poc - get rid of adv search form inclusion on results page, but keep the link to it. Show a special version of just the "compiled" QP query - better and more generic handling of search terms (compiling CGI params to QP string) - make limit to avail and sort work from basic search results page - genericize search cgi params -> qp. filter:foo, s/class/qtype/, etc - more! --- .../perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm | 75 +++++++++++++--------- Open-ILS/web/css/skin/default/opac/style.css | 4 +- .../default/opac/parts/advanced/global_row.tt2 | 2 +- .../default/opac/parts/advanced/search.tt2 | 18 ++---- ...{audience_options.tt2 => audience_selector.tt2} | 7 ++ .../default/opac/parts/format_selector.tt2 | 5 +- ...item_lang_options.tt2 => language_selector.tt2} | 11 +++- .../default/opac/parts/record/summary.tt2 | 20 +++++- .../web/templates/default/opac/parts/searchbar.tt2 | 41 ++++++------ .../default/opac/parts/stypes_selector.tt2 | 4 +- Open-ILS/web/templates/default/opac/results.tt2 | 12 +++- 11 files changed, 121 insertions(+), 78 deletions(-) rename Open-ILS/web/templates/default/opac/parts/{audience_options.tt2 => audience_selector.tt2} (55%) rename Open-ILS/web/templates/default/opac/parts/{item_lang_options.tt2 => language_selector.tt2} (83%) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm index 199ef1e92e..025f9d6f2b 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm @@ -11,15 +11,17 @@ my $U = 'OpenILS::Application::AppUtils'; sub _prepare_biblio_search_basics { my ($cgi) = @_; + return $cgi->param('query') unless $cgi->param('qtype'); + my %parts; - my @part_names = qw/class contains query/; + my @part_names = qw/qtype contains query/; $parts{$_} = [ $cgi->param($_) ] for (@part_names); my @chunks = (); - for (my $i = 0; $i < scalar @{$parts{'class'}}; $i++) { - my ($class, $contains, $query) = map { $parts{$_}->[$i] } @part_names; + for (my $i = 0; $i < scalar @{$parts{'qtype'}}; $i++) { + my ($qtype, $contains, $query) = map { $parts{$_}->[$i] } @part_names; - push(@chunks, $class . ':') unless $class eq 'keyword' and $i == 0; + push(@chunks, $qtype . ':') unless $qtype eq 'keyword' and $i == 0; # This stuff probably will need refined or rethought to better handle # the weird things Real Users will surely type in. @@ -41,32 +43,16 @@ sub _prepare_biblio_search { my ($cgi, $ctx) = @_; my $query = _prepare_biblio_search_basics($cgi); - my $args = {}; - - $args->{'org_unit'} = $cgi->param('loc') || $ctx->{aou_tree}->()->id; - $args->{'depth'} = defined $cgi->param('depth') ? - $cgi->param('depth') : - $ctx->{find_aou}->($args->{'org_unit'})->ou_type->depth; - - if (grep /available/, $cgi->param('modifier')) { - $query = '#available ' . $query; - } - if ($cgi->param('format')) { - $query .= ' format(' . join('', $cgi->param('format')) . ')'; - } + $query = ('#' . $_ . ' ' . $query) foreach ($cgi->param('modifier')); - if ($cgi->param('lang')) { - # XXX TODO find out how to build query with multiple langs, if that - # even needs to be a feature of adv search. - $query .= ' lang:' . $cgi->param('lang'); + foreach (grep /^fi:/, $cgi->param) { + /:(\w+)$/ or next; + my $term = join(",", $cgi->param($_)); + $query .= " $1($term)" if length $term; } - if ($cgi->param('audience')) { - $query .= ' audience(' . join(',', $cgi->param('audience')) . ')'; - } - - if (defined $cgi->param('sort')) { + if ($cgi->param('sort')) { my ($axis, $desc) = split /\./, $cgi->param('sort'); $query .= " sort($axis)"; $query .= '#descending' if $desc; @@ -86,7 +72,17 @@ sub _prepare_biblio_search { } } - return ($args, $query); + my $site = $cgi->param('loc') || $ctx->{aou_tree}->()->id; + if (defined($cgi->param('loc')) or not $query =~ /site\(\d+\)/) { + $query .= " site($site)"; + } + if (defined($cgi->param('depth')) or not $query =~ /depth\(\d+\)/) { + my $depth = defined $cgi->param('depth') ? + $cgi->param('depth') : $ctx->{find_aou}->($site)->ou_type->depth; + $query .= " depth($depth)"; + } + + return $query; } # context additions: @@ -103,20 +99,35 @@ sub load_rresults { my $page = $cgi->param('page') || 0; my $facet = $cgi->param('facet'); my $limit = $cgi->param('limit') || 10; # TODO user settings + my $offset = $page * $limit; + + my $query = _prepare_biblio_search($cgi, $ctx); +# XXX for now, we still put limit and offset into a hash rather than +# right into the query string, because use of the limit() and offset() filters +# in the query string doesn't actually work as advertised. +# +# When you do, with offsets > 0, you get wrong results in the 'count' +# part of the result hash from open-ils.search.biblio.multiclass.query. +# +# if (defined $cgi->param('limit') or not $query =~ /limit\(\d+\)/) { +# $query =~ s/ limit\(\d+\)//; +# $query .= " limit($limit)"; +# } +# if (defined $cgi->param('page') or not $query =~ /offset\(\d+\)/) { +# $query =~ s/ offset\(\d+\)//; +# $query .= " offset($offset)"; +# } + my $args = {'limit' => $limit, 'offset' => $offset}; - my ($args, $query) = _prepare_biblio_search($cgi, $ctx); # Stuff these into the TT context so that templates can use them in redrawing forms $ctx->{processed_search_query} = $query; - $ctx->{processed_search_args} = $args; - - $args->{'limit'} = $limit; - $args->{'offset'} = $page * $limit; $query = "$query $facet" if $facet; # TODO my $results; + $logger->info("LFW XXX: compiled query: q{$query}"); try { my $method = 'open-ils.search.biblio.multiclass.query'; diff --git a/Open-ILS/web/css/skin/default/opac/style.css b/Open-ILS/web/css/skin/default/opac/style.css index 8577afd2ca..0366017eb2 100644 --- a/Open-ILS/web/css/skin/default/opac/style.css +++ b/Open-ILS/web/css/skin/default/opac/style.css @@ -228,7 +228,7 @@ div.select-wrapper:hover { #search_box_wrapper { border:1px solid #e9ebf3; padding: 1px; - padding-left:3px; + padding-left: 3px; } #search-wrapper #breadcrumb { @@ -656,7 +656,7 @@ div.select-wrapper:hover { } .results_header_sel { - width: 88px; + /* width: 88px; */ float:left; position: relative; top: 2px; diff --git a/Open-ILS/web/templates/default/opac/parts/advanced/global_row.tt2 b/Open-ILS/web/templates/default/opac/parts/advanced/global_row.tt2 index 6d65c689ec..f55321867a 100644 --- a/Open-ILS/web/templates/default/opac/parts/advanced/global_row.tt2 +++ b/Open-ILS/web/templates/default/opac/parts/advanced/global_row.tt2 @@ -11,7 +11,7 @@ - + [% l("Item Type") %]
[% INCLUDE "default/opac/parts/format_selector.tt2" - values=CGI.param("format") multiple="multiple" size="4" id="adv_global_item_type_basic" %] [% l("Language") %]
- + [% INCLUDE "default/opac/parts/language_selector.tt2" + multiple="multiple" size="4" %] [% l("Audience") %]
- - - +
@@ -50,6 +41,7 @@
+ [% UNLESS is_advanced %] [% INCLUDE "default/opac/parts/format_selector.tt2" value=CGI.param("format") %] @@ -64,8 +56,15 @@ + [% END %] - + [% UNLESS took_care_of_form %][% END %] + [% IF is_advanced %] +
+ [ [% + l('Click to Refine Your Search') + %] ] +
[% END %]