From 184d671809b79efc6c8a00e8fcf805c29c676816 Mon Sep 17 00:00:00 2001 From: Lebbeous Fogle-Weekley Date: Wed, 27 Jul 2011 18:21:31 -0400 Subject: [PATCH] MARC expert search working This just needs the JS row cloning so you can search on multiple terms at a time. Signed-off-by: Lebbeous Fogle-Weekley --- .../lib/OpenILS/WWW/EGCatLoader/Search.pm | 67 ++++++++++++++++++- Open-ILS/web/css/skin/default/opac/style.css | 1 + .../default/opac/parts/advanced/expert.tt2 | 25 ++++++- 3 files changed, 90 insertions(+), 3 deletions(-) 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 ea33fa004c..2a9e5cdfed 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm @@ -133,7 +133,14 @@ sub load_rresults { $ctx->{page} = 'rresult'; - return $self->item_barcode_shortcut if $cgi->param("qtype") eq "item_barcode"; + if ($cgi->param("_special")) { + return $self->marc_expert_search if scalar($cgi->param("tag")); + return $self->item_barcode_shortcut if ( + $cgi->param("qtype") and ($cgi->param("qtype") eq "item_barcode") + ); + return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR; + } + my $page = $cgi->param('page') || 0; my $facet = $cgi->param('facet'); @@ -255,4 +262,62 @@ sub item_barcode_shortcut { return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR; } } + +# like item_barcode_search, this can't take all the usual search params, but +# this one will at least do site, limit and page +sub marc_expert_search { + my ($self) = @_; + + my @tags = $self->cgi->param("tag"); + my @subfields = $self->cgi->param("subfield"); + my @terms = $self->cgi->param("term"); + + my $query = []; + for (my $i = 0; $i < scalar @tags; $i++) { + push @$query, { + "term" => $terms[$i], + "restrict" => [{"tag" => $tags[$i], "subfield" => $subfields[$i]}] + }; + } + + # loc, limit and offset + my $page = $self->cgi->param("page") || 0; + my $limit = $self->_get_search_limit; + my $org_unit = $self->cgi->param("loc") || $self->ctx->{aou_tree}->()->id; + my $offset = $page * $limit; + + if (my $search = create OpenSRF::AppSession("open-ils.search")) { + my $results = $search->request( + "open-ils.search.biblio.marc", { + "searches" => $query, "org_unit" => $org_unit + }, $limit, $offset + )->gather(1); + + if (defined $U->event_code($results)) { + $self->apache->log->warn( + "open-ils.search.biblio.marc returned event: " . + $U->event_code($results) + ); + return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR; + } + + my ($facets, @data) = $self->get_records_and_facets( + # filter out nulls that will turn up here + [ grep { $_ } @{$results->{ids}} ], + undef, {flesh => "{holdings_xml,mra}"} + ); + + $self->ctx->{records} = [@data]; + $self->ctx->{search_facets} = {}; + + $self->ctx->{page_size} = $limit; + $self->ctx->{hit_count} = $results->{count}; + + return Apache2::Const::OK; + } else { + $self->apache->log->warn("couldn't connect to open-ils.search"); + return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR; + } +} + 1; diff --git a/Open-ILS/web/css/skin/default/opac/style.css b/Open-ILS/web/css/skin/default/opac/style.css index 6ea13c5455..6a0a19ae51 100644 --- a/Open-ILS/web/css/skin/default/opac/style.css +++ b/Open-ILS/web/css/skin/default/opac/style.css @@ -1014,3 +1014,4 @@ a.dash-link:hover { text-decoration: underline !important; } .invisible { visibility: hidden; } .rdetail-extras-summary { margin: 10px; } .staff-hold { background-color: #eee; } +.expert-search tbody tr th { text-align: right; padding-left: 2em; } diff --git a/Open-ILS/web/templates/default/opac/parts/advanced/expert.tt2 b/Open-ILS/web/templates/default/opac/parts/advanced/expert.tt2 index 35b11ab7ff..640b4f228e 100644 --- a/Open-ILS/web/templates/default/opac/parts/advanced/expert.tt2 +++ b/Open-ILS/web/templates/default/opac/parts/advanced/expert.tt2 @@ -1,3 +1,24 @@ - +
[% l("Expert Search") %]
- + + + + + + + + + + + + + + + + + + + +
-- 2.43.2