View | Details | Raw Unified | Return to bug 6483
Collapse All | Expand All

(-)a/C4/Auth.pm (+5 lines)
Lines 386-391 sub get_template_and_user { Link Here
386
        my $LibraryNameTitle = C4::Context->preference("LibraryName");
386
        my $LibraryNameTitle = C4::Context->preference("LibraryName");
387
        $LibraryNameTitle =~ s/<(?:\/?)(?:br|p)\s*(?:\/?)>/ /sgi;
387
        $LibraryNameTitle =~ s/<(?:\/?)(?:br|p)\s*(?:\/?)>/ /sgi;
388
        $LibraryNameTitle =~ s/<(?:[^<>'"]|'(?:[^']*)'|"(?:[^"]*)")*>//sg;
388
        $LibraryNameTitle =~ s/<(?:[^<>'"]|'(?:[^']*)'|"(?:[^"]*)")*>//sg;
389
        # clean up the busc param in the session if the page is not opac-detail
390
        if ($in->{'template_name'} =~ /opac-.+\.(?:tt|tmpl)$/ && $in->{'template_name'} !~ /opac-detail\.[a-z]+$/) {
391
            my $sessionSearch = get_session($in->{'query'}->cookie("CGISESSID"));
392
            $sessionSearch->clear(["busc"]) if ($sessionSearch->param("busc"));
393
        }
389
        # variables passed from CGI: opac_css_override and opac_search_limits.
394
        # variables passed from CGI: opac_css_override and opac_search_limits.
390
        my $opac_search_limit = $ENV{'OPAC_SEARCH_LIMIT'};
395
        my $opac_search_limit = $ENV{'OPAC_SEARCH_LIMIT'};
391
        my $opac_limit_override = $ENV{'OPAC_LIMIT_OVERRIDE'};
396
        my $opac_limit_override = $ENV{'OPAC_LIMIT_OVERRIDE'};
(-)a/koha-tmpl/opac-tmpl/prog/en/css/opac.css (+88 lines)
Lines 2014-2016 div.ft { Link Here
2014
#opac-isbddetail #isbdcontents { margin-top: 2em; }
2014
#opac-isbddetail #isbdcontents { margin-top: 2em; }
2015
2015
2016
div.bibmessage { background-color : #ffffb0; border-radius : 5px; padding : 3px; margin : 2px; }
2016
div.bibmessage { background-color : #ffffb0; border-radius : 5px; padding : 3px; margin : 2px; }
2017
2018
2019
/* pagination */
2020
.pagination {
2021
	padding-top:10px;
2022
	float:left;
2023
	width:100%;
2024
}
2025
2026
.pagination_menu {
2027
    text-align: center;
2028
    width:100%;
2029
}
2030
2031
.pagination_menu a {
2032
	text-decoration:none!important;
2033
}
2034
2035
.pagination_menu a:hover {
2036
	text-decoration:underline;
2037
}
2038
2039
/* nav */
2040
.nav {
2041
	float:left
2042
}
2043
.nav ul {}
2044
.nav li {
2045
	list-style:none;
2046
	float:left;
2047
	padding:4px;
2048
	color:#999;
2049
}
2050
2051
.nav li a {
2052
	text-decoration:none!important;
2053
}
2054
2055
.nav li a:hover {
2056
	text-decoration:underline;
2057
}
2058
2059
.nav li ul {
2060
	float:left;
2061
}
2062
2063
.back {
2064
	float:right;
2065
}
2066
2067
.back input{
2068
	background:none!important;
2069
	color:#999!important;
2070
}
2071
#a_listResults{
2072
    float:left;
2073
}
2074
#listResults{
2075
    line-height: 0.7em;
2076
}
2077
.pagination_list {
2078
	float:bottom
2079
}
2080
.pagination_list ul {
2081
    margin-left: 150px;
2082
    padding-top: 40px;
2083
    width: 350px;
2084
}
2085
.pagination_list li {
2086
	list-style:none;
2087
	float:bottom;
2088
	padding:4px;
2089
	color:#999;
2090
    border-bottom : 1px solid #DDDDDD;
2091
}
2092
.pagination_list li.highlight {
2093
   background-color : #F3F3F3;
2094
   border-top : 1px solid #DDDDDD;
2095
   border-bottom : 1px solid #DDDDDD;
2096
}
2097
.pagination_list span.li_pag_index {
2098
   color : #999;
2099
   text-align: left;
2100
   font-size: 15px;
2101
   font-weight : bold;
2102
   padding-right: 10px;
2103
}
2104
(-)a/koha-tmpl/opac-tmpl/prog/en/includes/opac-facets.inc (-1 lines)
Lines 2-8 Link Here
2
[% IF ( facets_loop ) %]
2
[% IF ( facets_loop ) %]
3
<div id="search-facets">
3
<div id="search-facets">
4
<h4>Refine your search</h4>
4
<h4>Refine your search</h4>
5
[% query_cgi %]
6
<ul>
5
<ul>
7
	<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 ) %]&amp;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 ) %]&amp;sort_by=[% sort_by %][% END %]&amp;limit=available">currently available items.</a>[% END %]</li></ul>
6
	<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 ) %]&amp;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 ) %]&amp;sort_by=[% sort_by %][% END %]&amp;limit=available">currently available items.</a>[% END %]</li></ul>
