From 684a218db75389d169abf50cc882fb7cb4ab9370 Mon Sep 17 00:00:00 2001 From: senator Date: Mon, 21 Feb 2011 14:42:38 -0500 Subject: [PATCH] big ol' commit making advanced search work, albeit with issues most obvious issue is that advanced search leads to a result page that renders with a basic search form filled out in a silly-looking way I'm thinking it'd be best when showing results from an advanced search to *not* show that basic search form, but instead have a hidden version of the advanced search form, prepopulated, revealable by a button labeled "refine your search" or something. That way we'd not have to worry about reversing query parser syntax back into broken-out widget values. make sense? --- .../lib/OpenILS/WWW/EGCatLoader/Search.pm | 99 +++++++++++++++--- .../web/css/skin/default/opac/semiauto.css | 4 +- Open-ILS/web/images/adv_row_close_btn.png | Bin 0 -> 524 bytes Open-ILS/web/js/opac/simple.js | 29 +++++ .../opac/parts/advanced/global_row.tt2 | 8 +- .../default/opac/parts/advanced/search.tt2 | 46 ++++---- .../web/templates/default/opac/parts/base.tt2 | 1 + .../default/opac/parts/format_selector.tt2 | 4 +- .../templates/default/opac/parts/header.tt2 | 8 +- .../default/opac/parts/result/table.tt2 | 11 +- .../default/opac/parts/searchbar.tt2 | 4 +- .../default/opac/parts/stypes_selector.tt2 | 6 +- .../web/templates/default/opac/results.tt2 | 4 +- 13 files changed, 163 insertions(+), 61 deletions(-) create mode 100644 Open-ILS/web/images/adv_row_close_btn.png create mode 100644 Open-ILS/web/js/opac/simple.js 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 2d826cd30d..e294aab279 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm @@ -8,6 +8,85 @@ use OpenILS::Application::AppUtils; my $U = 'OpenILS::Application::AppUtils'; +sub _prepare_biblio_search_basics { + my ($cgi) = @_; + + my %parts; + my @part_names = qw/class 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; + + push(@chunks, $class . ':') unless $class 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. + if ($contains eq 'nocontains') { + $query =~ s/"//g; + $query = ('"' . $query . '"') if index $query, ' '; + $query = '-' . $query; + } elsif ($contains eq 'exact') { + $query =~ s/"//g; + $query = ('"' . $query . '"') if index $query, ' '; + } + push @chunks, $query; + } + + return join(' ', @chunks); +} + +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 ($cgi->param('available')) { + $query = '#available ' . $query; + } + + if ($cgi->param('format')) { + $args->{'format'} = join('', $cgi->param('format')); + } + + 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'); + } + + if ($cgi->param('audience')) { + $query .= ' audience(' . $cgi->param('audience') . ')'; + } + + if (defined $cgi->param('sort')) { + my $sort = $cgi->param('sort'); + my $sort_order = $cgi->param('sort_order'); + $query .= " sort($sort)"; + $query .= '#' . $sort_order if $sort_order and $sort ne 'rel'; + } + + if ($cgi->param('pubyear_how') && $cgi->param('pubyear1')) { + if ($cgi->param('pubyear_how') eq 'between') { + $query .= ' between(' . $cgi->param('pubyear1'); + $query .= ',' . $cgi->param('pubyear2') if $cgi->param('pubyear2'); + $query .= ')'; + } else { + $query .= ' ' . $cgi->param('pubyear_how') . + '(' . $cgi->param('pubyear1') . ')'; + } + } + + return ($args, $query); +} + # context additions: # page_size # hit_count @@ -20,25 +99,19 @@ sub load_rresults { $ctx->{page} = 'rresult'; my $page = $cgi->param('page') || 0; - my $item_type = $cgi->param('item_type'); my $facet = $cgi->param('facet'); - my $query = $cgi->param('query'); - my $search_class = $cgi->param('class'); my $limit = $cgi->param('limit') || 10; # TODO user settings - my $loc = $cgi->param('loc') || $ctx->{aou_tree}->()->id; - my $depth = defined $cgi->param('depth') ? - $cgi->param('depth') : $ctx->{find_aou}->($loc)->ou_type->depth; + my ($args, $query) = _prepare_biblio_search($cgi, $ctx); - my $args = { - limit => $limit, offset => $page * $limit, - org_unit => $loc, depth => $depth, $item_type ? (item_type => [$item_type]) : () - }; + # 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 - # XXX Since open-ils.search is a public service, it is responsible for - # being wary of injection/bad input, not us, right? - $query = $search_class . ':' . $query if $search_class; my $results; diff --git a/Open-ILS/web/css/skin/default/opac/semiauto.css b/Open-ILS/web/css/skin/default/opac/semiauto.css index 550669f04c..68edb5e686 100644 --- a/Open-ILS/web/css/skin/default/opac/semiauto.css +++ b/Open-ILS/web/css/skin/default/opac/semiauto.css @@ -136,11 +136,11 @@ .opac-auto-149 { position: relative; top: 5px; left: 25px; } #util_print_btn { position: relative; top: 5px; left: 30px; } .opac-auto-151 { position: relative; top: 75px; } -.opac-auto-152 { position: relative; top: -9px; } +#adv_reset { position: relative; top: -9px; } .opac-auto-153 { position: relative; z-index: 100; } .text-center { text-align: center; } .opac-auto-156 { text-align: center; font-weight: bold; } -.opac-auto-157 { text-align: center; margin-top: 20px; width: 400px; } +#adv_quick_search_sidebar { text-align: center; margin-top: 20px; width: 400px; } .opac-auto-158 { text-align: center; margin-top: 6px; margin-bottom: 6px } .opac-auto-159 { text-align: center; padding: 20px; width: 100% } .opac-auto-160 { text-align: center; padding-bottom: 8px; } diff --git a/Open-ILS/web/images/adv_row_close_btn.png b/Open-ILS/web/images/adv_row_close_btn.png new file mode 100644 index 0000000000000000000000000000000000000000..edccf374d634b5774fac8e416ed243d453d6f9c8 GIT binary patch literal 524 zcmV+n0`vWeP)6snNGuc; zEG?9XNJe6K8*BA?G^{KpQ5!vlM% zA|<%Ra5#jn>(~FyW`ka@2h%idJXVIt5=b@$B(K?Q^6y%$22ImYuh%i1P7w?S5sgN# zTq{mIoldYo&Qhs_?RJYsqk(R>%Y!qS4C3)PoLn+j57Oy0#^W*i{XQm>2|}R|%H=Y4 zyPb`9R{>$QS|OE6U5UwLk}GoZ2wZ{nVHur7^4X{m2n5jSbP$O|5DtfJJS)yMg?77* z^?HqBv4~2g0znYaYPGQ6@8RUSN-zuqY%`HaBzWUgRYjptz+$n$U@*8}!fg|&VbyAt z%bm~X+?UJc5R1j&_xoviY$JCiAemG*1zY~vY{q?73C=0F#z>pzw0l0L=7%R>Yx|`r z%A=Qiz}EVkP3Mg+robLg3>t&*$9O89PS+U>3Zh#jdrUwhpw%>g1sDJVr({aa_LhYJ O0000 + @@ -11,7 +11,11 @@ - + + diff --git a/Open-ILS/web/templates/default/opac/parts/advanced/search.tt2 b/Open-ILS/web/templates/default/opac/parts/advanced/search.tt2 index c4fde3ada6..0fb4ab1f12 100644 --- a/Open-ILS/web/templates/default/opac/parts/advanced/search.tt2 +++ b/Open-ILS/web/templates/default/opac/parts/advanced/search.tt2 @@ -1,3 +1,4 @@ +
@@ -17,8 +18,7 @@ @@ -38,14 +38,15 @@ - @@ -198,20 +198,18 @@ - - - [% l('Search') %] -       - - Reset Form + +       + [% l('Reset Form') %] - - -