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)$/ && $1 !~ /^(?:MARC|ISBD)?detail$/) {
391
            my $sessionSearch = get_session($sessionID || $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 (-1 / +164 lines)
Lines 1884-1890 table#items th { Link Here
1884
	padding : 2px;
1884
	padding : 2px;
1885
}
1885
}
1886
#action {
1886
#action {
1887
	margin-top: 0;
1887
	/*margin-top: 0;*/
1888
}
1888
}
1889
#similars h4 {
1889
#similars h4 {
1890
	text-align : left;
1890
	text-align : left;
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
    position: absolute;
2022
    top:32px;
2023
    left: -1px;
2024
    width: 100%;
2025
    height:auto;
2026
    border: 1px solid #D0D0D0;
2027
    display: none;
2028
	background-color:#F3F3F3;
2029
	padding-bottom:10px;
2030
}
2031
2032
2033
/* nav */
2034
.nav .close_pagination {
2035
    padding-right: 10px;
2036
    position: absolute;
2037
    right: 3px;
2038
    top: -25px;
2039
}
2040
.nav .close_pagination a {
2041
    text-decoration:none!important;
2042
}
2043
2044
.nav ul {
2045
    padding-top: 10px;
2046
}
2047
2048
.nav li {
2049
	list-style:none;
2050
	float:left;
2051
	padding:4px;
2052
	color:#999;
2053
}
2054
2055
.nav li a {
2056
	text-decoration:none!important;
2057
}
2058
2059
.nav li a:hover {
2060
	text-decoration:underline;
2061
}
2062
2063
.nav li ul {
2064
	float:left;
2065
}
2066
2067
.back {
2068
	float:right;
2069
}
2070
2071
.back input{
2072
	background:none!important;
2073
	color:#999!important;
2074
}
2075
2076
.pagination_list {
2077
	float:bottom;
2078
}
2079
.pagination_list ul {
2080
    padding-top: 40px;
2081
	padding-left:0px;
2082
}
2083
.pagination_list li {
2084
	list-style:none;
2085
	float:bottom;
2086
	padding:4px;
2087
	color:#999;
2088
   /* border-bottom : 1px solid #DDDDDD;*/
2089
}
2090
.pagination_list li.highlight {
2091
   background-color : #F3F3F3;
2092
   border-top : 1px solid #DDDDDD;
2093
   border-bottom : 1px solid #DDDDDD;
2094
}
2095
.pagination_list span.li_pag_index {
2096
   color: #999999;
2097
    float: left;
2098
    font-size: 15px;
2099
    font-weight: bold;
2100
    padding-right: 10px;
2101
    text-align: right;
2102
    width: 13px;
2103
	
2104
}
2105
2106
.pagination_list li a {padding-left:0px;}
2107
2108
2109
.nav_results {
2110
    background-color: #F3F3F3;
2111
    border: 1px solid #D0D0D0;
2112
    margin-top: 0.5em;
2113
	position:relative;
2114
}
2115
2116
.nav_results .l_Results a {
2117
    background:#E1E1E1 url("../../images/ico_b_results.gif") 14px 13px no-repeat;
2118
    color:#006699;
2119
    display:block;
2120
    padding:8px 28px;
2121
    text-decoration:none;
2122
}
2123
.nav_results .l_Results a:hover {
2124
    background-color:#D9D9D9;
2125
}
2126
.nav_results ul.pg_menu {
2127
    height:25px;
2128
    border-top: 1px solid #D0D0D0;
2129
}
2130
.nav_results ul.pg_menu li {
2131
    color:#B2B2B2;
2132
    display:block;
2133
    float:left;
2134
    padding:5px 0;
2135
    list-style:none;
2136
    text-align:center;
2137
}
2138
.nav_results ul.pg_menu li.back_results {
2139
    padding:5px 0px;
2140
    width:45%;
2141
    border-left: 1px solid #D0D0D0;
2142
    border-right: 1px solid #D0D0D0;
2143
}
2144
.nav_results ul.pg_menu li a {
2145
    text-decoration:none;
2146
    font-weight:normal;
2147
    color:#4D4D4D;
2148
}
2149
.nav_results ul.pg_menu li a:hover {
2150
    color:#006699;
2151
}
2152
.nav_results ul.pg_menu li.left_results {
2153
    margin-right:10px;
2154
}
2155
.nav_results ul.pg_menu li.right_results {
2156
    margin-left:10px;
2157
}
2158
2159
.nav_results #listResults{
2160
    line-height: 0.7em;
