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

(-)a/C4/Auth.pm (+5 lines)
Lines 398-403 sub get_template_and_user { Link Here
398
        my $LibraryNameTitle = C4::Context->preference("LibraryName");
398
        my $LibraryNameTitle = C4::Context->preference("LibraryName");
399
        $LibraryNameTitle =~ s/<(?:\/?)(?:br|p)\s*(?:\/?)>/ /sgi;
399
        $LibraryNameTitle =~ s/<(?:\/?)(?:br|p)\s*(?:\/?)>/ /sgi;
400
        $LibraryNameTitle =~ s/<(?:[^<>'"]|'(?:[^']*)'|"(?:[^"]*)")*>//sg;
400
        $LibraryNameTitle =~ s/<(?:[^<>'"]|'(?:[^']*)'|"(?:[^"]*)")*>//sg;
401
        # clean up the busc param in the session if the page is not opac-detail
402
        if ($in->{'template_name'} =~ /opac-(.+)\.(?:tt|tmpl)$/ && $1 !~ /^(?:MARC|ISBD)?detail$/) {
403
            my $sessionSearch = get_session($sessionID || $in->{'query'}->cookie("CGISESSID"));
404
            $sessionSearch->clear(["busc"]) if ($sessionSearch->param("busc"));
405
        }
401
        # variables passed from CGI: opac_css_override and opac_search_limits.
406
        # variables passed from CGI: opac_css_override and opac_search_limits.
402
        my $opac_search_limit = $ENV{'OPAC_SEARCH_LIMIT'};
407
        my $opac_search_limit = $ENV{'OPAC_SEARCH_LIMIT'};
403
        my $opac_limit_override = $ENV{'OPAC_LIMIT_OVERRIDE'};
408
        my $opac_limit_override = $ENV{'OPAC_LIMIT_OVERRIDE'};
(-)a/koha-tmpl/opac-tmpl/prog/en/css/opac.css (-1 / +161 lines)
Lines 1902-1908 table#items th { Link Here
1902
	padding : 2px;
1902
	padding : 2px;
1903
}
1903
}
1904
#action {
1904
#action {
1905
	margin-top: 0;
1905
	/*margin-top: 0;*/
1906
}
1906
}
1907
#similars h4 {
1907
#similars h4 {
1908
	text-align : left;
1908
	text-align : left;
Lines 2065-2067 a.koha_url { Link Here
2065
    text-decoration:none;
2065
    text-decoration:none;
2066
    color: #666666;
2066
    color: #666666;
2067
}
2067
}
2068
/* pagination */
2069
.pagination {
2070
    position: absolute;
2071
    top:32px;
2072
    left: -1px;
2073
    width: 100%;
2074
    height:auto;
2075
    border: 1px solid #D0D0D0;
2076
    display: none;
2077
	background-color:#F3F3F3;
2078
	padding-bottom:10px;
2079
}
2080
2081
2082
/* nav */
2083
.nav .close_pagination {
2084
    padding-right: 10px;
2085
    position: absolute;
2086
    right: 3px;
2087
    top: -25px;
2088
}
2089
.nav .close_pagination a {
2090
    text-decoration:none!important;
2091
}
2092
2093
.nav ul {
2094
    padding-top: 10px;
2095
}
2096
2097
.nav li {
2098
	list-style:none;
2099
	float:left;
2100
	padding:4px;
2101
	color:#999;
2102
}
2103
2104
.nav li a {
2105
	text-decoration:none!important;
2106
}
2107
2108
.nav li a:hover {
2109
	text-decoration:underline;
2110
}
2111
2112
.nav li ul {
2113
	float:left;
2114
}
2115
2116
.back {
2117
	float:right;
2118
}
2119
2120
.back input{
2121
	background:none!important;
2122
	color:#999!important;
2123
}
2124
2125
.pagination_list {
2126
	float:bottom;
2127
}
2128
.pagination_list ul {
2129
    padding-top: 40px;
2130
	padding-left:0px;
2131
}
2132
.pagination_list li {
2133
	list-style:none;
2134
	float:bottom;
2135
	padding:4px;
2136
	color:#999;
2137
   /* border-bottom : 1px solid #DDDDDD;*/
2138
}
2139
.pagination_list li.highlight {
2140
   background-color : #F3F3F3;
2141
   border-top : 1px solid #DDDDDD;
2142
   border-bottom : 1px solid #DDDDDD;
2143
}
2144
.pagination_list span.li_pag_index {
2145
   color: #999999;
2146
    float: left;
2147
    font-size: 15px;
2148
    font-weight: bold;
2149
    padding-right: 10px;
2150
    text-align: right;
2151
    width: 13px;
2152
	
2153
}
2154
2155
.pagination_list li a {padding-left:0px;}
2156
2157
2158
.nav_results {
2159
    background-color: #F3F3F3;
2160
    border: 1px solid #D0D0D0;
2161
    margin-top: 0.5em;
2162
	position:relative;
2163
}
2164
2165
.nav_results .l_Results a {
2166
    background:#E1E1E1 url("../../images/ico_b_results.gif") 14px 13px no-repeat;
2167
    color:#006699;
2168
    display:block;
2169
    padding:8px 28px;
2170
    text-decoration:none;
2171
}
2172
.nav_results .l_Results a:hover {
2173
    background-color:#D9D9D9;
2174
}
2175
.nav_results ul.pg_menu {
2176
    height:25px;
2177
    border-top: 1px solid #D0D0D0;
2178
}
2179
.nav_results ul.pg_menu li {
2180
    color:#B2B2B2;
2181
    display:block;
2182
    float:left;
2183
    padding:5px 0;
2184
    list-style:none;
2185
    text-align:center;
2186
}
2187
.nav_results ul.pg_menu li.back_results {
2188
    padding:5px 0px;
2189
    width:45%;
2190
    border-left: 1px solid #D0D0D0;
2191
    border-right: 1px solid #D0D0D0;
2192
}
2193
.nav_results ul.pg_menu li a {
2194
    text-decoration:none;
2195
    font-weight:normal;
2196
    color:#4D4D4D;
2197
}
2198
.nav_results ul.pg_menu li a:hover {
2199
    color:#006699;
2200
}
2201
.nav_results ul.pg_menu li.left_results {
2202
    margin-right:10px;
2203
}
2204
.nav_results ul.pg_menu li.right_results {
2205
    margin-left:10px;
2206
}
2207
2208
.nav_results #listResults{
2209
    line-height: 0.7em;
