Bugzilla – Attachment 4430 Details for
Bug 6483
Paging in opac-detail when coming from a search
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed Patch for Paging in opac-detail when coming from a search
0001-Bug-6483-Paging-in-opac-detail-when-coming-from-a.patch (text/plain), 28.37 KB, created by
Salva Zaragoza Rubio
on 2011-06-08 11:26:31 UTC
(
hide
)
Description:
Proposed Patch for Paging in opac-detail when coming from a search
Filename:
MIME Type:
Creator:
Salva Zaragoza Rubio
Created:
2011-06-08 11:26:31 UTC
Size:
28.37 KB
patch
obsolete
>From fb53c76f10b5ef3dccb5c8736751a1e718e0b993 Mon Sep 17 00:00:00 2001 >From: Salvador Zaragoza Rubio <salvazm@masmedios.com> >Date: Fri, 27 May 2011 11:12:52 +0200 >Subject: [PATCH] Bug 6483 - Paging in opac-detail when coming from a search >Content-Type: text/plain; charset="utf-8" > >Add paging in opac-detail when coming from a search to be >able to continue viewing the previous and next register >from the detail without returning to the results. >The partial list pagination can be showed to increase forwarding >or rewinding in the pagination. >It's implemented for Zebra search and not build_grouped_results. > >The param busc with all the information from the search is passed >encrypted in zip and base64 for security reasons and to avoid >storing it in the session or submitting by POST. >The Compress::Zlib perl library is needed. > >A list of the biblionumbers inside the OPACnumSearchResults range >is passed to avoid repeating the searching everytime we see the >previous or next biblio. The searching will be run again when >we are going to exceed the list and a new one will be calculated >from the new search. >--- > koha-tmpl/opac-tmpl/prog/en/css/opac.css | 75 ++++++ > .../opac-tmpl/prog/en/includes/opac-facets.inc | 1 - > koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt | 92 ++++++++ > .../opac-tmpl/prog/en/modules/opac-results.tt | 4 +- > opac/opac-detail.pl | 246 ++++++++++++++++++++ > opac/opac-search.pl | 49 ++++ > 6 files changed, 464 insertions(+), 3 deletions(-) > mode change 100644 => 100755 koha-tmpl/opac-tmpl/prog/en/css/opac.css > mode change 100644 => 100755 koha-tmpl/opac-tmpl/prog/en/includes/opac-facets.inc > mode change 100644 => 100755 koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt > mode change 100644 => 100755 koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt > >diff --git a/koha-tmpl/opac-tmpl/prog/en/css/opac.css b/koha-tmpl/opac-tmpl/prog/en/css/opac.css >old mode 100644 >new mode 100755 >index aa295c9..112fed6 >--- a/koha-tmpl/opac-tmpl/prog/en/css/opac.css >+++ b/koha-tmpl/opac-tmpl/prog/en/css/opac.css >@@ -2014,3 +2014,78 @@ div.ft { > #opac-isbddetail #isbdcontents { margin-top: 2em; } > > div.bibmessage { background-color : #ffffb0; border-radius : 5px; padding : 3px; margin : 2px; } >+ >+ >+/* pagination */ >+.pagination { >+ padding-top:10px; >+ float:left; >+ width:100%; >+} >+ >+/* nav */ >+.nav { >+ float:left >+} >+.nav ul {} >+.nav li { >+ list-style:none; >+ float:left; >+ padding:4px; >+ color:#999; >+} >+ >+.nav li a { >+ text-decoration:none!important; >+} >+ >+.nav li a:hover { >+ text-decoration:underline; >+} >+ >+.nav li ul { >+ float:left; >+} >+ >+.back { >+ float:right; >+} >+ >+.back input{ >+ background:none!important; >+ color:#999!important; >+} >+#a_listResults{ >+ float:left; >+} >+#listResults{ >+ line-height: 0.7em; >+} >+.pagination_list { >+ float:bottom >+} >+.pagination_list ul { >+ margin-left: 150px; >+ padding-top: 40px; >+ width: 350px; >+} >+.pagination_list li { >+ list-style:none; >+ float:bottom; >+ padding:4px; >+ color:#999; >+ border-bottom : 1px solid #DDDDDD; >+} >+.pagination_list li.highlight { >+ background-color : #F3F3F3; >+ border-top : 1px solid #DDDDDD; >+ border-bottom : 1px solid #DDDDDD; >+} >+.pagination_list span.li_pag_index { >+ color : #999; >+ text-align: left; >+ font-size: 15px; >+ font-weight : bold; >+ padding-right: 10px; >+} >+ >diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/opac-facets.inc b/koha-tmpl/opac-tmpl/prog/en/includes/opac-facets.inc >old mode 100644 >new mode 100755 >index 4931283..4647fa0 >--- a/koha-tmpl/opac-tmpl/prog/en/includes/opac-facets.inc >+++ b/koha-tmpl/opac-tmpl/prog/en/includes/opac-facets.inc >@@ -2,7 +2,6 @@ > [% IF ( facets_loop ) %] > <div id="search-facets"> > <h4>Refine your search</h4> >-[% query_cgi %] > <ul> > <li>Availability<ul><li>[% IF ( available ) %]Showing only <strong>available</strong> items. <a href="/cgi-bin/koha/opac-search.pl?[% query_cgi |html %][% limit_cgi_not_availablity %][% IF ( sort_by ) %]&sort_by=[% sort_by %][% END %]">Show all items</a>[% ELSE %]Limit to <a href="/cgi-bin/koha/opac-search.pl?[% query_cgi |html %][% limit_cgi |html %][% IF ( sort_by ) %]&sort_by=[% sort_by %][% END %]&limit=available">currently available items.</a>[% END %]</li></ul> > [% IF ( related ) %] <li>(related searches: [% FOREACH relate IN related %][% relate.related_search %][% END %])</li>[% END %] >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >old mode 100644 >new mode 100755 >index ff4b52c..5bb906f >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt >@@ -3,6 +3,18 @@ > <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script> > <script type="text/JavaScript" language="JavaScript"> > //<![CDATA[ >+ [% IF ( busc ) %] >+ var arrPagination = new Array(); >+ var pag_index_ini = 0; >+ [% IF ( listResults ) %] >+ [% FOREACH listResult IN listResults %] >+ if (!pag_index_ini) pag_index_ini = [% listResult.index %]; >+ arrPagination[[% listResult.index %]] = {url:"[% listResult.url %]", title:"[% listResult.title|html %]", author:"[% listResult.author|html %]", biblionumber:[% listResult.biblionumber %]}; >+ [% END %] >+ [% END %] >+ [% END %] >+ >+ > $(document).ready(function() { > $('#bibliodescriptions > ul').tabs(); > [% IF ( opacuserlogin ) %][% IF ( loggedinusername ) %][% IF ( TagsEnabled ) %]$("#tagform").hide(); >@@ -24,9 +36,58 @@ > });[% IF ( GoogleJackets ) %] > KOHA.Google.GetCoverFromIsbn([% covernewwindow %]);[% END %][% IF ( opacuserlogin ) %][% IF ( loggedinusername ) %][% IF ( TagsEnabled ) %] > $(".tagbutton").click(KOHA.Tags.add_tag_button);[% END %][% END %][% END %] >+ $("#a_listResults").click(function() { >+ var ul_in = $(this).next("ul"); >+ var div_pag_list = $(".pagination_list"); >+ if (ul_in.css("display") == 'none') { >+ ul_in.show(); >+ $(this).attr('title','Hide pagination list'); >+ div_pag_list.show(); >+ renderPagination(pag_index_ini, arrPagination.length - 1, $("#ul_pagination_list"), false); >+ } else { >+ ul_in.hide(); >+ $(this).attr('title','Show pagination list'); >+ div_pag_list.hide(); >+ } >+ }); >+ $(".a_pag").mouseover(function() { >+ var id = $(this).attr("id"); >+ renderPagination(parseInt(id.substr("a_pag_".length), 10), arrPagination.length - 1, $("#ul_pagination_list"), true); >+ }); > > }); > >+ >+function renderPagination(index, total, ul, highlIndex) >+{ >+ for (var i = pag_index_ini; i <= total; i++) { >+ if (arrPagination[i] == undefined || arrPagination[i].url == "") continue; >+ $("#li_pag_" + i).remove(); >+ } >+ var j = 0; >+ for (i = index; i <= total; i++) { >+ if (arrPagination[i] == undefined || arrPagination[i].url == "") continue; >+ var li = $("<li id='li_pag_" + i + "' " + ((j % 2 == 0)?"class='highlight'":"") + " title='Go to detail' />"); >+ var html = "<span class='li_pag_index'>" + i + "</span><a href='" + arrPagination[i].url + "'>" + arrPagination[i].title + "</a>"; >+ if (arrPagination[i].author) html += "<br /> by " + arrPagination[i].author; >+ li.html(html); >+ if (highlIndex && i == index) li.css("backgroundColor", "#DDDDDD"); >+ ul.append(li); >+ j++; >+ } >+ for (i = pag_index_ini; i < index; i++) { >+ if (arrPagination[i] == undefined || arrPagination[i].url == "") continue; >+ $("#li_pag_" + i).remove(); >+ var li = $("<li id='li_pag_" + i + "' " + ((j % 2 == 0)?"class='highlight'":"") + " title='Go to detail' />"); >+ var html = "<span class='li_pag_index'>" + i + "</span><a href='" + arrPagination[i].url + "'>" + arrPagination[i].title + "</a>"; >+ if (arrPagination[i].author) html += "<br /> by " + arrPagination[i].author; >+ li.html(html); >+ ul.append(li); >+ j++; >+ } >+}//renderPagination >+ >+ > YAHOO.util.Event.onContentReady("furtherm", function () { > $("#furtherm").css("display","block").css("visibility","hidden"); > $("#furthersearches").parent().show(); >@@ -787,6 +848,37 @@ YAHOO.util.Event.onContentReady("furtherm", function () { > [% END %] > [% END %] > >+<div class="pagination"> >+[% IF ( busc ) %] >+<div class="nav"> >+ <ul> >+ <li class="first">[% IF ( previous ) %]<a href="[% previous %]" title="See: [% IF ( previousTitle ) %][% previousTitle |html %][% ELSE %]previous biblio[% END %]">« previous</a>[% ELSE %]previous[% END %]</li> >+ <li class="last">[% IF ( next ) %]<a href="[% next %]" title="See: [% IF ( nextTitle ) %][% nextTitle |html %][% ELSE %]next biblio[% END %]">next »</a>[% ELSE %]next[% END %]</li> >+ [% IF ( listResults ) %] >+ <li><a href="#" id="a_listResults" title="Show pagination list">...</a><ul id="listResults" style="display:none"> >+ [% FOREACH listResult IN listResults %] >+ <li>[% IF ( listResult.url ) %]<a href="[% listResult.url %]" title="See biblio "[% listResult.title|html %]" [% IF ( listResult.author ) %] by "[% listResult.author|html %]"[% END %] with biblionumber [% listResult.biblionumber %]" class="a_pag" id="a_pag_[% listResult.index %]">[% listResult.index %]</a>[% ELSE %][% listResult.index %][% END %]</li> >+ [% END %] >+ </ul></li> >+ [% END %] >+ </ul> >+</div> >+<div class="back"> >+ <span class="btn boton_gris"><input style="font-weight:normal !important;" type="button" value="« back to results" onclick="window.location.href = 'opac-search.pl?[% busc %]'" /></span> >+</div> >+[% IF ( listResults ) %] >+<div class="pagination_list" style="display:none"> >+ <ul id="ul_pagination_list"> >+ </ul> >+</div> >+[% END %] >+[% ELSE %] >+<div class="back"> >+ <span class="btn boton_gris"><input style="font-weight:normal !important;" type="button" value="« back" onclick="history.back(-1);" /></span> >+</div> >+[% END %] >+</div> >+ > </div> > </div> > </div> >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >old mode 100644 >new mode 100755 >index f371db1..2ddba50 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt >@@ -413,7 +413,7 @@ $(document).ready(function(){ > [% IF ( SEARCH_RESULT.BiblioDefaultViewmarc ) %]<a class="title" href="/cgi-bin/koha/opac-MARCdetail.pl?biblionumber=[% SEARCH_RESULT.biblionumber |url %]" title="View details for this title"> > [% ELSE %] > [% IF ( SEARCH_RESULT.BiblioDefaultViewisbd ) %]<a class="title" href="/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber=[% SEARCH_RESULT.biblionumber |url %]" title="View details for this title"> >- [% ELSE %]<a class="title" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% SEARCH_RESULT.biblionumber |url %]" title="View details for this title"> >+ [% ELSE %]<a class="title" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% SEARCH_RESULT.biblionumber |url %][% pasarParams |url %]" title="View details for this title"> > [% END %] > [% END %] > [% IF ( SEARCH_RESULT.title ) %][% SEARCH_RESULT.title |html %][% ELSE %]No title[% END %] [% FOREACH subtitl IN SEARCH_RESULT.subtitle %][% subtitl.subfield %][% END %]</a> >@@ -526,7 +526,7 @@ $(document).ready(function(){ > [% IF ( opacbookbag ) %]<a class="addtocart" href="#" onclick="addRecord('[% SEARCH_RESULT.biblionumber %]'); return false;">Add to Cart</a>[% END %] > </span> > </td><td> >- <a class="p1" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% SEARCH_RESULT.biblionumber %]"> >+ <a class="p1" href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% SEARCH_RESULT.biblionumber %][% pasarParams |url %]"> > [% IF ( OPACAmazonEnabled ) %][% IF ( OPACAmazonCoverImages ) %][% IF ( SEARCH_RESULT.normalized_isbn ) %]<img src="http://images.amazon.com/images/P/[% SEARCH_RESULT.normalized_isbn %].01.TZZZZZZZ.jpg" alt="" class="thumbnail" />[% ELSE %]<span class="no-image">No cover image available</span>[% END %][% END %][% END %] > > [% IF ( SyndeticsEnabled ) %][% IF ( SyndeticsCoverImages ) %][% IF ( using_https ) %] >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index b357a56..7bcf0e8 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -66,6 +66,252 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( > > my $biblionumber = $query->param('biblionumber') || $query->param('bib'); > >+# We look for the busc param to build the simple paging from the search >+my %paging = (previous => {}, next => {}); >+if ($query->param('busc')) { >+ use Compress::Zlib; >+ use MIME::Base64; >+ use URI::Escape; >+ use C4::Search; >+ >+ # Rebuild the encrypted busc param >+ sub rebuildBuscParam >+ { >+ my $arrParamsBusc = shift; >+ >+ my $pasarParams = ''; >+ my $j = 0; >+ for (keys %$arrParamsBusc) { >+ if ($_ =~ /^(?:query|listBiblios|query_type|simple_query|total|offset|offsetPrev|count|expand|scan)/) { >+ if (defined($arrParamsBusc->{$_})) { >+ $pasarParams .= '&' if ($j); >+ $pasarParams .= $_ . '=' . $arrParamsBusc->{$_}; >+ $j++; >+ } >+ } else { >+ for my $value (@{$arrParamsBusc->{$_}}) { >+ $pasarParams .= '&' if ($j); >+ $pasarParams .= $_ . '=' . $value; >+ $j++; >+ } >+ } >+ } >+ my $pasarParamsEnc = compress($pasarParams, Z_BEST_COMPRESSION); >+ $pasarParamsEnc = encode_base64($pasarParamsEnc); >+ $pasarParamsEnc = uri_escape($pasarParamsEnc); >+ return $pasarParamsEnc; >+ }#rebuildBuscParam >+ >+ my $busc = uri_unescape($query->param("busc")); >+ my $buscOrig = uri_escape($busc); >+ $busc = decode_base64($busc); >+ $busc = uncompress($busc); >+ my $buscParam = ''; >+ my $j = 0; >+ # Rebuild the query for the button "back to results" >+ for (split(/\&(?:amp;)?/, $busc)) { >+ unless ($_ =~ /^(?:query|listBiblios|query_type|simple_query|total|offsetPrev)/) { >+ $buscParam .= '&' unless ($j == 0); >+ $buscParam .= $_; >+ $j++; >+ } >+ } >+ $template->param('busc' => $buscParam); >+ my ($key, $value); >+ my %arrParamsBusc = (); >+ for (split(/\&(?:amp;)?/, $busc)) { >+ ($key, $value) = split(/=/, $_, 2); >+ if ($key =~ /^(?:query|listBiblios|query_type|simple_query|total|offset|offsetPrev|count|expand|scan)/) { >+ $arrParamsBusc{$key} = $value; >+ } else { >+ unless (exists($arrParamsBusc{$key})) { >+ $arrParamsBusc{$key} = []; >+ } >+ push @{$arrParamsBusc{$key}}, $value; >+ } >+ } >+ my $searchAgain = 0; >+ my $count = C4::Context->preference('OPACnumSearchResults') || 20; >+ my $results_per_page = ($arrParamsBusc{'count'} && $arrParamsBusc{'count'} =~ /^[0-9]+?/)?$arrParamsBusc{'count'}:$count; >+ my $offset = ($arrParamsBusc{'offset'} && $arrParamsBusc{'offset'} =~ /^[0-9]+?/)?$arrParamsBusc{'offset'}:0; >+ my $offsetSearch; >+ my @arrBiblios; >+ # We are inside the list of biblios and we don't have to search >+ if (exists($arrParamsBusc{'listBiblios'}) && $arrParamsBusc{'listBiblios'} =~ /^[0-9]+(?:,[0-9]+)*$/) { >+ @arrBiblios = split(',', $arrParamsBusc{'listBiblios'}); >+ if (@arrBiblios) { >+ # We are at the first item of the block >+ if ($arrBiblios[0] == $biblionumber) { >+ if (@arrBiblios > 1) { >+ for (my $j = 1; $j < @arrBiblios; $j++) { >+ next unless ($arrBiblios[$j]); >+ $paging{'next'}->{biblionumber} = $arrBiblios[$j]; >+ last; >+ } >+ } >+ # search again if we are not at the first searching block >+ if ($offset) { >+ $searchAgain = 1; >+ $offsetSearch = $offset - $results_per_page; >+ } >+ # we are at the last item of the block >+ } elsif ($arrBiblios[$#arrBiblios] == $biblionumber) { >+ for (my $j = $#arrBiblios - 1; $j >= 0; $j--) { >+ next unless ($arrBiblios[$j]); >+ $paging{'previous'}->{biblionumber} = $arrBiblios[$j]; >+ last; >+ } >+ if (!$offset) { >+ # search again if we are at the first block and there is more results >+ $searchAgain = 1 if ($arrParamsBusc{'total'} != @arrBiblios); >+ } else { >+ # search again if we aren't at the first block and there is more results >+ $searchAgain = 1 if ($arrParamsBusc{'total'} > ($offset + @arrBiblios)); >+ } >+ $offsetSearch = $offset + $results_per_page if ($searchAgain); >+ } else { >+ for (my $j = 1; $j < $#arrBiblios; $j++) { >+ if ($arrBiblios[$j] == $biblionumber) { >+ for (my $z = $j - 1; $z >= 0; $z--) { >+ next unless ($arrBiblios[$z]); >+ $paging{'previous'}->{biblionumber} = $arrBiblios[$z]; >+ last; >+ } >+ for (my $z = $j + 1; $z < @arrBiblios; $z++) { >+ next unless ($arrBiblios[$z]); >+ $paging{'next'}->{biblionumber} = $arrBiblios[$z]; >+ last; >+ } >+ last; >+ } >+ } >+ } >+ } >+ $offsetSearch = 0 if (defined($offsetSearch) && $offsetSearch < 0); >+ unless ($searchAgain) { >+ $paging{'previous'}->{busc} = $buscOrig if ($paging{'previous'}->{biblionumber}); >+ $paging{'next'}->{busc} = $buscOrig if ($paging{'next'}->{biblionumber}); >+ } else { >+ if ($paging{'previous'}->{biblionumber}) { >+ $paging{'previous'}->{busc} = $buscOrig; >+ } >+ if ($paging{'next'}->{biblionumber}) { >+ $paging{'next'}->{busc} = $buscOrig; >+ } >+ if (!$paging{'previous'}->{biblionumber}) { >+ $arrParamsBusc{'offsetPrev'} = $offset; >+ $arrParamsBusc{'offset'} = $offsetSearch; >+ delete $arrParamsBusc{'listBiblios'}; >+ $paging{'previous'}->{busc} = rebuildBuscParam(\%arrParamsBusc); >+ } elsif (!$paging{'next'}->{biblionumber} && $arrParamsBusc{'total'} > ($offset + @arrBiblios)) { >+ $arrParamsBusc{'offsetPrev'} = $offset; >+ $arrParamsBusc{'offset'} = $offsetSearch; >+ delete $arrParamsBusc{'listBiblios'}; >+ $paging{'next'}->{busc} = rebuildBuscParam(\%arrParamsBusc); >+ } >+ } >+ } else { # We have to search >+ my $expanded_facet = $arrParamsBusc{'expand'}; >+ my $branches = GetBranches(); >+ my @servers; >+ @servers = @{$arrParamsBusc{'server'}} if $arrParamsBusc{'server'}; >+ @servers = ("biblioserver") unless (@servers); >+ my $default_sort_by = C4::Context->preference('OPACdefaultSortField')."_".C4::Context->preference('OPACdefaultSortOrder') if (C4::Context->preference('OPACdefaultSortField') && C4::Context->preference('OPACdefaultSortOrder')); >+ my @sort_by = @{$arrParamsBusc{'sort_by'}} if $arrParamsBusc{'sort_by'}; >+ $sort_by[0] = $default_sort_by if !$sort_by[0] && defined($default_sort_by); >+ my ($error, $results_hashref, $facets); >+ eval { >+ ($error, $results_hashref, $facets) = getRecords($arrParamsBusc{'query'},$arrParamsBusc{'simple_query'},\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$arrParamsBusc{'query_type'},$arrParamsBusc{'scan'}); >+ }; >+ my $hits; >+ my @newresults; >+ for (my $i=0;$i<@servers;$i++) { >+ my $server = $servers[$i]; >+ $hits = $results_hashref->{$server}->{"hits"}; >+ @newresults = searchResults('opac', '', $hits, $results_per_page, $offset, $arrParamsBusc{'scan'}, @{$results_hashref->{$server}->{"RECORDS"}},, C4::Context->preference('hidelostitems')); >+ } >+ # build the new listBiblios >+ my $listBiblios = ''; >+ my $j = 0; >+ # add new list param >+ foreach (@newresults) { >+ my $bibnum = ($_->{biblionumber})?$_->{biblionumber}:0; >+ $listBiblios .= $bibnum . ','; >+ $j++; >+ last if ($j == $results_per_page); >+ } >+ chop $listBiblios if ($listBiblios =~ /,$/); >+ $arrParamsBusc{'listBiblios'} = $listBiblios; >+ @arrBiblios = split(',', $arrParamsBusc{'listBiblios'}); >+ if (@arrBiblios && !$biblionumber) { >+ if (defined($arrParamsBusc{'offsetPrev'})) { >+ $biblionumber = ($offset > $arrParamsBusc{'offsetPrev'})?$arrBiblios[0]:$arrBiblios[$#arrBiblios]; >+ } else { >+ $biblionumber = $arrBiblios[0]; >+ } >+ } >+ # From the new list we build again the next and previous result >+ if (@arrBiblios) { >+ if ($arrBiblios[$#arrBiblios] == $biblionumber) { >+ for (my $j = 0; $j < @newresults; $j++) { >+ next unless ($newresults[$j]); >+ $paging{'previous'}->{biblionumber} = $newresults[$j]->{biblionumber}; >+ last; >+ } >+ } elsif ($arrBiblios[0] == $biblionumber) { >+ for (my $j = $#newresults; $j >= 0; $j--) { >+ next unless ($newresults[$j]); >+ $paging{'next'}->{biblionumber} = $newresults[$j]->{biblionumber}; >+ last; >+ } >+ } >+ } >+ # build new busc param >+ $buscOrig = rebuildBuscParam(\%arrParamsBusc); >+ if ($paging{'next'}->{biblionumber}) { >+ $paging{'next'}->{busc} = $buscOrig; >+ } >+ if ($paging{'previous'}->{biblionumber}) { >+ $paging{'previous'}->{busc} = $buscOrig; >+ } >+ if (!$paging{'previous'}->{biblionumber}) { >+ $arrParamsBusc{'offset'} = $arrParamsBusc{'offsetPrev'}; >+ $arrParamsBusc{'offsetPrev'} = $offset; >+ delete $arrParamsBusc{'listBiblios'}; >+ $paging{'previous'}->{busc} = rebuildBuscParam(\%arrParamsBusc); >+ } elsif (!$paging{'next'}->{biblionumber} && $arrParamsBusc{'total'} > ($offset + @arrBiblios)) { >+ $arrParamsBusc{'offset'} = $arrParamsBusc{'offsetPrev'}; >+ $arrParamsBusc{'offsetPrev'} = $offset; >+ delete $arrParamsBusc{'listBiblios'}; >+ $paging{'next'}->{busc} = rebuildBuscParam(\%arrParamsBusc); >+ } >+ } >+ >+ # Previous biblio >+ my $previous = 'opac-detail.pl?' . (($paging{'previous'}->{biblionumber})?'biblionumber=' . $paging{'previous'}->{biblionumber} . '&':'') . 'busc=' . $paging{'previous'}->{busc} if ($paging{'previous'}->{busc}); >+ my $dataBiblioPaging = GetBiblioData($paging{'previous'}->{biblionumber}); >+ if ($dataBiblioPaging) { >+ $template->param('previousTitle' => $dataBiblioPaging->{'title'}); >+ } >+ # Next biblio >+ my $next = 'opac-detail.pl?' . (($paging{'next'}->{biblionumber})?'biblionumber=' . $paging{'next'}->{biblionumber} . '&':'') . 'busc=' . $paging{'next'}->{busc} if ($paging{'next'}->{busc}); >+ $dataBiblioPaging = GetBiblioData($paging{'next'}->{biblionumber}); >+ if ($dataBiblioPaging) { >+ $template->param('nextTitle' => $dataBiblioPaging->{'title'}); >+ } >+ $template->param('previous' => $previous, 'next' => $next); >+ # Partial list of biblio results >+ my @listResults; >+ for (my $j = 0; $j < @arrBiblios; $j++) { >+ next unless ($arrBiblios[$j]); >+ $dataBiblioPaging = GetBiblioData($arrBiblios[$j]) if ($arrBiblios[$j] != $biblionumber); >+ push @listResults, {index => $j + 1 + $offset, biblionumber => $arrBiblios[$j], title => ($arrBiblios[$j] == $biblionumber)?'':$dataBiblioPaging->{title}, author => ($arrBiblios[$j] != $biblionumber && $dataBiblioPaging->{author})?$dataBiblioPaging->{author}:'', url => ($arrBiblios[$j] == $biblionumber)?'':'opac-detail.pl?biblionumber=' . $arrBiblios[$j] . '&busc=' . $buscOrig}; >+ } >+ $template->param('listResults' => \@listResults) if (@listResults); >+} >+ >+ >+ > $template->param( 'AllowOnShelfHolds' => C4::Context->preference('AllowOnShelfHolds') ); > $template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) ); > >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index 7f247c7..8bfcda2 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -39,6 +39,9 @@ use C4::Branch; # GetBranches > use POSIX qw(ceil floor strftime); > use URI::Escape; > use Storable qw(thaw freeze); >+use Compress::Zlib; >+use MIME::Base64; >+ > > > my $DisplayMultiPlaceHold = C4::Context->preference("DisplayMultiPlaceHold"); >@@ -84,6 +87,8 @@ else { > authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ), > } > ); >+ >+ > if ($template_name eq 'opac-results.tmpl') { > $template->param('COinSinOPACResults' => C4::Context->preference('COinSinOPACResults')); > } >@@ -269,6 +274,21 @@ my $params = $cgi->Vars; > my $tag; > $tag = $params->{tag} if $params->{tag}; > >+ >+# String with params with the search criteria for the paging in opac-detail >+my $pasarParams = ''; >+my $j = 0; >+for (keys %$params) { >+ my @pasarParam = split("\0", $params->{$_}); >+ for my $paramValue(@pasarParam) { >+ $pasarParams .= '&' if ($j > 0); >+ $pasarParams .= $_ . '=' . $paramValue; >+ $j++; >+ } >+} >+# >+ >+ > # Params that can have more than one value > # sort by is used to sort the query > # in theory can have more than one but generally there's just one >@@ -422,6 +442,9 @@ elsif (C4::Context->preference('NoZebra')) { > ($error, $results_hashref, $facets) = C4::Search::pazGetRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan); > }; > } else { >+ $pasarParams .= '&query=' . $query; >+ $pasarParams .= '&simple_query=' . $simple_query; >+ $pasarParams .= '&query_type=' . $query_type if ($query_type); > eval { > ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan); > }; >@@ -543,6 +566,32 @@ for (my $i=0;$i<@servers;$i++) { > exit; > } > if ($hits) { >+ if (!C4::Context->preference('NoZebra') && !$build_grouped_results) { >+ # We build the encrypted list of first OPACnumSearchResults biblios to pass with the search criteria for paging on opac-detail >+ $pasarParams .= '&listBiblios='; >+ my $j = 0; >+ foreach (@newresults) { >+ my $bibnum = ($_->{biblionumber})?$_->{biblionumber}:0; >+ $pasarParams .= $bibnum . ','; >+ $j++; >+ last if ($j == $results_per_page); >+ } >+ chop $pasarParams if ($pasarParams =~ /,$/); >+ $pasarParams .= '&total=' . int($total) if ($pasarParams !~ /total=(?:[0-9]+)?/); >+ if ($pasarParams) { >+ my $pasarParamsEnc = compress($pasarParams, Z_BEST_COMPRESSION); >+ $pasarParamsEnc = encode_base64($pasarParamsEnc); >+ $pasarParamsEnc = uri_escape($pasarParamsEnc); >+ my $pasarParamsFinal = '&busc=' . $pasarParamsEnc; >+ $template->param('pasarParams' => $pasarParamsFinal); >+ foreach (@newresults) { >+ if ($_->{XSLTResultsRecord}) { >+ $_->{XSLTResultsRecord} =~ s/(opac-detail\.pl\?biblionumber=[0-9]+)/$1$pasarParamsFinal/g; >+ } >+ } >+ } >+ # >+ } > $template->param(total => $hits); > my $limit_cgi_not_availablity = $limit_cgi; > $limit_cgi_not_availablity =~ s/&limit=available//g if defined $limit_cgi_not_availablity; >-- >1.5.6.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 6483
:
4430
|
4446
|
4476
|
4477
|
4484
|
4495
|
4496
|
4497
|
4509
|
4512
|
4977
|
5114
|
5988