crummy paging in the record pages' copy listing
authorsenator <lebbeous@esilibrary.com>
Wed, 16 Feb 2011 22:23:16 +0000 (17:23 -0500)
committersenator <lebbeous@esilibrary.com>
Wed, 16 Feb 2011 22:23:16 +0000 (17:23 -0500)
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm
Open-ILS/web/templates/default/opac/parts/record/summary.tt2

index 71c7bd4..c3716d5 100644 (file)
@@ -15,8 +15,8 @@ sub load_record {
 
     my $org = $self->cgi->param('loc') || $self->ctx->{aou_tree}->()->id;
     my $depth = $self->cgi->param('depth') || 0;
-    my $copy_limit = $self->cgi->param('copy_limit');
-    my $copy_offset = $self->cgi->param('copy_offset');
+    my $copy_limit = int($self->cgi->param('copy_limit') || 20);
+    my $copy_offset = int($self->cgi->param('copy_offset') || 0);
 
     my $rec_id = $self->ctx->{page_args}->[0]
         or return Apache2::Const::HTTP_BAD_REQUEST;
@@ -30,6 +30,8 @@ sub load_record {
     $self->ctx->{marc_xml} = XML::LibXML->new->parse_string($self->ctx->{record}->marc);
 
     $self->ctx->{copies} = $copy_rec->gather(1);
+    $self->ctx->{copy_limit} = $copy_limit;
+    $self->ctx->{copy_offset} = $copy_offset;
 
     return Apache2::Const::OK;
 }
@@ -39,8 +41,8 @@ sub mk_copy_query {
     my $rec_id = shift;
     my $org = shift;
     my $depth = shift;
-    my $copy_limit = shift || 20;
-    my $copy_offset = shift || 0;
+    my $copy_limit = shift;
+    my $copy_offset = shift;
 
     my $query = {
         select => {
index 05c73f3..b28cf66 100644 (file)
                 END %]</td>
         </tr>
         [% END %]
+        <tr>
+        [% IF ctx.copy_offset > 0;
+            new_offset = ctx.copy_offset - ctx.copy_limit;
+            IF new_offset < 0; new_offset = 0; END %]
+            <td>
+                <a href="[% ctx.opac_root %]/record/[% record.id %]?copy_offset=[% new_offset %]&copy_limit=[% ctx.copy_limit %]">&laquo; [%
+                    l('Previous [_1]', ctx.copy_offset - new_offset)
+                %]</a>
+            </td>
+        [% END %]
+        [% IF ctx.copies.size >= ctx.copy_limit %]
+            <td>
+                <a href="[% ctx.opac_root %]/record/[% record.id %]?copy_offset=[% ctx.copy_offset + ctx.copy_limit %]&copy_limit=[% ctx.copy_limit %]">[%
+                    l('Next [_1]', ctx.copy_limit)
+                %] &raquo;</a>
+            </td>
+        [% END %]
+        </tr>
     </tbody>
 </table>