Bugzilla – Attachment 11671 Details for
Bug 8570
Add pagination to the Z39.50 results page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 8570 - Add pagination to the Z39.50 results page
SIGNED-OFF-Bug-8570---Add-pagination-to-the-Z3950-.patch (text/plain), 14.15 KB, created by
Owen Leonard
on 2012-08-17 15:25:06 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 8570 - Add pagination to the Z39.50 results page
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2012-08-17 15:25:06 UTC
Size:
14.15 KB
patch
obsolete
>From cdba370ff53d110aa4984009452786b4adb34802 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Fr=C3=A9d=C3=A9rick?= <frederick.capovilla@libeo.com> >Date: Fri, 3 Aug 2012 13:50:29 -0400 >Subject: [PATCH] [SIGNED-OFF] Bug 8570 - Add pagination to the Z39.50 results > page >Content-Type: text/plain; charset="utf-8" > >Add paginations to the Z39.50 search results. > >http://bugs.koha-community.org/show_bug.cgi?id=8570 >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >--- > acqui/z3950_search.pl | 57 ++++++++++++++------ > cataloguing/z3950_search.pl | 49 ++++++++++++----- > .../prog/en/modules/acqui/z3950_search.tt | 50 ++++++++++++++++- > .../prog/en/modules/cataloguing/z3950_search.tt | 47 ++++++++++++++++ > 4 files changed, 173 insertions(+), 30 deletions(-) > >diff --git a/acqui/z3950_search.pl b/acqui/z3950_search.pl >index 9dc8b6e..35e14c3 100755 >--- a/acqui/z3950_search.pl >+++ b/acqui/z3950_search.pl >@@ -63,6 +63,12 @@ my $controlnumber = $input->param('controlnumber'); > my $op = $input->param('op'); > my $booksellerid = $input->param('booksellerid'); > my $basketno = $input->param('basketno'); >+ >+my $page = $input->param('current_page') || 1; >+$page = $input->param('goto_page') if $input->param('changepage_goto'); >+my $show_next = 0; >+my $total_pages = 0; >+ > my $noconnection; > my $attr = ''; > my $term; >@@ -112,22 +118,26 @@ $template->param( frameworkcode => $frameworkcode, > ); > > >+$template->param( >+ isbn => $isbn, >+ issn => $issn, >+ lccn => $lccn, >+ lccall => $lccall, >+ title => $title, >+ author => $author, >+ controlnumber=> $controlnumber, >+ biblionumber => $biblionumber, >+ dewey => $dewey, >+ subject => $subject, >+); > > if ( $op ne "do_search" ) { > my $sth = $dbh->prepare("select id,host,name,checked from z3950servers order by host"); > $sth->execute(); > my $serverloop = $sth->fetchall_arrayref( {} ); > $template->param( >- isbn => $isbn, >- issn => $issn, >- lccn => $lccn, >- lccall => $lccall, >- title => $title, >- author => $author, >- controlnumber=> $controlnumber, > serverloop => $serverloop, > opsearch => "search", >- biblionumber => $biblionumber, > ); > output_html_with_http_headers $input, $cookie, $template->output; > exit; >@@ -258,13 +268,10 @@ warn "query ".$query if $DEBUG; > warn "numresults = $numresults" if $DEBUG; > my $i; > my $result = ''; >- if ( $numresults > 0 ) { >- for ( >- $i = 0 ; >- $i < ( ( $numresults < 20 ) ? ($numresults) : (20) ) ; >- $i++ >- ) >- { >+ if ( $numresults > 0 and $numresults >= (($page-1)*20)) { >+ $show_next = 1 if $numresults >= ($page*20); >+ $total_pages = int($numresults/20)+1 if $total_pages < ($numresults/20); >+ for ($i = ($page-1)*20; $i < (($numresults < ($page*20)) ? $numresults : ($page*20)); $i++) { > my $rec = $oResult[$k]->record($i); > if ($rec) { > my $marcrecord; >@@ -309,7 +316,25 @@ warn "query ".$query if $DEBUG; > } #$numresults > } > } # if $k !=0 >- # print $template->output if $firstresult !=1; >+ my $numberpending = $nremaining - 1; >+ >+ my @servers = (); >+ foreach my $id (@id) { >+ push(@servers,{id => $id}); >+ } >+ >+ $template->param( >+ breeding_loop => \@breeding_loop, >+ server => $servername[$k], >+ numberpending => $numberpending, >+ current_page => $page, >+ servers => \@servers, >+ total_pages => $total_pages, >+ ); >+ $template->param(show_nextbutton=>1) if $show_next; >+ $template->param(show_prevbutton=>1) if $page != 1; >+ >+ # print $template->output if $firstresult !=1; > $firstresult++; > > } # while nremaining >diff --git a/cataloguing/z3950_search.pl b/cataloguing/z3950_search.pl >index a44b5ea..28965fe 100755 >--- a/cataloguing/z3950_search.pl >+++ b/cataloguing/z3950_search.pl >@@ -49,6 +49,12 @@ my $stdid = $input->param('stdid'); > my $srchany = $input->param('srchany'); > my $random = $input->param('random') || rand(1000000000); # this var is not useful anymore just kept for rel2_2 compatibility > my $op = $input->param('op'); >+ >+my $page = $input->param('current_page') || 1; >+$page = $input->param('goto_page') if $input->param('changepage_goto'); >+my $show_next = 0; >+my $total_pages = 0; >+ > my $numberpending; > my $attr = ''; > my $term; >@@ -80,24 +86,28 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ > }); > > $template->param( frameworkcode => $frameworkcode, ); >+$template->param( >+ isbn => $isbn, >+ issn => $issn, >+ lccn => $lccn, >+ lccall => $lccall, >+ title => $title, >+ author => $author, >+ controlnumber=> $controlnumber, >+ stdid => $stdid, >+ srchany => $srchany, >+ biblionumber => $biblionumber, >+ dewey => $dewey, >+ subject => $subject, >+); > > if ( $op ne "do_search" ) { > my $sth = $dbh->prepare("SELECT id,host,name,checked FROM z3950servers ORDER BY rank, name"); > $sth->execute(); > my $serverloop = $sth->fetchall_arrayref( {} ); > $template->param( >- isbn => $isbn, >- issn => $issn, >- lccn => $lccn, >- lccall => $lccall, >- title => $title, >- author => $author, >- controlnumber=> $controlnumber, >- stdid => $stdid, >- srchany => $srchany, > serverloop => $serverloop, > opsearch => "search", >- biblionumber => $biblionumber, > ); > output_html_with_http_headers $input, $cookie, $template->output; > } >@@ -231,8 +241,10 @@ warn "query ".$query if $DEBUG; > my $numresults = $oResult[$k]->size(); > my $i; > my $result = ''; >- if ( $numresults > 0 ) { >- for ($i = 0; $i < (($numresults < 20) ? $numresults : 20); $i++) { >+ if ( $numresults > 0 and $numresults >= (($page-1)*20)) { >+ $show_next = 1 if $numresults >= ($page*20); >+ $total_pages = int($numresults/20)+1 if $total_pages < ($numresults/20); >+ for ($i = ($page-1)*20; $i < (($numresults < ($page*20)) ? $numresults : ($page*20)); $i++) { > my $rec = $oResult[$k]->record($i); > if ($rec) { > my $marcrecord; >@@ -280,13 +292,24 @@ warn "query ".$query if $DEBUG; > } > } # if $k !=0 > $numberpending = $nremaining - 1; >+ >+ my @servers = (); >+ foreach my $id (@id) { >+ push(@servers,{id => $id}); >+ } >+ > $template->param( > breeding_loop => \@breeding_loop, > server => $servername[$k], > numberpending => $numberpending, > biblionumber => $biblionumber, >- errconn => \@errconn >+ errconn => \@errconn, >+ current_page => $page, >+ servers => \@servers, >+ total_pages => $total_pages, > ); >+ $template->param(show_nextbutton=>1) if $show_next; >+ $template->param(show_prevbutton=>1) if $page != 1; > > output_html_with_http_headers $input, $cookie, $template->output if $numberpending == 0; > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/z3950_search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/z3950_search.tt >index 0d4ef2e..6af2ad7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/z3950_search.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/z3950_search.tt >@@ -16,7 +16,7 @@ > "aoColumnDefs": [ > { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false }, > ], >- "sPaginationType": "four_button" >+ "bPaginate": false > } ) ); > > $("#CheckAll").click(function(){ >@@ -50,6 +50,24 @@ > row.addClass("selected"); > }); > }); >+ >+[% IF ( total_pages ) %] >+function validate_goto_page(){ >+ var page = $('#goto_page').val(); >+ if(isNaN(page)) { >+ alert(_("The page entered is not a number.")); >+ return false; >+ } >+ else if(page < 1 || page > [% total_pages %] ) { >+ alert(_("The page should be a number between 1 and ") + [% total_pages %] + "."); >+ return false; >+ } >+ else { >+ return true; >+ } >+} >+[% END %] >+ > //]]> > </script> > <style type="text/css"> >@@ -155,6 +173,36 @@ tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : > [% END %] > [% END %]</tbody> > </table> >+ >+ <form method="post" action="z3950_search.pl" id="page_form" name="page_form" class="checkboxed"> >+ <input type="hidden" name="op" id="op" value="do_search" /> >+ <input type="hidden" name="current_page" id="current_page" value="[% current_page %]" /> >+ <input type="hidden" id="searchtitle" name="title" value="[% title |html %]" /> >+ <input type="hidden" id="isbn" name="isbn" value="[% isbn %]" /> >+ <input type="hidden" id="lccall" name="lccall" value="[% lccall %]" /> >+ <input type="hidden" id="author" name="author" value="[% author %]" /> >+ <input type="hidden" id="subject" name="subject" value="[% subject %]" /> >+ <input type="hidden" id="dewey" name="dewey" value="[% dewey %]" /> >+ <input type="hidden" name="frameworkcode" value="[% frameworkcode %]" /> >+ <input type="hidden" name="biblionumber" value="[% biblionumber %]" /> >+ <input type="hidden" name="controlnumber" value="[% controlnumber %]" /> >+ <input type="hidden" name="basketno" value="[% basketno %]" /> >+ <input type="hidden" name="booksellerid" value="[% booksellerid %]" /> >+ >+ [% FOREACH server IN servers %] >+ <input type="hidden" name="id" id="z3950_[% server.id %]" value="[% server.id %]" /> >+ [% END %] >+ >+ [% IF ( show_prevbutton ) %] >+ <input type="button" name="changepage_prev" value="Previous Page" onclick="$('#current_page').val([% current_page %]-1);$('#page_form').submit();" /> >+ [% END %] >+ Page [% current_page %] / [% total_pages %] >+ [% IF ( show_nextbutton ) %] >+ <input type="button" name="changepage_next" value="Next Page" onclick="$('#current_page').val([% current_page %]+1);$('#page_form').submit();" /> >+ [% END %] >+ <br />Go to page : <input id="goto_page" name="goto_page" value="[% current_page %]" size="4" /><input type="submit" name="changepage_goto" onclick="return validate_goto_page();" value="Go" /> >+ </form> >+ > [% ELSE %] > [% IF ( emptyserverlist ) %] > <div class="dialog alert">You didn't select any Z39.50 target.</div> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt >index ffd29d2..aeeecc7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/z3950_search.tt >@@ -62,6 +62,23 @@ $(document).ready(function(){ > }); > }); > >+[% IF ( total_pages ) %] >+function validate_goto_page(){ >+ var page = $('#goto_page').val(); >+ if(isNaN(page)) { >+ alert(_("The page entered is not a number.")); >+ return false; >+ } >+ else if(page < 1 || page > [% total_pages %] ) { >+ alert(_("The page should be a number between 1 and ") + [% total_pages %] + "."); >+ return false; >+ } >+ else { >+ return true; >+ } >+} >+[% END %] >+ > //]]> > </script> > <style type="text/css"> >@@ -160,6 +177,36 @@ tr.selected { background-color : #FFFFCC; } tr.selected td { background-color : > [% END %] > [% END %]</tbody> > </table> >+ >+ <form method="post" action="z3950_search.pl" id="page_form" name="page_form" class="checkboxed"> >+ <input type="hidden" name="op" id="op" value="do_search" /> >+ <input type="hidden" name="current_page" id="current_page" value="[% current_page %]" /> >+ <input type="hidden" id="title" name="title" value="[% title %]" /> >+ <input type="hidden" id="isbn" name="isbn" value="[% isbn %]" /> >+ <input type="hidden" id="lccall" name="lccall" value="[% lccall %]" /> >+ <input type="hidden" id="controlnumber" name="controlnumber" value="[% controlnumber %]" /> >+ <input type="hidden" id="srchany" name="srchany" value="[% srchany %]" /> >+ <input type="hidden" id="author" name="author" value="[% author %]" /> >+ <input type="hidden" id="subject" name="subject" value="[% subject %]" /> >+ <input type="hidden" id="dewey" name="dewey" value="[% dewey %]" /> >+ <input type="hidden" id="stdid" name="stdid" value="[% stdid %]" /> >+ <input type="hidden" name="biblionumber" value="[% biblionumber %]" /> >+ <input type="hidden" name="frameworkcode" value="[% frameworkcode %]" /> >+ >+ [% FOREACH server IN servers %] >+ <input type="hidden" name="id" id="z3950_[% server.id %]" value="[% server.id %]" /> >+ [% END %] >+ >+ [% IF ( show_prevbutton ) %] >+ <input type="button" name="changepage_prev" value="Previous Page" onclick="$('#current_page').val([% current_page %]-1);$('#page_form').submit();" /> >+ [% END %] >+ Page [% current_page %] / [% total_pages %] >+ [% IF ( show_nextbutton ) %] >+ <input type="button" name="changepage_next" value="Next Page" onclick="$('#current_page').val([% current_page %]+1);$('#page_form').submit();" /> >+ [% END %] >+ <br />Go to page : <input id="goto_page" name="goto_page" value="[% current_page %]" size="4" /><input type="submit" name="changepage_goto" onclick="return validate_goto_page();" value="Go" /> >+ </form> >+ > <p><form method="get" action="/cgi-bin/koha/cataloguing/z3950_search.pl"><input type="hidden" name="biblionumber" value="[% biblionumber %]"/><input type="hidden" name="frameworkcode" value="[% frameworkcode %]"/><input type="submit" value="Try Another Search"/></form></p> > [% ELSE %] > [% IF ( errconn ) %] >-- >1.7.9.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 8570
:
11347
| 11671