|
Lines 27-90
use C4::Auth;
Link Here
|
| 27 |
use C4::Context; |
27 |
use C4::Context; |
| 28 |
use C4::AuthoritiesMarc; |
28 |
use C4::AuthoritiesMarc; |
| 29 |
use C4::Acquisition; |
29 |
use C4::Acquisition; |
| 30 |
use C4::Koha; # XXX subfield_is_koha_internal_p |
30 |
use C4::Koha; |
| 31 |
|
31 |
|
| 32 |
my $query = new CGI; |
32 |
my $query = new CGI; |
| 33 |
my $op = $query->param('op'); |
33 |
my $op = $query->param('op') || ''; |
| 34 |
my $authtypecode = $query->param('authtypecode'); |
34 |
my $authtypecode = $query->param('authtypecode') || ''; |
| 35 |
my $index = $query->param('index'); |
35 |
my $index = $query->param('index') || ''; |
| 36 |
my $tagid = $query->param('tagid'); |
36 |
my $tagid = $query->param('tagid') || ''; |
| 37 |
my $resultstring = $query->param('result'); |
37 |
my $source = $query->param('source') || ''; |
| 38 |
my $relationship = $query->param('relationship'); |
38 |
my $relationship = $query->param('relationship') || ''; |
| 39 |
my $dbh = C4::Context->dbh; |
39 |
|
| 40 |
|
40 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user( |
| 41 |
my $startfrom = $query->param('startfrom'); |
41 |
{ |
| 42 |
$startfrom = 0 if ( !defined $startfrom ); |
42 |
template_name => ( $op eq 'do_search' ) |
| 43 |
my ( $template, $loggedinuser, $cookie ); |
43 |
? 'authorities/searchresultlist-auth.tt' |
| 44 |
my $resultsperpage; |
44 |
: 'authorities/auth_finder.tt', |
| 45 |
|
45 |
query => $query, |
| 46 |
my $authtypes = getauthtypes; |
46 |
type => 'intranet', |
|
|
47 |
authnotrequired => 0, |
| 48 |
flagsrequired => { catalogue => 1 }, |
| 49 |
} |
| 50 |
); |
| 51 |
|
| 52 |
# Authority types loop |
| 53 |
my $authtypes = C4::Koha::getauthtypes(); |
| 47 |
my @authtypesloop; |
54 |
my @authtypesloop; |
| 48 |
foreach my $thisauthtype ( keys %$authtypes ) { |
55 |
foreach my $thisauthtype ( keys %$authtypes ) { |
| 49 |
my %row = ( |
56 |
my %row = ( |
| 50 |
value => $thisauthtype, |
57 |
value => $thisauthtype, |
| 51 |
selected => ($thisauthtype eq $authtypecode), |
58 |
selected => ( $thisauthtype eq $authtypecode ), |
| 52 |
authtypetext => $authtypes->{$thisauthtype}{'authtypetext'}, |
59 |
authtypetext => $authtypes->{$thisauthtype}{'authtypetext'}, |
| 53 |
index => $index, |
60 |
index => $index, |
| 54 |
); |
61 |
); |
| 55 |
push @authtypesloop, \%row; |
62 |
push @authtypesloop, \%row; |
| 56 |
} |
63 |
} |
| 57 |
|
64 |
|
| 58 |
$op ||= q{}; |
65 |
# If search form posted |
| 59 |
if ( $op eq "do_search" ) { |
66 |
if ( $op eq "do_search" ) { |
| 60 |
my @marclist = $query->param('marclist'); |
67 |
my @marclist = $query->param('marclist'); |
| 61 |
my @and_or = $query->param('and_or'); |
68 |
my @and_or = $query->param('and_or'); |
| 62 |
my @excluding = $query->param('excluding'); |
69 |
my @excluding = $query->param('excluding'); |
| 63 |
my @operator = $query->param('operator'); |
70 |
my @operator = $query->param('operator'); |
| 64 |
my @value = ($query->param('value_mainstr')||undef, $query->param('value_main')||undef, $query->param('value_any')||undef, $query->param('value_match')||undef); |
71 |
my @value = ( |
| 65 |
my $orderby = $query->param('orderby'); |
72 |
$query->param('value_mainstr') || undef, |
| 66 |
|
73 |
$query->param('value_main') || undef, |
| 67 |
$resultsperpage = $query->param('resultsperpage'); |
74 |
$query->param('value_any') || undef, |
| 68 |
$resultsperpage = 20 if ( !defined $resultsperpage ); |
75 |
$query->param('value_match') || undef |
|
|
76 |
); |
| 77 |
my $orderby = $query->param('orderby') || ''; |
| 78 |
my $startfrom = $query->param('startfrom') || 0; |
| 79 |
my $resultsperpage = $query->param('resultsperpage') || 20; |
| 69 |
|
80 |
|
| 70 |
my ( $results, $total ) = |
81 |
my ( $results, $total ) = |
| 71 |
SearchAuthorities( \@marclist, \@and_or, \@excluding, \@operator, \@value, |
82 |
SearchAuthorities( \@marclist, \@and_or, \@excluding, \@operator, \@value, |
| 72 |
$startfrom * $resultsperpage, |
83 |
$startfrom * $resultsperpage, |
| 73 |
$resultsperpage, $authtypecode, $orderby); |
84 |
$resultsperpage, $authtypecode, $orderby ); |
| 74 |
|
85 |
|
| 75 |
# If an authority heading is repeated, add an arrayref to those repetions |
86 |
# If an authority heading is repeated, add an arrayref to those repetions |
| 76 |
# First heading -- Second heading |
87 |
# First heading -- Second heading |
| 77 |
for my $heading ( @$results ) { |
88 |
for my $heading (@$results) { |
| 78 |
my @repets = split / -- /, $heading->{summary}; |
89 |
my @repets = split / -- /, $heading->{summary}; |
| 79 |
if ( @repets > 1 ) { |
90 |
if ( @repets > 1 ) { |
| 80 |
my @repets_loop; |
91 |
my @repets_loop; |
| 81 |
for (my $i = 0; $i < @repets; $i++) { |
92 |
for ( my $i = 0 ; $i < @repets ; $i++ ) { |
| 82 |
push @repets_loop, |
93 |
push @repets_loop, |
| 83 |
{ index => $index, repet => $i+1, value => $repets[$i] }; |
94 |
{ index => $index, repet => $i + 1, value => $repets[$i] }; |
| 84 |
} |
95 |
} |
| 85 |
$heading->{repets} = \@repets_loop; |
96 |
$heading->{repets} = \@repets_loop; |
| 86 |
} |
97 |
} |
| 87 |
} |
98 |
} |
|
|
99 |
|
| 88 |
# multi page display gestion |
100 |
# multi page display gestion |
| 89 |
my $displaynext = 0; |
101 |
my $displaynext = 0; |
| 90 |
my $displayprev = $startfrom; |
102 |
my $displayprev = $startfrom; |
|
Lines 94-102
if ( $op eq "do_search" ) {
Link Here
|
| 94 |
|
106 |
|
| 95 |
my @field_data = (); |
107 |
my @field_data = (); |
| 96 |
|
108 |
|
| 97 |
my @marclist_ini = |
109 |
# get marclist again, as the previous one has been modified by catalogsearch (mainentry replaced by field name) |
| 98 |
$query->param('marclist') |
110 |
my @marclist_ini = $query->param('marclist'); |
| 99 |
; # get marclist again, as the previous one has been modified by catalogsearch (mainentry replaced by field name |
|
|
| 100 |
for ( my $i = 0 ; $i <= $#marclist ; $i++ ) { |
111 |
for ( my $i = 0 ; $i <= $#marclist ; $i++ ) { |
| 101 |
push @field_data, { term => "marclist", val => $marclist_ini[$i] }; |
112 |
push @field_data, { term => "marclist", val => $marclist_ini[$i] }; |
| 102 |
push @field_data, { term => "and_or", val => $and_or[$i] }; |
113 |
push @field_data, { term => "and_or", val => $and_or[$i] }; |
|
Lines 104-116
if ( $op eq "do_search" ) {
Link Here
|
| 104 |
push @field_data, { term => "operator", val => $operator[$i] }; |
115 |
push @field_data, { term => "operator", val => $operator[$i] }; |
| 105 |
} |
116 |
} |
| 106 |
|
117 |
|
| 107 |
push @field_data, { term => "value_mainstr", val => $query->param('value_mainstr') || "" }; |
118 |
push @field_data, |
| 108 |
push @field_data, { term => "value_main", val => $query->param('value_main') || "" }; |
119 |
{ term => "value_mainstr", val => $query->param('value_mainstr') || "" }; |
| 109 |
push @field_data, { term => "value_any", val => $query->param('value_any') || ""}; |
120 |
push @field_data, |
| 110 |
push @field_data, { term => "value_match", val => $query->param('value_match') || ""}; |
121 |
{ term => "value_main", val => $query->param('value_main') || "" }; |
|
|
122 |
push @field_data, |
| 123 |
{ term => "value_any", val => $query->param('value_any') || "" }; |
| 124 |
push @field_data, |
| 125 |
{ term => "value_match", val => $query->param('value_match') || "" }; |
| 111 |
|
126 |
|
| 112 |
my @numbers = (); |
127 |
my @numbers = (); |
| 113 |
|
|
|
| 114 |
if ( $total > $resultsperpage ) { |
128 |
if ( $total > $resultsperpage ) { |
| 115 |
for ( my $i = 1 ; $i < $total / $resultsperpage + 1 ; $i++ ) { |
129 |
for ( my $i = 1 ; $i < $total / $resultsperpage + 1 ; $i++ ) { |
| 116 |
if ( $i < 16 ) { |
130 |
if ( $i < 16 ) { |
|
Lines 129-201
if ( $op eq "do_search" ) {
Link Here
|
| 129 |
|
143 |
|
| 130 |
my $from = $startfrom * $resultsperpage + 1; |
144 |
my $from = $startfrom * $resultsperpage + 1; |
| 131 |
my $to; |
145 |
my $to; |
| 132 |
|
|
|
| 133 |
if ( $total < ( ( $startfrom + 1 ) * $resultsperpage ) ) { |
146 |
if ( $total < ( ( $startfrom + 1 ) * $resultsperpage ) ) { |
| 134 |
$to = $total; |
147 |
$to = $total; |
| 135 |
} |
148 |
} |
| 136 |
else { |
149 |
else { |
| 137 |
$to = ( ( $startfrom + 1 ) * $resultsperpage ); |
150 |
$to = ( ( $startfrom + 1 ) * $resultsperpage ); |
| 138 |
} |
151 |
} |
| 139 |
( $template, $loggedinuser, $cookie ) = get_template_and_user( |
|
|
| 140 |
{ |
| 141 |
template_name => "authorities/searchresultlist-auth.tt", |
| 142 |
query => $query, |
| 143 |
type => 'intranet', |
| 144 |
authnotrequired => 0, |
| 145 |
flagsrequired => { catalogue => 1 }, |
| 146 |
} |
| 147 |
); |
| 148 |
|
152 |
|
| 149 |
$template->param( result => $results ) if $results; |
153 |
$template->param( result => $results ) if $results; |
| 150 |
$template->param( |
154 |
$template->param( |
| 151 |
orderby => $orderby, |
155 |
orderby => $orderby, |
| 152 |
startfrom => $startfrom, |
156 |
startfrom => $startfrom, |
| 153 |
displaynext => $displaynext, |
157 |
displaynext => $displaynext, |
| 154 |
displayprev => $displayprev, |
158 |
displayprev => $displayprev, |
| 155 |
resultsperpage => $resultsperpage, |
159 |
resultsperpage => $resultsperpage, |
| 156 |
startfromnext => $startfrom + 1, |
160 |
startfromnext => $startfrom + 1, |
| 157 |
startfromprev => $startfrom - 1, |
161 |
startfromprev => $startfrom - 1, |
| 158 |
searchdata => \@field_data, |
162 |
searchdata => \@field_data, |
| 159 |
total => $total, |
163 |
total => $total, |
| 160 |
from => $from, |
164 |
from => $from, |
| 161 |
to => $to, |
165 |
to => $to, |
| 162 |
numbers => \@numbers, |
166 |
numbers => \@numbers, |
| 163 |
operator_mainstr => ( @operator > 0 && $operator[0] ) ? $operator[0] : '', |
167 |
operator_mainstr => ( @operator > 0 && $operator[0] ) |
| 164 |
operator_main => ( @operator > 1 && $operator[1] ) ? $operator[1] : '', |
168 |
? $operator[0] |
| 165 |
operator_any => ( @operator > 2 && $operator[2] ) ? $operator[2] : '', |
169 |
: '', |
| 166 |
operator_match => ( @operator > 3 && $operator[3] ) ? $operator[3] : '', |
170 |
operator_main => ( @operator > 1 && $operator[1] ) ? $operator[1] : '', |
| 167 |
); |
171 |
operator_any => ( @operator > 2 && $operator[2] ) ? $operator[2] : '', |
| 168 |
} else { |
172 |
operator_match => ( @operator > 3 && $operator[3] ) ? $operator[3] : '', |
| 169 |
( $template, $loggedinuser, $cookie ) = get_template_and_user( |
|
|
| 170 |
{ |
| 171 |
template_name => "authorities/auth_finder.tt", |
| 172 |
query => $query, |
| 173 |
type => 'intranet', |
| 174 |
authnotrequired => 0, |
| 175 |
flagsrequired => { catalogue => 1 }, |
| 176 |
} |
| 177 |
); |
173 |
); |
|
|
174 |
} |
| 175 |
else { |
| 178 |
|
176 |
|
| 179 |
$template->param( |
177 |
# special case for UNIMARC field 210c builder |
| 180 |
resultstring => $resultstring, |
178 |
my $resultstring = $query->param('result') || ''; |
| 181 |
); |
179 |
$template->param( resultstring => $resultstring, ); |
| 182 |
} |
180 |
} |
| 183 |
|
181 |
|
| 184 |
$template->param( |
182 |
$template->param( |
| 185 |
op => $op, |
183 |
op => $op, |
| 186 |
value_mainstr => $query->param('value_mainstr') || "", |
184 |
value_mainstr => $query->param('value_mainstr') || '', |
| 187 |
value_main => $query->param('value_main') || "", |
185 |
value_main => $query->param('value_main') || '', |
| 188 |
value_any => $query->param('value_any') || "", |
186 |
value_any => $query->param('value_any') || '', |
| 189 |
value_match => $query->param('value_match') || "", |
187 |
value_match => $query->param('value_match') || '', |
| 190 |
tagid => $tagid, |
188 |
tagid => $tagid, |
| 191 |
index => $index, |
189 |
index => $index, |
| 192 |
authtypesloop => \@authtypesloop, |
190 |
authtypesloop => \@authtypesloop, |
| 193 |
authtypecode => $authtypecode, |
191 |
authtypecode => $authtypecode, |
|
|
192 |
source => $source, |
| 193 |
relationship => $relationship, |
| 194 |
); |
194 |
); |
| 195 |
|
195 |
|
| 196 |
$template->{VARS}->{source} = $query->param('source') || ''; |
|
|
| 197 |
$template->{VARS}->{relationship} = $query->param('relationship') || ''; |
| 198 |
|
| 199 |
# Print the page |
196 |
# Print the page |
| 200 |
output_html_with_http_headers $query, $cookie, $template->output; |
197 |
output_html_with_http_headers $query, $cookie, $template->output; |
| 201 |
|
198 |
|
| 202 |
- |
|
|