Lines 194-205
sub SearchPrefs {
Link Here
|
194 |
my %tab_files = _get_pref_files( $input ); |
194 |
my %tab_files = _get_pref_files( $input ); |
195 |
our @terms = split( /\s+/, $searchfield ); |
195 |
our @terms = split( /\s+/, $searchfield ); |
196 |
|
196 |
|
197 |
sub matches { |
|
|
198 |
my ( $text ) = @_; |
199 |
|
200 |
return !grep( { $text !~ /$_/i } @terms ); |
201 |
} |
202 |
|
203 |
foreach my $tab_name ( keys %tab_files ) { |
197 |
foreach my $tab_name ( keys %tab_files ) { |
204 |
my $data = GetTab( $input, $tab_name ); |
198 |
my $data = GetTab( $input, $tab_name ); |
205 |
my $title = ( keys( %$data ) )[0]; |
199 |
my $title = ( keys( %$data ) )[0]; |
Lines 209-215
sub SearchPrefs {
Link Here
|
209 |
my $matched_groups; |
203 |
my $matched_groups; |
210 |
|
204 |
|
211 |
while ( my ( $group_title, $contents ) = each %$tab ) { |
205 |
while ( my ( $group_title, $contents ) = each %$tab ) { |
212 |
if ( matches( $group_title ) ) { |
206 |
if ( matches( $group_title, \@terms ) ) { |
213 |
$matched_groups->{$group_title} = $contents; |
207 |
$matched_groups->{$group_title} = $contents; |
214 |
next; |
208 |
next; |
215 |
} |
209 |
} |
Lines 225-236
sub SearchPrefs {
Link Here
|
225 |
my ( undef, $LINES ) = TransformPrefsToHTML( $data, $searchfield ); |
219 |
my ( undef, $LINES ) = TransformPrefsToHTML( $data, $searchfield ); |
226 |
|
220 |
|
227 |
return { search_jumped => 1, tab => $tab_name, tab_title => $title, LINES => $LINES }; |
221 |
return { search_jumped => 1, tab => $tab_name, tab_title => $title, LINES => $LINES }; |
228 |
} elsif ( matches( $piece->{'pref'} ) ) { |
222 |
} elsif ( matches( $piece->{'pref'}, \@terms) ) { |
229 |
$matched = 1; |
223 |
$matched = 1; |
230 |
} elsif ( ref( $piece->{'choices'} ) eq 'HASH' && grep( { $_ && matches( $_ ) } values( %{ $piece->{'choices'} } ) ) ) { |
224 |
} elsif ( ref( $piece->{'choices'} ) eq 'HASH' && grep( { $_ && matches( $_, \@terms ) } values( %{ $piece->{'choices'} } ) ) ) { |
231 |
$matched = 1; |
225 |
$matched = 1; |
232 |
} |
226 |
} |
233 |
} elsif ( matches( $piece ) ) { |
227 |
} elsif ( matches( $piece, \@terms ) ) { |
234 |
$matched = 1; |
228 |
$matched = 1; |
235 |
} |
229 |
} |
236 |
last if ( $matched ); |
230 |
last if ( $matched ); |
Lines 252-257
sub SearchPrefs {
Link Here
|
252 |
return @tabs; |
246 |
return @tabs; |
253 |
} |
247 |
} |
254 |
|
248 |
|
|
|
249 |
sub matches { |
250 |
my ( $text, $terms ) = @_; |
251 |
return !grep( { $text !~ /$_/i } @$terms ); |
252 |
} |
253 |
|
255 |
my $dbh = C4::Context->dbh; |
254 |
my $dbh = C4::Context->dbh; |
256 |
our $input = new CGI; |
255 |
our $input = new CGI; |
257 |
|
256 |
|