2161
}
2162
2163
.nav_results  #listResults li  {
2164
    background-color:#999999;
2165
    color:#C5C5C5;
2166
    font-weight:normal;
2167
	display:block;
2168
	margin-right:1px;
2169
	font-size:0.9em;
2170
	padding:5px 0px;
2171
	text-align:center;
2172
	min-width:20px;
2173
}
2174
2175
.nav_results  #listResults li:hover  {background-color:#006699;}
2176
2177
.nav_results  #listResults li a { color:#FFFFFF; font-weight:normal;}
2178
2179
(-)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 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
        if (arrPagination.length > 0) {
40
            renderPagIndexList(pag_index_ini, $("#listResults"));
41
        }
42
        $("#a_listResults").click(function(e) {
43
            if (arrPagination.length > 0) {
44
                e.preventDefault();
45
                var navigation = $(".pagination");
46
                if (navigation.css("display") == 'none') {
47
                    navigation.show();
48
                    var newtitle = $(this).attr('title').replace('Show', 'Hide')
49
                    $(this).attr('title',newtitle);
50
                    renderPagination(pag_index_ini, arrPagination.length - 1, $("#ul_pagination_list"), false);
51
                } else {
52
                    navigation.hide();
53
                    var newtitle = $(this).attr('title').replace('Hide', 'Show')
54
                    $(this).attr('title',newtitle);
55
                }
56
            }
57
        });
58
        $("#close_pagination").click(function(e) {
59
            e.preventDefault();
60
            var navigation = $(".pagination");
61
            navigation.hide();
62
        });
63
        [% END %]
