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

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-authoritiessearchresultlist.tt (-30 / +6 lines)
Lines 1-31 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
[% PROCESS 'opac-authorities.inc' %]
2
[% PROCESS 'opac-authorities.inc' %]
3
[% PROCESS 'authorities-search-results.inc' %]
3
[% PROCESS 'authorities-search-results.inc' %]
4
[% pagination = BLOCK %]
5
    <div class="pagination">
6
        <ul>
7
            [% IF ( displayprev ) %]
8
                <li>
9
                    <a href="opac-authorities-home.pl?startfrom=[% startfromprev %]&amp;[% FOREACH searchdat IN searchdata %][% searchdat.term %]=[% searchdat.val |url %]&amp;[% END %]resultsperpage=[% resultsperpage |html %]&amp;type=opac&amp;op=do_search&amp;authtypecode=[% authtypecode %]&amp;orderby=[% orderby|html %]">
10
                        &laquo;
11
                    </a>
12
                </li>
13
            [% END %]
14
            [% FOREACH number IN numbers %]
15
                [% IF ( number.highlight ) %]
16
                    <li class="active"><a href="#">[% number.number %]</a></li>
17
                [% ELSE %]
18
                    <li><a href="opac-authorities-home.pl?startfrom=[% number.startfrom %]&amp;[% FOREACH searchdat IN number.searchdata %][% searchdat.term %]=[% searchdat.val |url %]&amp;[% END %]resultsperpage=[% resultsperpage |html %]&amp;type=opac&amp;op=do_search&amp;authtypecode=[% authtypecode %]&amp;orderby=[% orderby|html %]">[% number.number %]</a></li>
19
                [% END %]
20
            [% END %]
21
            [% IF ( displaynext ) %]
22
                <li>
23
                    <a href="opac-authorities-home.pl?startfrom=[% startfromnext %]&amp;[% FOREACH searchdat IN searchdata %][% searchdat.term %]=[% searchdat.val |url %]&amp;[% END %]&amp;resultsperpage=[% resultsperpage |html %]&amp;type=opac&amp;op=do_search&amp;authtypecode=[% authtypecode %]&amp;orderby=[% orderby|html %]">&raquo;</a>
24
                </li>
25
            [% END %]
26
        </ul>
27
    </div> <!-- / #pages -->
28
[% END %]
29
[% INCLUDE 'doc-head-open.inc' %]
4
[% INCLUDE 'doc-head-open.inc' %]
30
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; [% IF ( total ) %]Authority search result[% ELSE %]No results found[% END %]</title>
5
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; [% IF ( total ) %]Authority search result[% ELSE %]No results found[% END %]</title>
31
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'doc-head-close.inc' %]
Lines 56-69 Link Here
56
                    <div id="userauthsearchresults" class="maincontent">
31
                    <div id="userauthsearchresults" class="maincontent">
57
                        <h1>Authority search results</h1>
32
                        <h1>Authority search results</h1>
58
33
59
                        [% pagination %]
34
                        [% IF total %]
60
35
                            <div class="pages">[% pagination_bar %]</div>
36
                        [% END %]
61
                        <div id="results">
37
                        <div id="results">
62
                            [% IF ( total ) %]
38
                            [% IF ( total ) %]
63
                                [% IF ( countfuzzy ) %]
39
                                [% IF ( countfuzzy ) %]
64
                                    <b>Showing [% resultcount %] of about [% total %] results</b>
40
                                    <p><b>Showing [% resultcount %] of about [% total %] results</b></p>
65
                                [% ELSE %]
41
                                [% ELSE %]
66
                                    <b>Results [% from %] to [% to %] of [% total %]</b>
42
                                    <p><b>Results [% from %] to [% to %] of [% total %]</b></p>
67
                                [% END %]
43
                                [% END %]
68
                            [% ELSE %]
44
                            [% ELSE %]
69
                                No results found.
45
                                No results found.
Lines 102-108 Link Here
102
                                </table>
78
                                </table>
103
                            </div> <!-- / .searchresults -->
79
                            </div> <!-- / .searchresults -->
104
80
105
                            [% pagination %]
81
                            <div class="pages">[% pagination_bar %]</div>
