Bugzilla – Attachment 4446 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 Add paging in opac-detail when coming from a search with session storage
0001-Bug-6483-Paging-in-opac-detail-when-coming-from-a-se.patch (text/plain), 29.29 KB, created by
Salva Zaragoza Rubio
on 2011-06-13 16:16:31 UTC
(
hide
)
Description:
Proposed patch for Add paging in opac-detail when coming from a search with session storage
Filename:
MIME Type:
Creator:
Salva Zaragoza Rubio
Created:
2011-06-13 16:16:31 UTC
Size:
29.29 KB
patch
obsolete
>From 32bbaf93f5dff8f2e4c9af96b23cc373b72bfa01 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 stored >on the session when running opac-search and opac-detail, outside these >pages the busc param is removed from the session. > >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. >--- > C4/Auth.pm | 5 + > koha-tmpl/opac-tmpl/prog/en/css/opac.css | 88 ++++++ > .../opac-tmpl/prog/en/includes/opac-facets.inc | 1 - > koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt | 104 +++++++- > opac/opac-detail.pl | 284 +++++++++++++++++++- > opac/opac-search.pl | 37 +++ > 6 files changed, 516 insertions(+), 3 deletions(-) > mode change 100644 => 100755 C4/Auth.pm > 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/C4/Auth.pm b/C4/Auth.pm >old mode 100644 >new mode 100755 >index b416449..cd4e520 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -386,6 +386,11 @@ sub get_template_and_user { > my $LibraryNameTitle = C4::Context->preference("LibraryName"); > $LibraryNameTitle =~ s/<(?:\/?)(?:br|p)\s*(?:\/?)>/ /sgi; > $LibraryNameTitle =~ s/<(?:[^<>'"]|'(?:[^']*)'|"(?:[^"]*)")*>//sg; >+ # clean up the busc param in the session if the page is not opac-detail >+ if ($in->{'template_name'} =~ /opac-.+\.(?:tt|tmpl)$/ && $in->{'template_name'} !~ /opac-detail\.[a-z]+$/) { >+ my $sessionSearch = get_session($in->{'query'}->cookie("CGISESSID")); >+ $sessionSearch->clear(["busc"]) if ($sessionSearch->param("busc")); >+ } > # variables passed from CGI: opac_css_override and opac_search_limits. > my $opac_search_limit = $ENV{'OPAC_SEARCH_LIMIT'}; > my $opac_limit_override = $ENV{'OPAC_LIMIT_OVERRIDE'}; >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..891db4a >--- a/koha-tmpl/opac-tmpl/prog/en/css/opac.css >+++ b/koha-tmpl/opac-tmpl/prog/en/css/opac.css >@@ -2014,3 +2014,91 @@ 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%; >+} >+ >+.pagination_menu { >+ text-align: center; >+ width:100%; >+} >+ >+.pagination_menu a { >+ text-decoration:none!important; >+} >+ >+.pagination_menu a:hover { >+ text-decoration:underline; >+} >+ >+/* 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 2129026..3507880 >--- 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..44617f1 >--- 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,17 @@ > <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 = [% indexPag %]; >+ [% IF ( listResults ) %] >+ [% FOREACH listResult IN listResults %] >+ 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 +35,64 @@ > });[% IF ( GoogleJackets ) %] > KOHA.Google.GetCoverFromIsbn([% covernewwindow %]);[% END %][% IF ( opacuserlogin ) %][% IF ( loggedinusername ) %][% IF ( TagsEnabled ) %] > $(".tagbutton").click(KOHA.Tags.add_tag_button);[% END %][% END %][% END %] >+ [% IF ( busc ) %] >+ $("#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(); >+ var newtitle = $(this).attr('title').replace('Show', 'Hide') >+ $(this).attr('title',newtitle); >+ div_pag_list.show(); >+ renderPagination(pag_index_ini, arrPagination.length - 1, $("#ul_pagination_list"), false); >+ } else { >+ ul_in.hide(); >+ var newtitle = $(this).attr('title').replace('Hide', 'Show') >+ $(this).attr('title',newtitle); >+ 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); >+ }); >+ [% END %] > > }); > >+ >+[% IF ( busc ) %] >+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 >+[% END %] >+ >+ > YAHOO.util.Event.onContentReady("furtherm", function () { > $("#furtherm").css("display","block").css("visibility","hidden"); > $("#furthersearches").parent().show(); >@@ -787,6 +853,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 ([% indexPag %]-[% indexPagEnd %] / [% totalPag %])">...</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> >@@ -832,7 +929,12 @@ YAHOO.util.Event.onContentReady("furtherm", function () { > </div> > </div> > [% END %] >- >+[% IF ( busc ) %] >+ <div class="detailtagcell"> >+ <div class="pagination_menu"><strong>Pagination</strong>: [% IF ( previous ) %]<a href="[% previous %]" title="See: [% IF ( previousTitle ) %][% previousTitle |html %][% ELSE %]previous biblio[% END %]">« previous</a>[% ELSE %]previous[% END %] >+ [% IF ( next ) %]<a href="[% next %]" title="See: [% IF ( nextTitle ) %][% nextTitle |html %][% ELSE %]next biblio[% END %]">next »</a>[% ELSE %]next[% END %]</div> >+ </div> >+[% END %] > <div id="export" class="detailtagcell"> > <form method="get" action="/cgi-bin/koha/opac-export.pl"> > <label for="format">Save Record:</label> >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 >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index b357a56..510ade3 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -23,7 +23,7 @@ use strict; > use warnings; > > use CGI; >-use C4::Auth; >+use C4::Auth qw(:DEFAULT get_session); > use C4::Branch; > use C4::Koha; > use C4::Serials; #uses getsubscriptionfrom biblionumber >@@ -66,6 +66,288 @@ 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 $session = get_session($query->cookie("CGISESSID")); >+my %paging = (previous => {}, next => {}); >+if ($session->param('busc')) { >+ use C4::Search; >+ >+ # Rebuild the string to store on session >+ sub rebuildBuscParam >+ { >+ my $arrParamsBusc = shift; >+ >+ my $pasarParams = ''; >+ my $j = 0; >+ for (keys %$arrParamsBusc) { >+ if ($_ =~ /^(?:query|listBiblios|newlistBiblios|query_type|simple_query|total|offset|offsetSearch|next|previous|count|expand|scan)/) { >+ if (defined($arrParamsBusc->{$_})) { >+ $pasarParams .= '&' if ($j); >+ $pasarParams .= $_ . '=' . $arrParamsBusc->{$_}; >+ $j++; >+ } >+ } else { >+ for my $value (@{$arrParamsBusc->{$_}}) { >+ $pasarParams .= '&' if ($j); >+ $pasarParams .= $_ . '=' . $value; >+ $j++; >+ } >+ } >+ } >+ return $pasarParams; >+ }#rebuildBuscParam >+ >+ # Search given the current values from the busc param >+ sub searchAgain >+ { >+ my ($arrParamsBusc, $offset, $results_per_page) = @_; >+ >+ 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')); >+ } >+ return \@newresults; >+ }#searchAgain >+ >+ # Build the current list of biblionumbers in this search >+ sub buildListBiblios >+ { >+ my ($newresultsRef, $results_per_page) = @_; >+ >+ my $listBiblios = ''; >+ my $j = 0; >+ foreach (@$newresultsRef) { >+ my $bibnum = ($_->{biblionumber})?$_->{biblionumber}:0; >+ $listBiblios .= $bibnum . ','; >+ $j++; >+ last if ($j == $results_per_page); >+ } >+ chop $listBiblios if ($listBiblios =~ /,$/); >+ return $listBiblios; >+ }#buildListBiblios >+ >+ my $busc = $session->param("busc"); >+ my @arrBusc = split(/\&(?:amp;)?/, $busc); >+ my ($key, $value); >+ my %arrParamsBusc = (); >+ for (@arrBusc) { >+ ($key, $value) = split(/=/, $_, 2); >+ if ($key =~ /^(?:query|listBiblios|newlistBiblios|query_type|simple_query|next|previous|total|offset|offsetSearch|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; >+ $arrParamsBusc{'count'} = $results_per_page; >+ my $offset = ($arrParamsBusc{'offset'} && $arrParamsBusc{'offset'} =~ /^[0-9]+?/)?$arrParamsBusc{'offset'}:0; >+ # The value OPACnumSearchResults has changed and the search has to be rebuild >+ if ($count != $results_per_page) { >+ if (exists($arrParamsBusc{'listBiblios'}) && $arrParamsBusc{'listBiblios'} =~ /^[0-9]+(?:,[0-9]+)*$/) { >+ my $indexBiblio = 0; >+ my @arrBibliosAux = split(',', $arrParamsBusc{'listBiblios'}); >+ for (@arrBibliosAux) { >+ last if ($_ == $biblionumber); >+ $indexBiblio++; >+ } >+ $indexBiblio += $offset; >+ $offset = int($indexBiblio / $count) * $count; >+ $arrParamsBusc{'offset'} = $offset; >+ } >+ $arrParamsBusc{'count'} = $count; >+ $results_per_page = $count; >+ my $newresultsRef = searchAgain(\%arrParamsBusc, $offset, $results_per_page); >+ $arrParamsBusc{'listBiblios'} = buildListBiblios($newresultsRef, $results_per_page); >+ delete $arrParamsBusc{'previous'} if (exists($arrParamsBusc{'previous'})); >+ delete $arrParamsBusc{'next'} if (exists($arrParamsBusc{'next'})); >+ delete $arrParamsBusc{'offsetSearch'} if (exists($arrParamsBusc{'offsetSearch'})); >+ delete $arrParamsBusc{'newlistBiblios'} if (exists($arrParamsBusc{'newlistBiblios'})); >+ my $newbusc = rebuildBuscParam(\%arrParamsBusc); >+ $session->param("busc" => $newbusc); >+ @arrBusc = split(/\&(?:amp;)?/, $newbusc); >+ } else { >+ my $modifyListBiblios = 0; >+ # We come from a previous click >+ if (exists($arrParamsBusc{'previous'})) { >+ $modifyListBiblios = 1 if ($biblionumber == $arrParamsBusc{'previous'}); >+ delete $arrParamsBusc{'previous'}; >+ } elsif (exists($arrParamsBusc{'next'})) { # We come from a next click >+ $modifyListBiblios = 2 if ($biblionumber == $arrParamsBusc{'next'}); >+ delete $arrParamsBusc{'next'}; >+ } >+ if ($modifyListBiblios) { >+ if (exists($arrParamsBusc{'newlistBiblios'})) { >+ my $listBibliosAux = $arrParamsBusc{'listBiblios'}; >+ $arrParamsBusc{'listBiblios'} = $arrParamsBusc{'newlistBiblios'}; >+ my @arrAux = split(',', $listBibliosAux); >+ $arrParamsBusc{'newlistBiblios'} = $listBibliosAux; >+ if ($modifyListBiblios == 1) { >+ $arrParamsBusc{'next'} = $arrAux[0]; >+ $paging{'next'}->{biblionumber} = $arrAux[0]; >+ }else { >+ $arrParamsBusc{'previous'} = $arrAux[$#arrAux]; >+ $paging{'previous'}->{biblionumber} = $arrAux[$#arrAux]; >+ } >+ } else { >+ delete $arrParamsBusc{'listBiblios'}; >+ } >+ my $offsetAux = $arrParamsBusc{'offset'}; >+ $arrParamsBusc{'offset'} = $arrParamsBusc{'offsetSearch'}; >+ $arrParamsBusc{'offsetSearch'} = $offsetAux; >+ $offset = $arrParamsBusc{'offset'}; >+ my $newbusc = rebuildBuscParam(\%arrParamsBusc); >+ $session->param("busc" => $newbusc); >+ @arrBusc = split(/\&(?:amp;)?/, $newbusc); >+ } >+ } >+ my $buscParam = ''; >+ my $j = 0; >+ # Rebuild the query for the button "back to results" >+ for (@arrBusc) { >+ unless ($_ =~ /^(?:query|listBiblios|newlistBiblios|query_type|simple_query|next|previous|total|count|offsetSearch)/) { >+ $buscParam .= '&' unless ($j == 0); >+ $buscParam .= $_; >+ $j++; >+ } >+ } >+ $template->param('busc' => $buscParam); >+ 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 list >+ 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 list >+ if ($offset && !$arrParamsBusc{'previous'}) { >+ $searchAgain = 1; >+ $offsetSearch = $offset - $results_per_page; >+ } >+ # we are at the last item of the list >+ } 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 list and there is more results >+ $searchAgain = 1 if (!$arrParamsBusc{'next'} && $arrParamsBusc{'total'} != @arrBiblios); >+ } else { >+ # search again if we aren't at the first list and there is more results >+ $searchAgain = 1 if (!$arrParamsBusc{'next'} && $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); >+ } >+ if ($searchAgain) { >+ my $newresultsRef = searchAgain(\%arrParamsBusc, $offsetSearch, $results_per_page); >+ my @newresults = @$newresultsRef; >+ # build the new listBiblios >+ my $listBiblios = buildListBiblios(\@newresults, $results_per_page); >+ unless (exists($arrParamsBusc{'listBiblios'})) { >+ $arrParamsBusc{'listBiblios'} = $listBiblios; >+ @arrBiblios = split(',', $arrParamsBusc{'listBiblios'}); >+ } else { >+ $arrParamsBusc{'newlistBiblios'} = $listBiblios; >+ } >+ # From the new list we build again the next and previous result >+ if (@arrBiblios) { >+ if ($arrBiblios[0] == $biblionumber) { >+ for (my $j = $#newresults; $j >= 0; $j--) { >+ next unless ($newresults[$j]); >+ $paging{'previous'}->{biblionumber} = $newresults[$j]->{biblionumber}; >+ $arrParamsBusc{'previous'} = $paging{'previous'}->{biblionumber}; >+ $arrParamsBusc{'offsetSearch'} = $offsetSearch; >+ last; >+ } >+ } elsif ($arrBiblios[$#arrBiblios] == $biblionumber) { >+ for (my $j = 0; $j < @newresults; $j++) { >+ next unless ($newresults[$j]); >+ $paging{'next'}->{biblionumber} = $newresults[$j]->{biblionumber}; >+ $arrParamsBusc{'next'} = $paging{'next'}->{biblionumber}; >+ $arrParamsBusc{'offsetSearch'} = $offsetSearch; >+ last; >+ } >+ } >+ } >+ # build new busc param >+ my $newbusc = rebuildBuscParam(\%arrParamsBusc); >+ $session->param("busc" => $newbusc); >+ } >+ my ($previous, $next, $dataBiblioPaging); >+ # Previous biblio >+ if ($paging{'previous'}->{biblionumber}) { >+ $previous = 'opac-detail.pl?biblionumber=' . $paging{'previous'}->{biblionumber}; >+ $dataBiblioPaging = GetBiblioData($paging{'previous'}->{biblionumber}); >+ $template->param('previousTitle' => $dataBiblioPaging->{'title'}) if ($dataBiblioPaging); >+ } >+ # Next biblio >+ if ($paging{'next'}->{biblionumber}) { >+ $next = 'opac-detail.pl?biblionumber=' . $paging{'next'}->{biblionumber}; >+ $dataBiblioPaging = GetBiblioData($paging{'next'}->{biblionumber}); >+ $template->param('nextTitle' => $dataBiblioPaging->{'title'}) if ($dataBiblioPaging); >+ } >+ $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]}; >+ } >+ $template->param('listResults' => \@listResults) if (@listResults); >+ $template->param('indexPag' => 1 + $offset, 'totalPag' => $arrParamsBusc{'total'}, 'indexPagEnd' => scalar(@arrBiblios) + $offset); >+} >+ >+ >+ > $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..dbc3792 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -269,6 +269,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 +437,10 @@ 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 .= '&count=' . $results_per_page; >+ $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 +562,24 @@ 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 $session = get_session($cgi->cookie("CGISESSID")); >+ $session->param('busc' => $pasarParams); >+ } >+ # >+ } > $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.7.3.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