# Start from a list of record ids, either bre or metarecords, depending on the #metabib modifier
__PACKAGE__->add_search_filter( 'record_list' );
+__PACKAGE__->add_search_filter( 'has_browse_entry' );
+
# used internally, but generally not user-settable
__PACKAGE__->add_search_filter( 'preferred_language' );
__PACKAGE__->add_search_filter( 'preferred_language_weight' );
$where .= "$key ${NOT}IN (" . join(',', map { $self->QueryParser->quote_value($_) } @{$filter->args}) . ')';
}
+ } elsif ($filter->name eq 'has_browse_entry') {
+ if (@{$filter->args} > 0) {
+ $from .= "\n" . $spc x 3 . sprintf("INNER JOIN metabib.browse_entry_def_map mbedm ON (mbedm.source = m.source AND mbedm.entry = %d)", $filter->args->[0]);
+ }
} elsif ($filter->name eq 'edit_date' or $filter->name eq 'create_date') {
# bre.create_date and bre.edit_date filtering
my $datefilter = $filter->name;
no warnings 'uninitialized';
- my $limit = int($self->cgi->param('limit') || 10);
- my $offset = int($self->cgi->param('offset') || 0);
+ # XXX TODO add config.global_flag rows for browse limit limit and
+ # browse offset limit? large offsets (or really large limits) could be
+ # tortuous to the DB.
+
+ my $limit = int($self->cgi->param('blimit') || 10);
+ my $offset = int($self->cgi->param('boffset') || 0);
my @params = (
scalar($self->cgi->param('qtype')),
);
}
+# This changes $results and returns 1 for success, undef for failure.
+# $results must be an arrayref of result rows from the DB's metabib.browse().
+sub flesh_browse_results {
+ my ($self, $results) = @_;
+
+ my @auth_ids = map { split /,/, $_->{authorities} } @$results;
+
+ if (@auth_ids) {
+ # select ash.*
+ # from authority.record_entry are
+ # join authority.control_set acs on (are.control_set = acs.id)
+ # join authority.control_set_authority_field
+ # XXX wait what am I doing here?
+ my $authorities = $self->editor->json_query({
+ ""
+ }) or return;
+ }
+
+ return 1;
+}
+
sub load_browse_impl {
my ($self, $limit, $offset, @params) = @_;
});
if (not $results) { # DB error, not empty result set.
- # The choice of ->warn instead of ->error for the Apache
- # logs is a conscious one. Let's save ->error for more
- # process-ending stuff. We're not necessarily crashing
- # in this case.
-
- $self->apache->log->warn(
- "error in browse: " . $self->editor->event->{textcode}
+ $logger->warn(
+ "error in browse (direct): " . $self->editor->event->{textcode}
);
$self->ctx->{browse_error} = 1;
return;
- }
+ }#elsif (not $self->flesh_browse_results($results)) {
+# $logger->warn(
+# "error in browse (flesh): " . $self->editor->event->{textcode}
+# );
+# $self->ctx->{browse_error} = 1;
+#
+# return;
+# }
return $results;
}
PROCESS "opac/parts/org_selector.tt2";
WRAPPER "opac/parts/base.tt2";
INCLUDE "opac/parts/topnav.tt2";
+
ctx.page_title = l("Browse the Catalog");
- limit = CGI.param('limit') || 10;
- offset = CGI.param('offset') || 0;
+ blimit = CGI.param('blimit') || 10;
+ boffset = CGI.param('boffset') || 0;
%]
<div id="search-wrapper">
<div id="browse-the-catalog">
<div id="browse-controls">
<form method="get">
- <input type="hidden" name="limit"
- value="[% limit %]" />
+ <input type="hidden" name="blimit"
+ value="[% blimit %]" />
<label for="browse-search-class">[%
l('Browse by') %]</label>
[% BLOCK browse_pager %]
<div class="browse-pager">
[% IF ctx.more_back %]
- <a class="opac-button" href="[% mkurl('', {offset => CGI.param('offset') - limit}) %]">← [%l ('Back') %]</a>
+ <a class="opac-button" href="[% mkurl('', {boffset => CGI.param('boffset') - blimit}) %]">← [%l ('Back') %]</a>
[% END %]
[% IF browse.english_pager; # XXX how to apply i18n here?
current_qtype = CGI.param('qtype') || 'title' %]
- <span class="browse-english-shortcuts">
- <a href="[% mkurl('', {qtype => current_qtype, bterm => '0'}, ['offset']) %]">0-9</a>
+ <span class="browse-shortcuts">
+ <a href="[% mkurl('', {qtype => current_qtype, bterm => '0'}, ['boffset']) %]">0-9</a>
[% FOR letter IN ['A'..'Z'] %]
- <a href="[% mkurl('', {qtype => current_qtype, bterm => letter}, ['offset']) %]">[% letter %]</a>
+ <a href="[% mkurl('', {qtype => current_qtype, bterm => letter}, ['boffset']) %]">[% letter %]</a>
[% END %]
</span>
[% END %]
[% IF ctx.more_forward %]
- <a class="opac-button" href="[% mkurl('', {offset => CGI.param('offset') + limit}) %]">[%l ('Forward') %] →</a>
+ <a class="opac-button" href="[% mkurl('', {boffset => CGI.param('boffset') + blimit}) %]">[%l ('Forward') %] →</a>
[% END %]
</div>
[% END %]
"to library staff.") %]
</span>
[% ELSE %]
+ <ul class="browse-result-list">
[% FOR result IN ctx.browse_results %]
- <div class="browse-result">
- <span class="browse-result-value">[% result.value | html %]</span>
- <span class="browse-result-value">([% result.sources %])</span>
- </div>
+ <li class="browse-result">
+ <span class="browse-result-value">
+ <a href="[% mkurl(ctx.opac_root _ '/results', {'fi:has_browse_entry' => result.browse_entry}) %]">[% result.value | html %]</a>
+ </span>
+ <span class="browse-result-sources">([% result.sources %])</span>
+ </li>
[% END %]
+ </ul>
[% END %]
</div>