From: berick Date: Fri, 15 Apr 2011 20:11:40 +0000 (-0400) Subject: use org unit shortname for site param; capture site/depth in search builder to pass... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=13fc8e74ce84da23ec53e969e94f52f605e5042d;p=evergreen%2Fequinox.git use org unit shortname for site param; capture site/depth in search builder to pass on to unapi retrieval, though there's still some template work to do w/ displaying the correct data there (for copy counts) --- 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 1cae862952..5c6046d1c0 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm @@ -77,17 +77,27 @@ sub _prepare_biblio_search { } } - my $site = $cgi->param('loc'); - if (defined($site) and $site ne '' and ($site ne $ctx->{aou_tree}->()->id) and not $query =~ /site\(\d+\)/) { + my $site; + my $org = $cgi->param('loc'); + if (defined($org) and $org ne '' and ($org ne $ctx->{aou_tree}->()->id) and not $query =~ /site\(\S+\)/) { + $site = $ctx->{find_aou}->($org)->shortname; $query .= " site($site)"; } + + if(!$site) { + ($site) = ($query =~ /site\(([^\)]+)\)/); + $site ||= $ctx->{aou_tree}->()->shortname; + } + + + my $depth; if (defined($cgi->param('depth')) and not $query =~ /depth\(\d+\)/) { - my $depth = defined $cgi->param('depth') ? + $depth = defined $cgi->param('depth') ? $cgi->param('depth') : $ctx->{find_aou}->($site)->ou_type->depth; $query .= " depth($depth)"; } - return $query; + return ($query, $site, $depth); } # context additions: @@ -104,9 +114,11 @@ sub load_rresults { my $page = $cgi->param('page') || 0; my $facet = $cgi->param('facet'); my $limit = $cgi->param('limit') || 10; # TODO user settings + my $loc = $cgi->param('loc'); my $offset = $page * $limit; - my $query = _prepare_biblio_search($cgi, $ctx); + my ($query, $site, $depth) = _prepare_biblio_search($cgi, $ctx); + # Limit and offset will stay here. Everything else should be part of # the query string, not special args. my $args = {'limit' => $limit, 'offset' => $offset}; @@ -140,7 +152,13 @@ sub load_rresults { return Apache2::Const::OK if @$rec_ids == 0; my ($facets, @data) = $self->get_records_and_facets( - $rec_ids, $results->{facet_key}, {flesh => '{holdings_xml,mra}'}); + $rec_ids, $results->{facet_key}, + { + flesh => '{holdings_xml,mra}', + site => $site, + depth => $depth + } + ); # shove recs into context in search results order for my $rec_id (@$rec_ids) { diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm index e951fef2aa..456f9c3672 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm @@ -149,7 +149,7 @@ sub get_records_and_facets { my ($self, $rec_ids, $facet_key, $unapi_args) = @_; $unapi_args ||= {}; - $unapi_args->{loc} ||= $self->ctx->{aou_tree}->()->shortname; + $unapi_args->{site} ||= $self->ctx->{aou_tree}->()->shortname; $unapi_args->{depth} ||= $self->ctx->{aou_tree}->()->ou_type->depth; $unapi_args->{flesh_depth} ||= 5; @@ -171,7 +171,7 @@ sub get_records_and_facets { {from => [ 'unapi.bre', $_, 'marcxml','record', $unapi_args->{flesh}, - $unapi_args->{loc}, + $unapi_args->{site}, $unapi_args->{depth}, $unapi_args->{flesh_depth}, ]}