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

(-)a/C4/Auth.pm (+5 lines)
Lines 393-398 sub get_template_and_user { Link Here
393
        my $LibraryNameTitle = C4::Context->preference("LibraryName");
393
        my $LibraryNameTitle = C4::Context->preference("LibraryName");
394
        $LibraryNameTitle =~ s/<(?:\/?)(?:br|p)\s*(?:\/?)>/ /sgi;
394
        $LibraryNameTitle =~ s/<(?:\/?)(?:br|p)\s*(?:\/?)>/ /sgi;
395
        $LibraryNameTitle =~ s/<(?:[^<>'"]|'(?:[^']*)'|"(?:[^"]*)")*>//sg;
395
        $LibraryNameTitle =~ s/<(?:[^<>'"]|'(?:[^']*)'|"(?:[^"]*)")*>//sg;
396
        # clean up the busc param in the session if the page is not opac-detail
397
        if ($in->{'template_name'} =~ /opac-(.+)\.(?:tt|tmpl)$/ && $1 !~ /^(?:MARC|ISBD)?detail$/) {
398
            my $sessionSearch = get_session($sessionID || $in->{'query'}->cookie("CGISESSID"));
399
            $sessionSearch->clear(["busc"]) if ($sessionSearch->param("busc"));
400
        }
396
        # variables passed from CGI: opac_css_override and opac_search_limits.
401
        # variables passed from CGI: opac_css_override and opac_search_limits.
397
        my $opac_search_limit = $ENV{'OPAC_SEARCH_LIMIT'};
402
        my $opac_search_limit = $ENV{'OPAC_SEARCH_LIMIT'};
398
        my $opac_limit_override = $ENV{'OPAC_LIMIT_OVERRIDE'};
403
        my $opac_limit_override = $ENV{'OPAC_LIMIT_OVERRIDE'};
(-)a/koha-tmpl/opac-tmpl/prog/en/css/opac.css (-2 / +164 lines)
Lines 1888-1894 table#items th { Link Here
1888
	padding : 2px;
1888
	padding : 2px;
1889
}
1889
}
1890
#action {
1890
#action {
1891
	margin-top: 0;
1891
	/*margin-top: 0;*/
1892
}
1892
}
1893
#similars h4 {
1893
#similars h4 {
1894
	text-align : left;
1894
	text-align : left;
Lines 2038-2041 div.bibmessage { background-color : #ffffb0; border-radius : 5px; padding : 3px; Link Here
2038
2038
2039
#renewall_link {
2039
#renewall_link {
2040
	background-image : url(../../images/checks.png);
2040
	background-image : url(../../images/checks.png);
2041
}
2041
}
2042
2043
/* pagination */
2044
.pagination {
2045
    position: absolute;
2046
    top:32px;
2047
    left: -1px;
2048
    width: 100%;
2049
    height:auto;
2050
    border: 1px solid #D0D0D0;
2051
    display: none;
2052
	background-color:#F3F3F3;
2053
	padding-bottom:10px;
2054
}
2055
2056
2057
/* nav */
2058
.nav .close_pagination {
2059
    padding-right: 10px;
2060
    position: absolute;
2061
    right: 3px;
2062
    top: -25px;
2063
}
2064
.nav .close_pagination a {
2065
    text-decoration:none!important;
2066
}
2067
2068
.nav ul {
2069
    padding-top: 10px;
2070
}
2071
2072
.nav li {
2073
	list-style:none;
2074
	float:left;
2075
	padding:4px;
2076
	color:#999;
2077
}
2078
2079
.nav li a {
2080
	text-decoration:none!important;
2081
}
2082
2083
.nav li a:hover {
2084
	text-decoration:underline;
2085
}
2086
2087
.nav li ul {
2088
	float:left;
2089
}
2090
2091
.back {
2092
	float:right;
2093
}
2094
2095
.back input{
2096
	background:none!important;
2097
	color:#999!important;
2098
}
2099
2100
.pagination_list {
2101
	float:bottom;
2102
}
2103
.pagination_list ul {
2104
    padding-top: 40px;
2105
	padding-left:0px;
2106
}
2107
.pagination_list li {
2108
	list-style:none;
2109
	float:bottom;
2110
	padding:4px;
2111
	color:#999;
2112
   /* border-bottom : 1px solid #DDDDDD;*/
2113
}
2114
.pagination_list li.highlight {
2115
   background-color : #F3F3F3;
2116
   border-top : 1px solid #DDDDDD;
2117
   border-bottom : 1px solid #DDDDDD;
2118
}
2119
.pagination_list span.li_pag_index {
2120
   color: #999999;
2121
    float: left;
2122
    font-size: 15px;
2123
    font-weight: bold;
2124
    padding-right: 10px;
2125
    text-align: right;
2126
    width: 13px;
2127
	
2128
}
2129
2130
.pagination_list li a {padding-left:0px;}
2131
2132
2133
.nav_results {
2134
    background-color: #F3F3F3;
2135
    border: 1px solid #D0D0D0;
2136
    margin-top: 0.5em;
2137
	position:relative;
2138
}
2139
2140
.nav_results .l_Results a {
2141
    background:#E1E1E1 url("../../images/ico_b_results.gif") 14px 13px no-repeat;
2142
    color:#006699;
2143
    display:block;
2144
    padding:8px 28px;
2145
    text-decoration:none;
2146
}
2147
.nav_results .l_Results a:hover {
2148
    background-color:#D9D9D9;
2149
}
2150
.nav_results ul.pg_menu {
2151
    height:25px;
2152
    border-top: 1px solid #D0D0D0;
2153
}
2154
.nav_results ul.pg_menu li {
2155
    color:#B2B2B2;
2156
    display:block;
2157
    float:left;
2158
    padding:5px 0;
2159
    list-style:none;
2160
    text-align:center;
2161
}
2162
.nav_results ul.pg_menu li.back_results {
2163
    padding:5px 0px;
2164
    width:45%;
2165
    border-left: 1px solid #D0D0D0;
2166
    border-right: 1px solid #D0D0D0;
2167
}
2168
.nav_results ul.pg_menu li a {
2169
    text-decoration:none;
2170
    font-weight:normal;
2171
    color:#4D4D4D;
2172
}
2173
.nav_results ul.pg_menu li a:hover {
2174
    color:#006699;
2175
}
2176
.nav_results ul.pg_menu li.left_results {
2177
    margin-right:10px;
2178
}
2179
.nav_results ul.pg_menu li.right_results {
2180
    margin-left:10px;
2181
}
2182
2183
.nav_results #listResults{
2184
    line-height: 0.7em;