8
	[% IF ( related ) %] <li>(related searches: [% FOREACH relate IN related %][% relate.related_search %][% END %])</li>[% END %]
7
	[% IF ( related ) %] <li>(related searches: [% FOREACH relate IN related %][% relate.related_search %][% END %])</li>[% END %]
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt (-1 / +103 lines)
Lines 3-8 Link Here
3
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
3
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
4
<script type="text/JavaScript" language="JavaScript">
4
<script type="text/JavaScript" language="JavaScript">
5
//<![CDATA[
5
//<![CDATA[
6
    [% IF ( busc ) %]
7
        var arrPagination = new Array();
8
        var pag_index_ini = [% indexPag %];
9
        [% IF ( listResults ) %]
10
            [% FOREACH listResult IN listResults %]
11
                arrPagination[[% listResult.index %]] = {url:"[% listResult.url %]", title:"[% listResult.title|html %]", author:"[% listResult.author|html %]", biblionumber:[% listResult.biblionumber %]};
12
           [% END %]
13
        [% END %]
14
    [% END %]
15
16
6
     $(document).ready(function() { 
17
     $(document).ready(function() { 
7
        $('#bibliodescriptions > ul').tabs();
18
        $('#bibliodescriptions > ul').tabs();
8
[% IF ( opacuserlogin ) %][% IF ( loggedinusername ) %][% IF ( TagsEnabled ) %]$("#tagform").hide();
19
[% IF ( opacuserlogin ) %][% IF ( loggedinusername ) %][% IF ( TagsEnabled ) %]$("#tagform").hide();
Lines 24-32 Link Here
24
        });[% IF ( GoogleJackets ) %]
35
        });[% IF ( GoogleJackets ) %]
25
        KOHA.Google.GetCoverFromIsbn([% covernewwindow %]);[% END %][% IF ( opacuserlogin ) %][% IF ( loggedinusername ) %][% IF ( TagsEnabled ) %]
36
        KOHA.Google.GetCoverFromIsbn([% covernewwindow %]);[% END %][% IF ( opacuserlogin ) %][% IF ( loggedinusername ) %][% IF ( TagsEnabled ) %]
26
        $(".tagbutton").click(KOHA.Tags.add_tag_button);[% END %][% END %][% END %]
37
        $(".tagbutton").click(KOHA.Tags.add_tag_button);[% END %][% END %][% END %]
38
        [% IF ( busc ) %]
39
        $("#a_listResults").click(function() {
40
            var ul_in = $(this).next("ul");
41
            var div_pag_list = $(".pagination_list");
42
            if (ul_in.css("display") == 'none') {
43
                ul_in.show();
44
                var newtitle = $(this).attr('title').replace('Show', 'Hide')
45
                $(this).attr('title',newtitle);
46
                div_pag_list.show();
47
                renderPagination(pag_index_ini, arrPagination.length - 1, $("#ul_pagination_list"), false);
48
            } else {
49
                ul_in.hide();
50
                var newtitle = $(this).attr('title').replace('Hide', 'Show')
51
                $(this).attr('title',newtitle);
52
                div_pag_list.hide();
53
            }
54
        });
