From ab6c1b02b9c49d3f2237050233aa488faa7b90e1 Mon Sep 17 00:00:00 2001 From: Brendan Lawlor Date: Thu, 1 Aug 2024 13:59:28 +0000 Subject: [PATCH] Bug 14322: (follow-up) Perl tidy Signed-off-by: David Nind Signed-off-by: Paul Derscheid Signed-off-by: Katrin Fischer --- catalogue/itemsearch.pl | 50 ++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/catalogue/itemsearch.pl b/catalogue/itemsearch.pl index a8134712f4..40b42adeb7 100755 --- a/catalogue/itemsearch.pl +++ b/catalogue/itemsearch.pl @@ -38,61 +38,65 @@ my $cgi = CGI->new; my $format = $cgi->param('format'); my $template_name = 'catalogue/itemsearch.tt'; -if (defined $format and $format eq 'json') { +if ( defined $format and $format eq 'json' ) { $template_name = 'catalogue/itemsearch_json.tt'; # Map DataTables parameters with 'regular' parameters - $cgi->param('rows', scalar $cgi->param('length')); - $cgi->param('page', (scalar $cgi->param('start') / scalar $cgi->param('length')) + 1); + $cgi->param( 'rows', scalar $cgi->param('length') ); + $cgi->param( 'page', ( scalar $cgi->param('start') / scalar $cgi->param('length') ) + 1 ); my @columns = @{ from_json $cgi->param('columns') }; - $cgi->param('sortby', $columns[ $cgi->param('order[0][column]') ]->{name}); - $cgi->param('sortorder', scalar $cgi->param('order[0][dir]')); + $cgi->param( 'sortby', $columns[ $cgi->param('order[0][column]') ]->{name} ); + $cgi->param( 'sortorder', scalar $cgi->param('order[0][dir]') ); my @f = $cgi->multi_param('f'); my @q = $cgi->multi_param('q'); # If index indicates the value is a barcode, we need to preprocess it before searching - for ( my $i = 0; $i < @q; $i++ ) { - $q[$i] = barcodedecode($q[$i]) if $f[$i] eq 'barcode'; + for ( my $i = 0 ; $i < @q ; $i++ ) { + $q[$i] = barcodedecode( $q[$i] ) if $f[$i] eq 'barcode'; } push @q, '' if @q == 0; my @op = $cgi->multi_param('op'); - my @c = $cgi->multi_param('c'); + my @c = $cgi->multi_param('c'); for my $column (@columns) { - my $search = $column->{search}->{value}; + my $search = $column->{search}->{value}; my $column_name = $column->{name}; - if (defined $search and $search ne '') { + if ( defined $search and $search ne '' ) { my @words = split /\s+/, $search; foreach my $word (@words) { push @f, $column_name; push @c, 'and'; - if ( grep { $_ eq $column_name } qw( ccode homebranch holdingbranch location itype notforloan itemlost onloan ) ) { - push @q, "$word"; + if ( grep { $_ eq $column_name } + qw( ccode homebranch holdingbranch location itype notforloan itemlost onloan ) ) + { + push @q, "$word"; push @op, '='; } else { - push @q, "%$word%"; + push @q, "%$word%"; push @op, 'like'; } } } } - $cgi->param('f', @f); - $cgi->param('q', @q); - $cgi->param('op', @op); - $cgi->param('c', @c); -} elsif (defined $format and $format eq 'csv') { + $cgi->param( 'f', @f ); + $cgi->param( 'q', @q ); + $cgi->param( 'op', @op ); + $cgi->param( 'c', @c ); +} elsif ( defined $format and $format eq 'csv' ) { $template_name = 'catalogue/itemsearch_csv.tt'; # Retrieve all results - $cgi->param('rows', 0); -} elsif (defined $format and $format eq 'barcodes') { + $cgi->param( 'rows', 0 ); +} elsif ( defined $format and $format eq 'barcodes' ) { + # Retrieve all results - $cgi->param('rows', 0); -} elsif (defined $format and $format eq 'shareable') { + $cgi->param( 'rows', 0 ); +} elsif ( defined $format and $format eq 'shareable' ) { + # get the item search parameters from the url and fill form -} elsif (defined $format) { +} elsif ( defined $format ) { die "Unsupported format $format"; } -- 2.39.5