106
82
107
                        [% END # / IF total %]
83
                        [% END # / IF total %]
108
                    </div> <!-- / #userauthsearchresults -->
84
                    </div> <!-- / #userauthsearchresults -->
(-)a/koha-tmpl/opac-tmpl/bootstrap/less/opac.less (-1 / +3 lines)
Lines 1957-1963 span.sep { Link Here
1957
}
1957
}
1958
1958
1959
/* style for PM-generated pagination bar */
1959
/* style for PM-generated pagination bar */
1960
1960
.pages {
1961
    margin: 20px 0;
1962
}
1961
.pages span:first-child,
1963
.pages span:first-child,
1962
.pages a:first-child {
1964
.pages a:first-child {
1963
    border-width: 1px 1px 1px 1px;
1965
    border-width: 1px 1px 1px 1px;
(-)a/opac/opac-authorities-home.pl (-58 / +36 lines)
Lines 22-27 use strict; Link Here
22
use warnings;
22
use warnings;
23
23
24
use CGI qw ( -utf8 );
24
use CGI qw ( -utf8 );
25
use URI::Escape;
25
use C4::Auth;
26
use C4::Auth;
26
27
27
use C4::Context;
28
use C4::Context;
Lines 40-50 my $op = $query->param('op') || ''; Link Here
40
my $authtypecode = $query->param('authtypecode') || '';
41
my $authtypecode = $query->param('authtypecode') || '';
41
my $dbh          = C4::Context->dbh;
42
my $dbh          = C4::Context->dbh;
42
43
43
my $startfrom = $query->param('startfrom');
44
my $startfrom = $query->param('startfrom') || 1;
45
my $resultsperpage = $query->param('resultsperpage') || 20;
44
my $authid    = $query->param('authid');
46
my $authid    = $query->param('authid');
45
$startfrom = 0 if ( !defined $startfrom );
46
my ( $template, $loggedinuser, $cookie );
47
my ( $template, $loggedinuser, $cookie );
47
my $resultsperpage;
48
48
49
my $authority_types = Koha::Authority::Types->search({}, { order_by => ['authtypetext']});
49
my $authority_types = Koha::Authority::Types->search({}, { order_by => ['authtypetext']});
50
50
Lines 57-64 if ( $op eq "do_search" ) { Link Here
57
    my @value = $query->multi_param('value');
57
    my @value = $query->multi_param('value');
58
    $value[0] ||= q||;
58
    $value[0] ||= q||;
59
59
60
    $resultsperpage = $query->param('resultsperpage');
61
    $resultsperpage = 20 if ( !defined $resultsperpage );
62
    my @tags;
60
    my @tags;
63
    my $builder = Koha::SearchEngine::QueryBuilder->new(
61
    my $builder = Koha::SearchEngine::QueryBuilder->new(
64
        { index => $Koha::SearchEngine::AUTHORITIES_INDEX } );
62
        { index => $Koha::SearchEngine::AUTHORITIES_INDEX } );
Lines 66-78 if ( $op eq "do_search" ) { Link Here
66
        { index => $Koha::SearchEngine::AUTHORITIES_INDEX } );
64
        { index => $Koha::SearchEngine::AUTHORITIES_INDEX } );
67
    my $search_query = $builder->build_authorities_query_compat( \@marclist, \@and_or,
65
    my $search_query = $builder->build_authorities_query_compat( \@marclist, \@and_or,
68
        \@excluding, \@operator, \@value, $authtypecode, $orderby );
66
        \@excluding, \@operator, \@value, $authtypecode, $orderby );
69
#    use Data::Dumper;
70
#    die Dumper(\@marclist, \@and_or,
71
#        \@excluding, \@operator, \@value, $authtypecode, $orderby, $query);
72
    # The searchengine API expects pages to start at page 1
73
    $startfrom = $startfrom // 0;
74
    my ( $results, $total ) =
67
    my ( $results, $total ) =
75
      $searcher->search_auth_compat( $search_query, $startfrom+1, $resultsperpage );
68
      $searcher->search_auth_compat( $search_query, $startfrom, $resultsperpage );
76
    ( $template, $loggedinuser, $cookie ) = get_template_and_user(
69
    ( $template, $loggedinuser, $cookie ) = get_template_and_user(
77
        {
70
        {
78
            template_name   => "opac-authoritiessearchresultlist.tt",
71
            template_name   => "opac-authoritiessearchresultlist.tt",
Lines 84-131 if ( $op eq "do_search" ) { Link Here
84
    );
77
    );
85
78
86
    # multi page display gestion
79
    # multi page display gestion
87
    my $displaynext = 0;
80
    my $value_url = uri_escape_utf8($value[0]);
88
    my $displayprev = $startfrom;
81
    my $base_url = "opac-authorities-home.pl?"
89
    $total ||= 0;
82
      ."marclist=$marclist[0]"
90
    if ( ( $total - ( ( $startfrom + 1 ) * ($resultsperpage) ) ) > 0 ) {
83
      ."&amp;and_or=$and_or[0]"
91
        $displaynext = 1;
84
      ."&amp;excluding=$excluding[0]"
92
    }
85
      ."&amp;operator=$operator[0]"
93
86
      ."&amp;value=$value_url"
94
    my @field_data = (
87
      ."&amp;resultsperpage=$resultsperpage"
95
        { term => "marclist",  val => $marclist[0] },
88
      ."&amp;type=opac"
96
        { term => "and_or",    val => $and_or[0] },
89
      ."&amp;op=do_search"
97
        { term => "excluding", val => $excluding[0] },
90
      ."&amp;authtypecode=$authtypecode"
98
        { term => "operator",  val => $operator[0] },
91
      ."&amp;orderby=$orderby";
99
        { term => "value",     val => $value[0] },
92
100
    );
93
    my $from = ( $startfrom - 1 ) * $resultsperpage + 1;
101
102
    my @numbers = ();
103
104
    if ( $total > $resultsperpage ) {
105
        for ( my $i = 1 ; $i < $total / $resultsperpage + 1 ; $i++ ) {
106
            if ( $i < 16 ) {
107
                my $highlight = 0;
108
                ( $startfrom == ( $i - 1 ) ) && ( $highlight = 1 );
109
                push @numbers,
110
                  {
111
                    number     => $i,
112
                    highlight  => $highlight,
113
                    searchdata => \@field_data,
114
                    startfrom  => ( $i - 1 )
115
                  };
116
            }
117
        }
118
    }
119
120
    my $from = $startfrom * $resultsperpage + 1;
121
    my $to;
94
    my $to;
95
    if ( !defined $total ) {
96
        $total = 0;
97
    }
122
98
123
    if ( $total < ( ( $startfrom + 1 ) * $resultsperpage ) ) {
99
    if ( $total < $startfrom * $resultsperpage ) {
124
        $to = $total;
100
        $to = $total;
125
    }
101
    }
126
    else {
102
    else {
127
        $to = ( ( $startfrom + 1 ) * $resultsperpage );
103
        $to = $startfrom * $resultsperpage;
128
    }
104
    }
105
106
    $template->param( result => $results ) if $results;
107
108
    $template->param(
109
        pagination_bar => pagination_bar(
110
            $base_url,  int( $total / $resultsperpage ) + 1,
111
            $startfrom, 'startfrom'
112
        ),
113
        total     => $total,
114
        from      => $from,
115
        to        => $to,
116
    );
117
129
    unless (C4::Context->preference('OPACShowUnusedAuthorities')) {
118
    unless (C4::Context->preference('OPACShowUnusedAuthorities')) {
130
#        TODO implement usage counts
119
#        TODO implement usage counts
131
#        my @usedauths = grep { $_->{used} > 0 } @$results;
120
#        my @usedauths = grep { $_->{used} > 0 } @$results;
Lines 162-183 if ( $op eq "do_search" ) { Link Here
162
        }
151
        }
163
    }
152
    }
164
153
165
    $template->param( result => $results ) if $results;
166
    $template->param( orderby => $orderby );
154
    $template->param( orderby => $orderby );
167
    $template->param(
155
    $template->param(
168
        startfrom      => $startfrom,
156
        startfrom      => $startfrom,
169
        displaynext    => $displaynext,
170
        displayprev    => $displayprev,
171
        resultsperpage => $resultsperpage,
157
        resultsperpage => $resultsperpage,
172
        startfromnext  => $startfrom + 1,
173
        startfromprev  => $startfrom - 1,
174
        searchdata     => \@field_data,
175
        countfuzzy     => !(C4::Context->preference('OPACShowUnusedAuthorities')),
158
        countfuzzy     => !(C4::Context->preference('OPACShowUnusedAuthorities')),
176
        total          => $total,
177
        from           => $from,
178
        to             => $to,
179
        resultcount    => scalar @$results,
159
        resultcount    => scalar @$results,
180
        numbers        => \@numbers,
181
        authtypecode   => $authtypecode,
160
        authtypecode   => $authtypecode,
182
        authtypetext   => $authority_types->find($authtypecode)->authtypetext,
161
        authtypetext   => $authority_types->find($authtypecode)->authtypetext,
183
        isEDITORS      => $authtypecode eq 'EDITORS',
162
        isEDITORS      => $authtypecode eq 'EDITORS',
184
- 

Return to bug 2735