2210
}
2211
2212
.nav_results  #listResults li  {
2213
    background-color:#999999;
2214
    color:#C5C5C5;
2215
    font-weight:normal;
2216
	display:block;
2217
	margin-right:1px;
2218
	font-size:0.9em;
2219
	padding:5px 0px;
2220
	text-align:center;
2221
	min-width:20px;
2222
}
2223
2224
.nav_results  #listResults li:hover  {background-color:#006699;}
2225
2226
.nav_results  #listResults li a { color:#FFFFFF; font-weight:normal;}
2227
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tt (+176 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 33-41 Link Here
33
        [% END %]
44
        [% END %]
34
	[% IF ( opacuserlogin ) %][% IF ( loggedinusername ) %][% IF ( TagsEnabled ) %]
45
	[% IF ( opacuserlogin ) %][% IF ( loggedinusername ) %][% IF ( TagsEnabled ) %]
35
        $(".tagbutton").click(KOHA.Tags.add_tag_button);[% END %][% END %][% END %]
46
        $(".tagbutton").click(KOHA.Tags.add_tag_button);[% END %][% END %][% END %]
47
        [% IF ( busc ) %]
48
        if (arrPagination.length > 0) {
49
            renderPagIndexList(pag_index_ini, $("#listResults"));
50
        }
51
        $("#a_listResults").click(function(e) {
52
            if (arrPagination.length > 0) {
53
                e.preventDefault();
54
                var navigation = $(".pagination");
55
                if (navigation.css("display") == 'none') {
56
                    navigation.show();
57
                    var newtitle = $(this).attr('title').replace('Show', 'Hide')
58
                    $(this).attr('title',newtitle);
59
                    renderPagination(pag_index_ini, arrPagination.length - 1, $("#ul_pagination_list"), false);
60
                } else {
61
                    navigation.hide();
62
                    var newtitle = $(this).attr('title').replace('Hide', 'Show')
63
                    $(this).attr('title',newtitle);
64
                }
65
            }
66
        });
67
        $("#close_pagination").click(function(e) {
68
            e.preventDefault();
69
            var navigation = $(".pagination");
70
            navigation.hide();
71
        });
72
        [% END %]
36
73
37
});
74
});
38
75
76
77
[% IF ( busc ) %]
78
79
var timeoutRFW;
80
var totalPagItemList = 10;
81
82
function rewindList()
83
{
84
    var ul = $("#listResults");
85
    var li_ini = ul.children(':first').next();
86
    var index_ini = pag_index_ini;
87
    if (li_ini) {
88
        index_ini = parseInt(li_ini.attr("class").substring(7), 10);
89
    }
90
    var li_end = ul.children(':last').prev();
91
    var index_end = arrPagination.length - 1;
92
    if (li_end) {
93
        index_end = parseInt(li_end.attr("class").substring(7), 10);
94
    }
95
    if (index_ini > pag_index_ini) {
96
        renderPagIndexList(index_ini - 1, ul, false);
97
        renderPagination(index_ini - 1, arrPagination.length - 1, $("#ul_pagination_list"), true);
98
    }
99
}//rewindList
100
101
function forwardList()
102
{
103
    var ul = $("#listResults");
104
    var li_ini = ul.children(':first').next();
105
    var index_ini = pag_index_ini;
106
    if (li_ini) {
107
        index_ini = parseInt(li_ini.attr("class").substring(7), 10);
108
    }
109
    var li_end = ul.children(':last').prev();
110
    var index_end = arrPagination.length - 1;
111
    if (li_end) {
112
        index_end = parseInt(li_end.attr("class").substring(7), 10);
113
    }
114
    if (index_end < arrPagination.length - 1) {
115
        renderPagIndexList(index_ini + 1, ul, false);
116
        renderPagination(index_ini + 1, arrPagination.length - 1, $("#ul_pagination_list"), true);
117
    }
118
}//forwardList
119
120
function renderPagIndexList(index, ul)
121
{
122
    var $kids = ul.children("li");
123
    if ($kids.length > 0) {
124
        $kids.each(function() {
125
            $(this).remove();
126
        });
127
    }
128
    var li;
129
    var html = "";
130
    var ini = index - 1;
131
    var end = ini + totalPagItemList - 1;
132
    li = $("<li />");
133
    html = (index > pag_index_ini)?"<a href='#' id='rew_list_index' onclick='rewindList()' title='Click to rewind the list to " + ini + " - " + end + "'>&laquo;</a>":"&laquo;";
134
    li.html(html);
135
    ul.append(li);
136
    var title = "";
137
    for (var i=index; i < arrPagination.length && i < index + totalPagItemList; i++) {
138
        if (arrPagination[i] == undefined) continue;
139
        var li = $("<li />");
140
        if (arrPagination[i].url != "") {
141
            title = "See biblio &quot;" + arrPagination[i].title + "&quot; ";
142
            if (arrPagination[i].author != "") title += " by &quot;" + arrPagination[i].author + "&quot;";
143
            title += " with biblionumber " + arrPagination[i].biblionumber;
144
            html = "<a href='" + arrPagination[i].url + "' title='" + title + "' class='a_pag' id='a_pag_" + i + "'";
145
            html += " onmouseover='renderPagination(" + i + ", " + (arrPagination.length - 1) + ", $(\"#ul_pagination_list\"), true)'";
146
            html += ">" + i + "</a>";
147
        } else html = i;
148
        li.html(html);
149
        li.attr("class", "li_pag_" + i);
150
        ul.append(li);
151
    }
152
    li = $("<li />");
153
    ini = index + 1;
154
    end = (arrPagination.length > index + totalPagItemList)?index + totalPagItemList:arrPagination.length - 1;
155
    html = (end <= arrPagination.length - 1 && (end - index) >= totalPagItemList)?"<a href='#' id='fw_list_index' onclick='forwardList()' title='Click to forward the list to " + ini + " - " + end + "'>&raquo;</a>":"&raquo;";
156
    li.html(html);
157
    ul.append(li);
158
}//renderPagIndexList
159
160
161
function renderPagination(index, total, ul, highlIndex)
162
{
163
    for (var i = pag_index_ini; i <= total; i++) {
164
        if (arrPagination[i] == undefined || arrPagination[i].url == "") continue;
165
        $("#li_pag_" + i).remove();
166
    }
167
    var j = 0;
168
    for (var i = index; i <= total && j < totalPagItemList; i++) {
169
        if (arrPagination[i] == undefined || arrPagination[i].url == "") continue;
170
        var li = $("<li id='li_pag_" + i + "' " + ((j % 2 == 0)?"class='highlight'":"")  + " title='Go to detail' />");
171
        var html = "<span class='li_pag_index'>" + i + "</span><a href='" + arrPagination[i].url + "'>" + arrPagination[i].title + "</a>";
172
        if (arrPagination[i].author) html += "<br /> by " + arrPagination[i].author;
173
        li.html(html);
174
        if (highlIndex && i == index) li.css("backgroundColor", "#DDDDDD");
175
        ul.append(li);
176
        j++;
177
    }
178
    for (i = pag_index_ini; i < index && j < totalPagItemList; i++) {
179
        if (arrPagination[i] == undefined || arrPagination[i].url == "") continue;
180
        $("#li_pag_" + i).remove();
181
        var li = $("<li id='li_pag_" + i + "' " + ((j % 2 == 0)?"class='highlight'":"")  + " title='Go to detail' />");
182
        var html = "<span class='li_pag_index'>" + i + "</span><a href='" + arrPagination[i].url + "'>" + arrPagination[i].title + "</a>";
183
        if (arrPagination[i].author) html += "<br /> by " + arrPagination[i].author;
184
        li.html(html);
185
        ul.append(li);
186
        j++;
187
    }
188
}//renderPagination
189
[% END %]
190
191
39
YAHOO.util.Event.onContentReady("furtherm", function () {
192
YAHOO.util.Event.onContentReady("furtherm", function () {
40
    $("#furtherm").css("display","block").css("visibility","hidden");
193
    $("#furtherm").css("display","block").css("visibility","hidden");
41
	$("#furthersearches").parent().show();
194
	$("#furthersearches").parent().show();
Lines 825-830 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
825
[% END %]
978
[% END %]
826
[% END %]
979
[% END %]
827
980
981
828
</div>
982
</div>
829
[% IF ( NovelistSelectProfile ) %][% IF ( NovelistSelectView == 'below' ) %]
983
[% IF ( NovelistSelectProfile ) %][% IF ( NovelistSelectView == 'below' ) %]
830
<div id="NovelistSelect">
984
<div id="NovelistSelect">
Lines 835-842 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
835
</div>
989
</div>
836
</div>
990
</div>
837
991
992
838
<div class="yui-u">
993
<div class="yui-u">
839
<div id="ulactioncontainer" class="container">
994
<div id="ulactioncontainer" class="container">
995
[% IF ( busc ) %]
996
    <div class="nav_results">
997
        <div class="l_Results">[% IF ( listResults ) %]<a href="#" id="a_listResults" title="Show pagination list ([% indexPag %]-[% indexPagEnd %] / [% totalPag %])">Browse results</a>[% ELSE %]Browse results[% END %]</div>
998
        <ul class="pg_menu">
999
            <li class="left_results">[% IF ( previous ) %]<a href="[% previous %]" title="See: [% IF ( previousTitle ) %][% previousTitle |html %][% ELSE %]previous biblio[% END %]">&laquo; Previous</a>[% ELSE %]Previous[% END %]</li>
1000
            <li class="back_results"><a href="opac-search.pl?[% busc %]" title="Back to the results search list">Back to results</a></li>
1001
            <li class="right_results">[% IF ( next ) %]<a href="[% next %]" title="See: [% IF ( nextTitle ) %][% nextTitle |html %][% ELSE %]next biblio[% END %]">Next &raquo;</a>[% ELSE %]Next[% END %]</li>
1002
        </ul>
1003
        [% IF ( listResults ) %]
1004
        <div class="pagination">
1005
            <div class="nav">
1006
                <span class="close_pagination"><a href="#" id="close_pagination">Close</a></span>
1007
                <ul id="listResults"></ul>
1008
            </div>
1009
            <div class="pagination_list">
1010
                <ul id="ul_pagination_list"></ul>
1011
            </div>
1012
        </div>
1013
        [% END %]
1014
    </div>
1015
[% END %]
840
<ul id="action">
1016
<ul id="action">
841
1017
842
[% UNLESS ( norequests ) %]
1018
[% UNLESS ( norequests ) %]
(-)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 272-277 my $params = $cgi->Vars; Link Here
272
my $tag;
272
my $tag;
273
$tag = $params->{tag} if $params->{tag};
273
$tag = $params->{tag} if $params->{tag};
274
274
275
276
# String with params with the search criteria for the paging in opac-detail
277
my $pasarParams = '';
278
my $j = 0;
279
for (keys %$params) {
280
    my @pasarParam = split("\0", $params->{$_});
281
    for my $paramValue(@pasarParam) {
282
        $pasarParams .= '&amp;' if ($j > 0);
283
        $pasarParams .= $_ . '=' . $paramValue;
284
        $j++;
285
    }
286
}
287
#
288
289
275
# Params that can have more than one value
290
# Params that can have more than one value
276
# sort by is used to sort the query
291
# sort by is used to sort the query
277
# in theory can have more than one but generally there's just one
292
# in theory can have more than one but generally there's just one
Lines 434-439 elsif (C4::Context->preference('NoZebra')) { Link Here
434
        ($error, $results_hashref, $facets) = C4::Search::pazGetRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan);
449
        ($error, $results_hashref, $facets) = C4::Search::pazGetRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan);
435
    };
450
    };
436
} else {
451
} else {
452
    $pasarParams .= '&amp;query=' . $query;
453
    $pasarParams .= '&amp;count=' . $results_per_page;
454
    $pasarParams .= '&amp;simple_query=' . $simple_query;
455
    $pasarParams .= '&amp;query_type=' . $query_type if ($query_type);
437
    eval {
456
    eval {
438
        ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan);
457
        ($error, $results_hashref, $facets) = getRecords($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,$expanded_facet,$branches,$query_type,$scan);
439
    };
458
    };
