misc little stuff *AND* wholly untested qp has_browse_entry() filter
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Thu, 2 May 2013 03:30:43 +0000 (23:30 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Fri, 3 May 2013 13:57:50 +0000 (09:57 -0400)
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Browse.pm
Open-ILS/src/templates/opac/browse.tt2
Open-ILS/src/templates/opac/css/style.css.tt2

index c202dac..97d140f 100644 (file)
@@ -665,6 +665,8 @@ __PACKAGE__->add_search_filter( 'container' );
 # 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' );
@@ -1109,6 +1111,10 @@ sub flatten {
                     $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;
index 91888ce..af129b1 100644 (file)
@@ -37,8 +37,12 @@ sub prepare_browse_parameters {
 
     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')),
@@ -60,6 +64,27 @@ sub prepare_browse_parameters {
     );
 }
 
+# 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) = @_;
 
@@ -72,18 +97,20 @@ sub load_browse_impl {
     });
 
     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;
 }
index 227689c..9edf2bc 100644 (file)
@@ -5,9 +5,10 @@
     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">
@@ -25,8 +26,8 @@
             <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}) %]">&larr; [%l ('Back') %]</a>
+                        <a class="opac-button" href="[% mkurl('', {boffset => CGI.param('boffset') - blimit}) %]">&larr; [%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') %] &rarr;</a>
+                        <a class="opac-button" href="[% mkurl('', {boffset => CGI.param('boffset') + blimit}) %]">[%l ('Forward') %] &rarr;</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>
 
index 12c92cb..b3e497b 100644 (file)
@@ -1515,3 +1515,19 @@ a.preflib_change {
 #search-tools > span {
     margin: 0 1em;
 }
+.browse-error {
+    font-weight: bold;
+    font-color: #c00;
+}
+.browse-result-sources {
+    margin-left: 1em;
+}
+.browse-pager {
+    margin: 2ex 0;
+}
+.browse-result-list {
+    list-style-type: square;
+}
+.browse-shortcuts {
+    font-size: 120%;
+}