55
        $(".a_pag").mouseover(function() {
56
            var id = $(this).attr("id");
57
            renderPagination(parseInt(id.substr("a_pag_".length), 10), arrPagination.length - 1, $("#ul_pagination_list"), true);
58
        });
59
        [% END %]
27
60
28
});
61
});
29
62
63
64
[% IF ( busc ) %]
65
function renderPagination(index, total, ul, highlIndex)
66
{
67
    for (var i = pag_index_ini; i <= total; i++) {
68
        if (arrPagination[i] == undefined || arrPagination[i].url == "") continue;
69
        $("#li_pag_" + i).remove();
70
    }
71
    var j = 0;
72
    for (i = index; i <= total; i++) {
73
        if (arrPagination[i] == undefined || arrPagination[i].url == "") continue;
74
        var li = $("<li id='li_pag_" + i + "' " + ((j % 2 == 0)?"class='highlight'":"")  + " title='Go to detail' />");
75
        var html = "<span class='li_pag_index'>" + i + "</span><a href='" + arrPagination[i].url + "'>" + arrPagination[i].title + "</a>";
76
        if (arrPagination[i].author) html += "<br /> by " + arrPagination[i].author;
77
        li.html(html);
78
        if (highlIndex && i == index) li.css("backgroundColor", "#DDDDDD");
79
        ul.append(li);
80
        j++;
81
    }
82
    for (i = pag_index_ini; i < index; i++) {
83
        if (arrPagination[i] == undefined || arrPagination[i].url == "") continue;
84
        $("#li_pag_" + i).remove();
85
        var li = $("<li id='li_pag_" + i + "' " + ((j % 2 == 0)?"class='highlight'":"")  + " title='Go to detail' />");
86
        var html = "<span class='li_pag_index'>" + i + "</span><a href='" + arrPagination[i].url + "'>" + arrPagination[i].title + "</a>";
87
        if (arrPagination[i].author) html += "<br /> by " + arrPagination[i].author;
88
        li.html(html);
89
        ul.append(li);
90
        j++;
91
    }
92
}//renderPagination
93
[% END %]
94
95
30
YAHOO.util.Event.onContentReady("furtherm", function () {
96
YAHOO.util.Event.onContentReady("furtherm", function () {
31
    $("#furtherm").css("display","block").css("visibility","hidden");
97
    $("#furtherm").css("display","block").css("visibility","hidden");
32
	$("#furthersearches").parent().show();
98
	$("#furthersearches").parent().show();
Lines 787-792 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
787
[% END %]
853
[% END %]
788
[% END %]
854
[% END %]
789
855
856
<div class="pagination">
857
[% IF ( busc ) %]
858
<div class="nav">
859
    <ul>
860
        <li class="first">[% IF ( previous ) %]<a href="[% previous %]" title="See: [% IF ( previousTitle ) %][% previousTitle |html %][% ELSE %]previous biblio[% END %]">&laquo; previous</a>[% ELSE %]previous[% END %]</li>
861
        <li class="last">[% IF ( next ) %]<a href="[% next %]" title="See: [% IF ( nextTitle ) %][% nextTitle |html %][% ELSE %]next biblio[% END %]">next &raquo;</a>[% ELSE %]next[% END %]</li>
862
        [% IF ( listResults ) %]
863
            <li><a href="#" id="a_listResults" title="Show pagination list ([% indexPag %]-[% indexPagEnd %] / [% totalPag %])">...</a><ul id="listResults" style="display:none">
864
            [% FOREACH listResult IN listResults %]
865
            <li>[% IF ( listResult.url ) %]<a href="[% listResult.url %]" title="See biblio &quot;[% listResult.title|html %]&quot; [% IF ( listResult.author ) %] by &quot;[% listResult.author|html %]&quot;[% END %] with biblionumber [% listResult.biblionumber %]" class="a_pag" id="a_pag_[% listResult.index %]">[% listResult.index %]</a>[% ELSE %][% listResult.index %][% END %]</li>
866
            [% END %]
867
            </ul></li>
868
        [% END %]
869
    </ul>
870
</div>
871
<div class="back">
872
    <span class="btn boton_gris"><input style="font-weight:normal !important;" type="button" value="&laquo; back to results" onclick="window.location.href = 'opac-search.pl?[% busc %]'" /></span>
873
</div>
874
[% IF ( listResults ) %]
875
<div class="pagination_list" style="display:none">
876
    <ul id="ul_pagination_list">
877
    </ul>
878
</div>
879
[% END %]
880
[% ELSE %]
881
<div class="back">
882
    <span class="btn boton_gris"><input style="font-weight:normal !important;" type="button" value="&laquo; back" onclick="history.back(-1);" /></span>
883
</div>
884
[% END %]
885
</div>
886
790
</div>
887
</div>
791
</div>
888
</div>
792
</div>
889
</div>
Lines 832-838 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
832
</div>
929
</div>
833
</div>
930
</div>
834
[% END %]
931
[% END %]
835
932
[% IF ( busc ) %]
933
    <div class="detailtagcell">
934
    <div class="pagination_menu"><strong>Pagination</strong>: [% IF ( previous ) %]<a href="[% previous %]" title="See: [% IF ( previousTitle ) %][% previousTitle |html %][% ELSE %]previous biblio[% END %]">&laquo; previous</a>[% ELSE %]previous[% END %]
935
        [% IF ( next ) %]<a href="[% next %]" title="See: [% IF ( nextTitle ) %][% nextTitle |html %][% ELSE %]next biblio[% END %]">next &raquo;</a>[% ELSE %]next[% END %]</div>
936
    </div>
937
[% END %]
836
        <div id="export" class="detailtagcell">
938
        <div id="export" class="detailtagcell">
837
        <form method="get" action="/cgi-bin/koha/opac-export.pl">
939
        <form method="get" action="/cgi-bin/koha/opac-export.pl">
838
        <label for="format">Save Record:</label>
940
        <label for="format">Save Record:</label>
(-)a/opac/opac-detail.pl (-1 / +283 lines)
Lines 23-29 use strict; Link Here
23
use warnings;
23
use warnings;
24
24
25
use CGI;
25
use CGI;
26
use C4::Auth;
26
use C4::Auth qw(:DEFAULT get_session);
27
use C4::Branch;
27
use C4::Branch;
28
use C4::Koha;
28
use C4::Koha;
29
use C4::Serials;    #uses getsubscriptionfrom biblionumber
29
use C4::Serials;    #uses getsubscriptionfrom biblionumber
Lines 66-71 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
66
66
67
my $biblionumber = $query->param('biblionumber') || $query->param('bib');
67
my $biblionumber = $query->param('biblionumber') || $query->param('bib');
68
68
69
# We look for the busc param to build the simple paging from the search
70
my $session = get_session($query->cookie("CGISESSID"));
71
my %paging = (previous => {}, next => {});
72
if ($session->param('busc')) {
73
    use C4::Search;
74
75
    # Rebuild the string to store on session
76
    sub rebuildBuscParam
77
    {
78
        my $arrParamsBusc = shift;
79
80
        my $pasarParams = '';
81
        my $j = 0;
82
        for (keys %$arrParamsBusc) {
83
            if ($_ =~ /^(?:query|listBiblios|newlistBiblios|query_type|simple_query|total|offset|offsetSearch|next|previous|count|expand|scan)/) {
84
                if (defined($arrParamsBusc->{$_})) {
85
                    $pasarParams .= '&amp;' if ($j);
86
                    $pasarParams .= $_ . '=' . $arrParamsBusc->{$_};
87
                    $j++;
88
                }
89
            } else {
90
                for my $value (@{$arrParamsBusc->{$_}}) {
91
                    $pasarParams .= '&amp;' if ($j);
92
                    $pasarParams .= $_ . '=' . $value;
93
                    $j++;
94
                }
95
            }
96
        }
97
        return $pasarParams;
98
    }#rebuildBuscParam
99
100
    # Search given the current values from the busc param
101
    sub searchAgain
102
    {
103
        my ($arrParamsBusc, $offset, $results_per_page) = @_;
104
105
        my $expanded_facet = $arrParamsBusc->{'expand'};
106
        my $branches = GetBranches();
107
        my @servers;
108
        @servers = @{$arrParamsBusc->{'server'}} if $arrParamsBusc->{'server'};
109
        @servers = ("biblioserver") unless (@servers);
110
        my $default_sort_by = C4::Context->preference('OPACdefaultSortField')."_".C4::Context->preference('OPACdefaultSortOrder') if (C4::Context->preference('OPACdefaultSortField') && C4::Context->preference('OPACdefaultSortOrder'));
111
        my @sort_by = @{$arrParamsBusc->{'sort_by'}} if $arrParamsBusc->{'sort_by'};
112
        $sort_by[0] = $default_sort_by if !$sort_by[0] && defined($default_sort_by);
113
        my ($error, $results_hashref, $facets);
114
        eval {
115
            ($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'});
116
        };
117
        my $hits;
118
        my @newresults;
119
        for (my $i=0;$i<@servers;$i++) {
120
            my $server = $servers[$i];
121
            $hits = $results_hashref->{$server}->{"hits"};
122
            @newresults = searchResults('opac', '', $hits, $results_per_page, $offset, $arrParamsBusc->{'scan'}, @{$results_hashref->{$server}->{"RECORDS"}},, C4::Context->preference('hidelostitems'));
123
        }
124
        return \@newresults;
125
    }#searchAgain
126
127
    # Build the current list of biblionumbers in this search
128
    sub buildListBiblios
129
    {
130
        my ($newresultsRef, $results_per_page) = @_;
131
132
        my $listBiblios = '';
133
        my $j = 0;
134
        foreach (@$newresultsRef) {
135
            my $bibnum = ($_->{biblionumber})?$_->{biblionumber}:0;
136
            $listBiblios .= $bibnum . ',';
137
            $j++;
138
            last if ($j == $results_per_page);
139
        }
140
        chop $listBiblios if ($listBiblios =~ /,$/);
141
        return $listBiblios;
142
    }#buildListBiblios
143
144
    my $busc = $session->param("busc");
145
    my @arrBusc = split(/\&(?:amp;)?/, $busc);
146
    my ($key, $value);
147
    my %arrParamsBusc = ();
148
    for (@arrBusc) {
149
        ($key, $value) = split(/=/, $_, 2);
150
        if ($key =~ /^(?:query|listBiblios|newlistBiblios|query_type|simple_query|next|previous|total|offset|offsetSearch|count|expand|scan)/) {
151
            $arrParamsBusc{$key} = $value;
152
        } else {
153
            unless (exists($arrParamsBusc{$key})) {
154
                $arrParamsBusc{$key} = [];
155
            }
156
            push @{$arrParamsBusc{$key}}, $value;
157
        }
158
    }
159
    my $searchAgain = 0;
160
    my $count = C4::Context->preference('OPACnumSearchResults') || 20;
161
    my $results_per_page = ($arrParamsBusc{'count'} && $arrParamsBusc{'count'} =~ /^[0-9]+?/)?$arrParamsBusc{'count'}:$count;
162
    $arrParamsBusc{'count'} = $results_per_page;
163
    my $offset = ($arrParamsBusc{'offset'} && $arrParamsBusc{'offset'} =~ /^[0-9]+?/)?$arrParamsBusc{'offset'}:0;
164
    # The value OPACnumSearchResults has changed and the search has to be rebuild
165
    if ($count != $results_per_page) {
166
        if (exists($arrParamsBusc{'listBiblios'}) && $arrParamsBusc{'listBiblios'} =~ /^[0-9]+(?:,[0-9]+)*$/) {
167
            my $indexBiblio = 0;
168
            my @arrBibliosAux = split(',', $arrParamsBusc{'listBiblios'});
169
            for (@arrBibliosAux) {
170
                last if ($_ == $biblionumber);
171
                $indexBiblio++;
172
            }
173
            $indexBiblio += $offset;
174
            $offset = int($indexBiblio / $count) * $count;
175
            $arrParamsBusc{'offset'} = $offset;
176
        }
177
        $arrParamsBusc{'count'} = $count;
178
        $results_per_page = $count;
179
        my $newresultsRef = searchAgain(\%arrParamsBusc, $offset, $results_per_page);
180
        $arrParamsBusc{'listBiblios'} = buildListBiblios($newresultsRef, $results_per_page);
181
        delete $arrParamsBusc{'previous'} if (exists($arrParamsBusc{'previous'}));
182
        delete $arrParamsBusc{'next'} if (exists($arrParamsBusc{'next'}));
183
        delete $arrParamsBusc{'offsetSearch'} if (exists($arrParamsBusc{'offsetSearch'}));
184
        delete $arrParamsBusc{'newlistBiblios'} if (exists($arrParamsBusc{'newlistBiblios'}));
185
        my $newbusc = rebuildBuscParam(\%arrParamsBusc);
186
        $session->param("busc" => $newbusc);
187
        @arrBusc = split(/\&(?:amp;)?/, $newbusc);
188
    } else {
189
        my $modifyListBiblios = 0;
190
        # We come from a previous click
191
        if (exists($arrParamsBusc{'previous'})) {
192
            $modifyListBiblios = 1 if ($biblionumber == $arrParamsBusc{'previous'});
193
            delete $arrParamsBusc{'previous'};
194
        } elsif (exists($arrParamsBusc{'next'})) { # We come from a next click
195
            $modifyListBiblios = 2 if ($biblionumber == $arrParamsBusc{'next'});
196
            delete $arrParamsBusc{'next'};
197
        }
198
        if ($modifyListBiblios) {
199
            if (exists($arrParamsBusc{'newlistBiblios'})) {
200
                my $listBibliosAux = $arrParamsBusc{'listBiblios'};
201
                $arrParamsBusc{'listBiblios'} = $arrParamsBusc{'newlistBiblios'};
202
                my @arrAux = split(',', $listBibliosAux);
203
                $arrParamsBusc{'newlistBiblios'} = $listBibliosAux;
204
                if ($modifyListBiblios == 1) {
205
                    $arrParamsBusc{'next'} = $arrAux[0];
206
                    $paging{'next'}->{biblionumber} = $arrAux[0];
207
                }else {
208
                    $arrParamsBusc{'previous'} = $arrAux[$#arrAux];
209
                    $paging{'previous'}->{biblionumber} = $arrAux[$#arrAux];
210
                }
211
            } else {
212
                delete $arrParamsBusc{'listBiblios'};
213
            }
214
            my $offsetAux = $arrParamsBusc{'offset'};
215
            $arrParamsBusc{'offset'} = $arrParamsBusc{'offsetSearch'};
216
            $arrParamsBusc{'offsetSearch'} = $offsetAux;
217
            $offset = $arrParamsBusc{'offset'};
218
            my $newbusc = rebuildBuscParam(\%arrParamsBusc);
219
            $session->param("busc" => $newbusc);
220
            @arrBusc = split(/\&(?:amp;)?/, $newbusc);
221
        }
222
    }
223
    my $buscParam = '';
224
    my $j = 0;
225
    # Rebuild the query for the button "back to results"
226
    for (@arrBusc) {
227
        unless ($_ =~ /^(?:query|listBiblios|newlistBiblios|query_type|simple_query|next|previous|total|count|offsetSearch)/) {
228
            $buscParam .= '&amp;' unless ($j == 0);
229
            $buscParam .= $_;
230
            $j++;
231
        }
232
    }
233
    $template->param('busc' => $buscParam);
234
    my $offsetSearch;
235
    my @arrBiblios;
236
    # We are inside the list of biblios and we don't have to search
237
    if (exists($arrParamsBusc{'listBiblios'}) && $arrParamsBusc{'listBiblios'} =~ /^[0-9]+(?:,[0-9]+)*$/) {
238
        @arrBiblios = split(',', $arrParamsBusc{'listBiblios'});
239
        if (@arrBiblios) {
240
            # We are at the first item of the list
241
            if ($arrBiblios[0] == $biblionumber) {
242
                if (@arrBiblios > 1) {
243
                    for (my $j = 1; $j < @arrBiblios; $j++) {
244
                        next unless ($arrBiblios[$j]);
245
                        $paging{'next'}->{biblionumber} = $arrBiblios[$j];
246
                        last;
247
                    }
248
                }
249
                # search again if we are not at the first searching list
250
                if ($offset && !$arrParamsBusc{'previous'}) {
251
                    $searchAgain = 1;
252
                    $offsetSearch = $offset - $results_per_page;
253
                }
254
            # we are at the last item of the list
255
            } elsif ($arrBiblios[$#arrBiblios] == $biblionumber) {
256
                for (my $j = $#arrBiblios - 1; $j >= 0; $j--) {
257
                    next unless ($arrBiblios[$j]);
258
                    $paging{'previous'}->{biblionumber} = $arrBiblios[$j];
259
                    last;
260
                }
261
                if (!$offset) {
262
                    # search again if we are at the first list and there is more results
263
                    $searchAgain = 1 if (!$arrParamsBusc{'next'} && $arrParamsBusc{'total'} != @arrBiblios);
264
                } else {
265
                    # search again if we aren't at the first list and there is more results
266
                    $searchAgain = 1 if (!$arrParamsBusc{'next'} && $arrParamsBusc{'total'} > ($offset + @arrBiblios));
267
                }
268
                $offsetSearch = $offset + $results_per_page if ($searchAgain);
269
            } else {
270
                for (my $j = 1; $j < $#arrBiblios; $j++) {
271
                    if ($arrBiblios[$j] == $biblionumber) {
272
                        for (my $z = $j - 1; $z >= 0; $z--) {
273
                            next unless ($arrBiblios[$z]);
274
                            $paging{'previous'}->{biblionumber} = $arrBiblios[$z];
275
                            last;
276
                        }
277
                        for (my $z = $j + 1; $z < @arrBiblios; $z++) {
278
                            next unless ($arrBiblios[$z]);
279
                            $paging{'next'}->{biblionumber} = $arrBiblios[$z];
280
                            last;
281
                        }
282
                        last;
283
                    }
284
                }
285
            }
286
        }
287
        $offsetSearch = 0 if (defined($offsetSearch) && $offsetSearch < 0);
288
    }
289
    if ($searchAgain) {
290
        my $newresultsRef = searchAgain(\%arrParamsBusc, $offsetSearch, $results_per_page);
291
        my @newresults = @$newresultsRef;
292
        # build the new listBiblios
293
        my $listBiblios = buildListBiblios(\@newresults, $results_per_page);
294
        unless (exists($arrParamsBusc{'listBiblios'})) {
295
            $arrParamsBusc{'listBiblios'} = $listBiblios;
296
            @arrBiblios = split(',', $arrParamsBusc{'listBiblios'});
297
        } else {
298
            $arrParamsBusc{'newlistBiblios'} = $listBiblios;
299
        }
300
        # From the new list we build again the next and previous result
301
        if (@arrBiblios) {
302
            if ($arrBiblios[0] == $biblionumber) {
303
                for (my $j = $#newresults; $j >= 0; $j--) {
304
                    next unless ($newresults[$j]);
305
                    $paging{'previous'}->{biblionumber} = $newresults[$j]->{biblionumber};
306
                    $arrParamsBusc{'previous'} = $paging{'previous'}->{biblionumber};
307
                    $arrParamsBusc{'offsetSearch'} = $offsetSearch;
308
                   last;
309
                }
310
            } elsif ($arrBiblios[$#arrBiblios] == $biblionumber) {
311
                for (my $j = 0; $j < @newresults; $j++) {
312
                    next unless ($newresults[$j]);
313
                    $paging{'next'}->{biblionumber} = $newresults[$j]->{biblionumber};
314
                    $arrParamsBusc{'next'} = $paging{'next'}->{biblionumber};
315
                    $arrParamsBusc{'offsetSearch'} = $offsetSearch;
316
                    last;
317
                }
318
            }
319
        }
320
        # build new busc param
321
        my $newbusc = rebuildBuscParam(\%arrParamsBusc);
322
        $session->param("busc" => $newbusc);
323
    }
324
    my ($previous, $next, $dataBiblioPaging);
325
    # Previous biblio
326
    if ($paging{'previous'}->{biblionumber}) {
327
        $previous = 'opac-detail.pl?biblionumber=' . $paging{'previous'}->{biblionumber};
328
        $dataBiblioPaging = GetBiblioData($paging{'previous'}->{biblionumber});
329
        $template->param('previousTitle' => $dataBiblioPaging->{'title'}) if ($dataBiblioPaging);
330
    }
331
    # Next biblio
332
    if ($paging{'next'}->{biblionumber}) {
333
        $next = 'opac-detail.pl?biblionumber=' . $paging{'next'}->{biblionumber};
334
        $dataBiblioPaging = GetBiblioData($paging{'next'}->{biblionumber});
335
        $template->param('nextTitle' => $dataBiblioPaging->{'title'}) if ($dataBiblioPaging);
336
    }
337
    $template->param('previous' => $previous, 'next' => $next);
338
    # Partial list of biblio results
339
    my @listResults;
340
    for (my $j = 0; $j < @arrBiblios; $j++) {
341
        next unless ($arrBiblios[$j]);
342
        $dataBiblioPaging = GetBiblioData($arrBiblios[$j]) if ($arrBiblios[$j] != $biblionumber);
343
        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]};
344
    }
345
    $template->param('listResults' => \@listResults) if (@listResults);
346
    $template->param('indexPag' => 1 + $offset, 'totalPag' => $arrParamsBusc{'total'}, 'indexPagEnd' => scalar(@arrBiblios) + $offset);
347
}
348
349
350
69
$template->param( 'AllowOnShelfHolds' => C4::Context->preference('AllowOnShelfHolds') );
351
$template->param( 'AllowOnShelfHolds' => C4::Context->preference('AllowOnShelfHolds') );
70
$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
352
$template->param( 'ItemsIssued' => CountItemsIssued( $biblionumber ) );
71
353
(-)a/opac/opac-search.pl (-1 / +37 lines)
Lines 269-274 my $params = $cgi->Vars; Link Here
269
my $tag;
269
my $tag;
270
$tag = $params->{tag} if $params->{tag};
270
$tag = $params->{tag} if $params->{tag};
271
271
272
273
# String with params with the search criteria for the paging in opac-detail
274
my $pasarParams = '';
275
my $j = 0;
276
for (keys %$params) {
277
    my @pasarParam = split("\0", $params->{$_});
278
    for my $paramValue(@pasarParam) {
279
        $pasarParams .= '&amp;' if ($j > 0);
280
        $pasarParams .= $_ . '=' . $paramValue;
281
        $j++;
282
    }
283
}
284
#
285
286
272
# Params that can have more than one value
287
# Params that can have more than one value
273
# sort by is used to sort the query
288
# sort by is used to sort the query
274
# in theory can have more than one but generally there's just one
289
# in theory can have more than one but generally there's just one
Lines 422-427 elsif (C4::Context->preference('NoZebra')) { Link Here
422
        ($error, $results_hashref, $facets) = C4::Search::pazGetRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan);
437
        ($error, $results_hashref, $facets) = C4::Search::pazGetRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan);
423
    };
438
    };
424
} else {
439
} else {
440
    $pasarParams .= '&amp;query=' . $query;
441
    $pasarParams .= '&amp;count=' . $results_per_page;
442
    $pasarParams .= '&amp;simple_query=' . $simple_query;
443
    $pasarParams .= '&amp;query_type=' . $query_type if ($query_type);
425
    eval {
444
    eval {
426
        ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan);
445
        ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan);
427
    };
446
    };
Lines 543-548 for (my $i=0;$i<@servers;$i++) { Link Here
543
            exit;
562
            exit;
544
        }
563
        }
545
        if ($hits) {
564
        if ($hits) {
565
            if (!C4::Context->preference('NoZebra') && !$build_grouped_results) {
566
                # We build the encrypted list of first OPACnumSearchResults biblios to pass with the search criteria for paging on opac-detail
567
                $pasarParams .= '&amp;listBiblios=';
568
                my $j = 0;
569
                foreach (@newresults) {
570
                    my $bibnum = ($_->{biblionumber})?$_->{biblionumber}:0;
571
                    $pasarParams .= $bibnum . ',';
572
                    $j++;
573
                    last if ($j == $results_per_page);
574
                }
575
                chop $pasarParams if ($pasarParams =~ /,$/);
576
                $pasarParams .= '&amp;total=' . int($total) if ($pasarParams !~ /total=(?:[0-9]+)?/);
577
                if ($pasarParams) {
578
                    my $session = get_session($cgi->cookie("CGISESSID"));
579
                    $session->param('busc' => $pasarParams);
580
                }
581
                #
582
            }
546
            $template->param(total => $hits);
583
            $template->param(total => $hits);
547
            my $limit_cgi_not_availablity = $limit_cgi;
584
            my $limit_cgi_not_availablity = $limit_cgi;
548
            $limit_cgi_not_availablity =~ s/&limit=available//g if defined $limit_cgi_not_availablity;
585
            $limit_cgi_not_availablity =~ s/&limit=available//g if defined $limit_cgi_not_availablity;
549
- 

Return to bug 6483