Lines 555-560 for (my $i=0;$i<@servers;$i++) { Link Here
555
            exit;
574
            exit;
556
        }
575
        }
557
        if ($hits) {
576
        if ($hits) {
577
            if (!C4::Context->preference('NoZebra') && !$build_grouped_results) {
578
                # We build the encrypted list of first OPACnumSearchResults biblios to pass with the search criteria for paging on opac-detail
579
                $pasarParams .= '&amp;listBiblios=';
580
                my $j = 0;
581
                foreach (@newresults) {
582
                    my $bibnum = ($_->{biblionumber})?$_->{biblionumber}:0;
583
                    $pasarParams .= $bibnum . ',';
584
                    $j++;
585
                    last if ($j == $results_per_page);
586
                }
587
                chop $pasarParams if ($pasarParams =~ /,$/);
588
                $pasarParams .= '&amp;total=' . int($total) if ($pasarParams !~ /total=(?:[0-9]+)?/);
589
                if ($pasarParams) {
590
                    my $session = get_session($cgi->cookie("CGISESSID"));
591
                    $session->param('busc' => $pasarParams);
592
                }
593
                #
594
            }
558
            $template->param(total => $hits);
595
            $template->param(total => $hits);
559
            my $limit_cgi_not_availablity = $limit_cgi;
596
            my $limit_cgi_not_availablity = $limit_cgi;
560
            $limit_cgi_not_availablity =~ s/&limit=available//g if defined $limit_cgi_not_availablity;
597
            $limit_cgi_not_availablity =~ s/&limit=available//g if defined $limit_cgi_not_availablity;
561
- 

Return to bug 6483