2185
}
2186
2187
.nav_results  #listResults li  {
2188
    background-color:#999999;
2189
    color:#C5C5C5;
2190
    font-weight:normal;
2191
	display:block;
2192
	margin-right:1px;
2193
	font-size:0.9em;
2194
	padding:5px 0px;
2195
	text-align:center;
2196
	min-width:20px;
2197
}
2198
2199
.nav_results  #listResults li:hover  {background-color:#006699;}
2200
2201
.nav_results  #listResults li a { color:#FFFFFF; font-weight:normal;}
2202
2203
(-)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 30-38 Link Here
30
	[% END %]
41
	[% END %]
31
	[% IF ( opacuserlogin ) %][% IF ( loggedinusername ) %][% IF ( TagsEnabled ) %]
42
	[% IF ( opacuserlogin ) %][% IF ( loggedinusername ) %][% IF ( TagsEnabled ) %]
32
        $(".tagbutton").click(KOHA.Tags.add_tag_button);[% END %][% END %][% END %]
43
        $(".tagbutton").click(KOHA.Tags.add_tag_button);[% END %][% END %][% END %]
44
        [% IF ( busc ) %]
45
        if (arrPagination.length > 0) {
46
            renderPagIndexList(pag_index_ini, $("#listResults"));
47
        }
