From 02f5cf0fca126946b30b267986ea8afe1fb1f5cd Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sat, 25 Apr 2009 11:58:23 +0000 Subject: [PATCH] inputs show description if defined and inputs with same name with show up as single checkbox allowing grouping of input files into one item on interface git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@1157 07558da8-63fa-0310-ba24-9fe276d99e06 --- vhost/webpac2.cgi | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/vhost/webpac2.cgi b/vhost/webpac2.cgi index 340e0db..9d086a0 100755 --- a/vhost/webpac2.cgi +++ b/vhost/webpac2.cgi @@ -116,6 +116,18 @@ foreach ( split(/[\n\r]+/, $select_attr_operators ) ) { warn "## attr_operator = ", dump( $attr_operator ); +my $only_input; + +foreach ( @{ $db->{input} } ) { + my $input = $_->{name} || die "no name in ",dump( $_ ); + if ( ! $only_input->{'-labels'}->{$input} ) { + push @{ $only_input->{'-values'} }, $input; + $only_input->{'-labels'}->{$input} = $_->{description} || $input; + } +} + +warn "## only_input = ", dump( $only_input ); + print start_html( -title => $db->{name}, @@ -139,7 +151,7 @@ print h2( 'Select input' ), checkbox_group( -name => 'only_input', - -values => [ map { $_->{name} } @{ $db->{input} } ], + %$only_input, -linebreak=> 'true', ), qq||, @@ -165,8 +177,7 @@ if ( my $search = param('search') ) { dump_yaml( 'pager', $pager ); - my @search = (); - + my @search = (); if ( $search =~ m{(=|"|AND|OR)} ) { push @search, $search; } elsif ( my $op = param('attr_operator') ) { @@ -189,15 +200,14 @@ if ( my $search = param('search') ) { $v =~ s{(\s*)(\S+)}{rewrite($1,$2)}ge; push @search, $v; + + my @only_input = param('only_input'); + push @search, '(' . join(') OR (', map { "input=$_" } @only_input) . ')' if @only_input; } else { push @search, "xml=$search"; } - my @only_input = param('only_input'); - - push @search, '(' . join(') or (', @only_input) . ')' if @only_input; - - my $q = '(' . join(') and (', @search) . ')'; + my $q = '(' . join(') AND (', @search) . ')'; $q =~ s{\(\((.+)\)\)}{($1)}; warn "# query: $q\n"; my $swish_results = $swish->query( $q ); -- 2.20.1