27
64
28
});
65
});
29
66
67
68
[% IF ( busc ) %]
69
70
var timeoutRFW;
71
var totalPagItemList = 10;
72
73
function rewindList()
74
{
75
    var ul = $("#listResults");
76
    var li_ini = ul.children(':first').next();
77
    var index_ini = pag_index_ini;
78
    if (li_ini) {
79
        index_ini = parseInt(li_ini.attr("class").substring(7), 10);
80
    }
81
    var li_end = ul.children(':last').prev();
82
    var index_end = arrPagination.length - 1;
83
    if (li_end) {
84
        index_end = parseInt(li_end.attr("class").substring(7), 10);
85
    }
86
    if (index_ini > pag_index_ini) {
87
        renderPagIndexList(index_ini - 1, ul, false);
88
        renderPagination(index_ini - 1, arrPagination.length - 1, $("#ul_pagination_list"), true);
89
    }
90
}//rewindList
91
92
function forwardList()
93
{
94
    var ul = $("#listResults");
95
    var li_ini = ul.children(':first').next();
96
    var index_ini = pag_index_ini;
97
    if (li_ini) {
98
        index_ini = parseInt(li_ini.attr("class").substring(7), 10);
99
    }
100
    var li_end = ul.children(':last').prev();
101
    var index_end = arrPagination.length - 1;
102
    if (li_end) {
103
        index_end = parseInt(li_end.attr("class").substring(7), 10);
104
    }
105
    if (index_end < arrPagination.length - 1) {
106
        renderPagIndexList(index_ini + 1, ul, false);
107
        renderPagination(index_ini + 1, arrPagination.length - 1, $("#ul_pagination_list"), true);
108
    }
109
}//forwardList
110
111
function renderPagIndexList(index, ul)
112
{
113
    var $kids = ul.children("li");
114
    if ($kids.length > 0) {
115
        $kids.each(function() {
116
            $(this).remove();
117
        });
118
    }
119
    var li;
120
    var html = "";
121
    var ini = index - 1;
122
    var end = ini + totalPagItemList - 1;
123
    li = $("<li />");
124
    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;";
125
    li.html(html);
126
    ul.append(li);
127
    var title = "";
128
    for (var i=index; i < arrPagination.length && i < index + totalPagItemList; i++) {
129
        if (arrPagination[i] == undefined) continue;
130
        var li = $("<li />");
131
        if (arrPagination[i].url != "") {
132
            title = "See biblio &quot;" + arrPagination[i].title + "&quot; ";
133
            if (arrPagination[i].author != "") title += " by &quot;" + arrPagination[i].author + "&quot;";
134
            title += " with biblionumber " + arrPagination[i].biblionumber;
135
            html = "<a href='" + arrPagination[i].url + "' title='" + title + "' class='a_pag' id='a_pag_" + i + "'";
136
            html += " onmouseover='renderPagination(" + i + ", " + (arrPagination.length - 1) + ", $(\"#ul_pagination_list\"), true)'";
137
            html += ">" + i + "</a>";
138
        } else html = i;
139
        li.html(html);
140
        li.attr("class", "li_pag_" + i);
141
        ul.append(li);
142
    }
143
    li = $("<li />");
144
    ini = index + 1;
145
    end = (arrPagination.length > index + totalPagItemList)?index + totalPagItemList:arrPagination.length - 1;
146
    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;";
147
    li.html(html);
148
    ul.append(li);
149
}//renderPagIndexList
150
151
152
function renderPagination(index, total, ul, highlIndex)
153
{
154
    for (var i = pag_index_ini; i <= total; i++) {
155
        if (arrPagination[i] == undefined || arrPagination[i].url == "") continue;
156
        $("#li_pag_" + i).remove();
157
    }
158
    var j = 0;
159
    for (var i = index; i <= total && j < totalPagItemList; i++) {
160
        if (arrPagination[i] == undefined || arrPagination[i].url == "") continue;
161
        var li = $("<li id='li_pag_" + i + "' " + ((j % 2 == 0)?"class='highlight'":"")  + " title='Go to detail' />");
162
        var html = "<span class='li_pag_index'>" + i + "</span><a href='" + arrPagination[i].url + "'>" + arrPagination[i].title + "</a>";
163
        if (arrPagination[i].author) html += "<br /> by " + arrPagination[i].author;
164
        li.html(html);
165
        if (highlIndex && i == index) li.css("backgroundColor", "#DDDDDD");
166
        ul.append(li);
167
        j++;
168
    }
169
    for (i = pag_index_ini; i < index && j < totalPagItemList; i++) {
170
        if (arrPagination[i] == undefined || arrPagination[i].url == "") continue;
171
        $("#li_pag_" + i).remove();
172
        var li = $("<li id='li_pag_" + i + "' " + ((j % 2 == 0)?"class='highlight'":"")  + " title='Go to detail' />");
173
        var html = "<span class='li_pag_index'>" + i + "</span><a href='" + arrPagination[i].url + "'>" + arrPagination[i].title + "</a>";
174
        if (arrPagination[i].author) html += "<br /> by " + arrPagination[i].author;
175
        li.html(html);
176
        ul.append(li);
177
        j++;
178
    }
179
}//renderPagination
180
[% END %]
181
182
30
YAHOO.util.Event.onContentReady("furtherm", function () {
183
YAHOO.util.Event.onContentReady("furtherm", function () {
31
    $("#furtherm").css("display","block").css("visibility","hidden");
184
    $("#furtherm").css("display","block").css("visibility","hidden");
32
	$("#furthersearches").parent().show();
185
	$("#furthersearches").parent().show();
Lines 787-798 YAHOO.util.Event.onContentReady("furtherm", function () { Link Here
787
[% END %]
940
[% END %]
788
[% END %]
941
[% END %]
789
942
943
790
</div>
944
</div>
791
</div>
945
</div>
792
</div>
946
</div>
793
947
948
794
<div class="yui-u">
949
<div class="yui-u">
795
<div id="ulactioncontainer" class="container">
950
<div id="ulactioncontainer" class="container">
951
[% IF ( busc ) %]
952
    <div class="nav_results">
953
        <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>
954
        <ul class="pg_menu">
955
            <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>
956
            <li class="back_results"><a href="opac-search.pl?[% busc %]" title="Back to the results search list">Back to results</a></li>
957
            <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>
958
        </ul>
959
        [% IF ( listResults ) %]
960
        <div class="pagination">
961
            <div class="nav">
962
                <span class="close_pagination"><a href="#" id="close_pagination">Close</a></span>
963
                <ul id="listResults"></ul>
964
            </div>
965
            <div class="pagination_list">
966
                <ul id="ul_pagination_list"></ul>
967
            </div>
968
        </div>
969
        [% END %]
970
    </div>
971
[% END %]
796
<ul id="action">
972
<ul id="action">
797
973
798
[% UNLESS ( norequests ) %]
974
[% 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 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