}
}
- 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:
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};
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) {
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;
{from => [
'unapi.bre', $_, 'marcxml','record',
$unapi_args->{flesh},
- $unapi_args->{loc},
+ $unapi_args->{site},
$unapi_args->{depth},
$unapi_args->{flesh_depth},
]}