48
        $("#a_listResults").click(function(e) {
49
            if (arrPagination.length > 0) {
50
                e.preventDefault();
51
                var navigation = $(".pagination");
52
                if (navigation.css("display") == 'none') {
53
                    navigation.show();
54
                    var newtitle = $(this).attr('title').replace('Show', 'Hide')
55
                    $(this).attr('title',newtitle);
56
                    renderPagination(pag_index_ini, arrPagination.length - 1, $("#ul_pagination_list"), false);
57
                } else {
58
                    navigation.hide();
59
                    var newtitle = $(this).attr('title').replace('Hide', 'Show')
60
                    $(this).attr('title',newtitle);
61
                }
62
            }
63
        });
64
        $("#close_pagination").click(function(e) {
65
            e.preventDefault();
66
            var navigation = $(".pagination");
67
            navigation.hide();
68
        });
69
        [% END %]
33
70
34
});
71
});
35
72
73
74
[% IF ( busc ) %]
75
76
var timeoutRFW;
77
var totalPagItemList = 10;
78
79
function rewindList()
80
{
81
    var ul = $("#listResults");
82
    var li_ini = ul.children(':first').next();
83
    var index_ini = pag_index_ini;
84
    if (li_ini) {
85
        index_ini = parseInt(li_ini.attr("class").substring(7), 10);
86
    }
87
    var li_end = ul.children(':last').prev();
88
    var index_end = arrPagination.length - 1;
89
    if (li_end) {
90
        index_end = parseInt(li_end.attr("class").substring(7), 10);
91
    }
92
    if (index_ini > pag_index_ini) {
93
        renderPagIndexList(index_ini - 1, ul, false);
94
        renderPagination(index_ini - 1, arrPagination.length - 1, $("#ul_pagination_list"), true);
95
    }
96
}//rewindList
97
98
function forwardList()
99
{
100
    var ul = $("#listResults");
101
    var li_ini = ul.children(':first').next();
102
    var index_ini = pag_index_ini;
103
    if (li_ini) {
104
        index_ini = parseInt(li_ini.attr("class").substring(7), 10);
105
    }
106
    var li_end = ul.children(':last').prev();
107
    var index_end = arrPagination.length - 1;
108
    if (li_end) {
109
        index_end = parseInt(li_end.attr("class").substring(7), 10);
110
    }
111
    if (index_end < arrPagination.length - 1) {
112
        renderPagIndexList(index_ini + 1, ul, false);
113
        renderPagination(index_ini + 1, arrPagination.length - 1, $("#ul_pagination_list"), true);
114
    }
115
}//forwardList
116
117
function renderPagIndexList(index, ul)
118
{
119
    var $kids = ul.children("li");
120
    if ($kids.length > 0) {
121
        $kids.each(function() {
122
            $(this).remove();
123
        });
124
    }
125
    var li;
126
    var html = "";
127
    var ini = index - 1;
128
    var end = ini + totalPagItemList - 1;
129
    li = $("<li />");
130
    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;";
131
    li.html(html);
132
    ul.append(li);
133
    var title = "";
134
    for (var i=index; i < arrPagination.length && i < index + totalPagItemList; i++) {
135
        if (arrPagination[i] == undefined) continue;
136
        var li = $("<li />");
137
        if (arrPagination[i].url != "") {
138
            title = "See biblio &quot;" + arrPagination[i].title + "&quot; ";
139
            if (arrPagination[i].author != "") title += " by &quot;" + arrPagination[i].author + "&quot;";
140
            title += " with biblionumber " + arrPagination[i].biblionumber;
141
            html = "<a href='" + arrPagination[i].url + "' title='" + title + "' class='a_pag' id='a_pag_" + i + "'";
142
            html += " onmouseover='renderPagination(" + i + ", " + (arrPagination.length - 1) + ", $(\"#ul_pagination_list\"), true)'";
143
            html += ">" + i + "</a>";
144
        } else html = i;
145
        li.html(html);
146
        li.attr("class", "li_pag_" + i);
147
        ul.append(li);
148
    }
149
    li = $("<li />");
150
    ini = index + 1;
151
    end = (arrPagination.length > index + totalPagItemList)?index + totalPagItemList:arrPagination.length - 1;
152
    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;";
153
    li.html(html);
154
    ul.append(li);
155
}//renderPagIndexList
156
157
158
function renderPagination(index, total, ul, highlIndex)
159
{
160
    for (var i = pag_index_ini; i <= total; i++) {
161
        if (arrPagination[i] == undefined || arrPagination[i].url == "") continue;
162
        $("#li_pag_" + i).remove();
163
    }
164
    var j = 0;
165
    for (var i = index; i <= total && j < totalPagItemList; i++) {
166
        if (arrPagination[i] == undefined || arrPagination[i].url == "") continue;
167
        var li = $("<li id='li_pag_" + i + "' " + ((j % 2 == 0)?"class='highlight'":"")  + " title='Go to detail' />");
168
        var html = "<span class='li_pag_index'>" + i + "</span><a href='" + arrPagination[i].url + "'>" + arrPagination[i].title + "</a>";
169
        if (arrPagination[i].author) html += "<br /> by " + arrPagination[i].author;
170
        li.html(html);
171
        if (highlIndex && i == index) li.css("backgroundColor", "#DDDDDD");
172
        ul.append(li);
173
        j++;
174
    }
175
    for (i = pag_index_ini; i < index && j < totalPagItemList; i++) {
176
        if (arrPagination[i] == undefined || arrPagination[i].url == "") continue;
177
        $("#li_pag_" + i).remove();
178
        var li = $("<li id='li_pag_" + i + "' " + ((j % 2 == 0)?"class='highlight'":"")  + " title='Go to detail' />");
179
        var html = "<span class='li_pag_index'>" + i + "</span><a href='" + arrPagination[i].url + "'>" + arrPagination[i].title + "</a>";
180
        if (arrPagination[i].author) html += "<br /> by " + arrPagination[i].author;
181
        li.html(html);
182
        ul.append(li);
183
        j++;
184
    }
185
}//renderPagination
186
[% END %]
187
188
36
YAHOO.util.Event.onContentReady("furtherm", function () {
189
YAHOO.util.Event.onContentReady("furtherm", function () {
37
    $("#furtherm").css("display","block").css("visibility","hidden");
190
    $("#furtherm").css("display","block").css("visibility","hidden");
38
	$("#furthersearches").parent().show();
191
	$("#furthersearches").parent().show();
Lines 800-811 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
800
[% END %]
953
[% END %]
801
[% END %]
954
[% END %]
802
955
956
803
</div>
957
</div>
804
</div>
958
</div>
805
</div>
959
</div>
806
960
961
807
<div class="yui-u">
962
<div class="yui-u">
808
<div id="ulactioncontainer" class="container">
963
<div id="ulactioncontainer" class="container">
964
[% IF ( busc ) %]
965
    <div class="nav_results">
966
        <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>
967
        <ul class="pg_menu">
968
            <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>
969
            <li class="back_results"><a href="opac-search.pl?[% busc %]" title="Back to the results search list">Back to results</a></li>
970
            <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>
971
        </ul>
972
        [% IF ( listResults ) %]
973
        <div class="pagination">
974
            <div class="nav">
975
                <span class="close_pagination"><a href="#" id="close_pagination">Close</a></span>
976
                <ul id="listResults"></ul>
977
            </div>
978
            <div class="pagination_list">
979
                <ul id="ul_pagination_list"></ul>
980
            </div>
981
        </div>
982
        [% END %]
983
    </div>
984
[% END %]
809
<ul id="action">
985
<ul id="action">
810
986
811
[% UNLESS ( norequests ) %]
987
[% 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 273-278 my $params = $cgi->Vars; Link Here
273
my $tag;
273
my $tag;
274
$tag = $params->{tag} if $params->{tag};
274
$tag = $params->{tag} if $params->{tag};
275
275
276
277
# String with params with the search criteria for the paging in opac-detail
278
my $pasarParams = '';
279
my $j = 0;
280
for (keys %$params) {
281
    my @pasarParam = split("\0", $params->{$_});
282
    for my $paramValue(@pasarParam) {
283
        $pasarParams .= '&amp;' if ($j > 0);
284
        $pasarParams .= $_ . '=' . $paramValue;
285
        $j++;
286
    }
287
}
288
#
289
290
276
# Params that can have more than one value
291
# Params that can have more than one value
277
# sort by is used to sort the query
292
# sort by is used to sort the query
278
# in theory can have more than one but generally there's just one
293
# 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