+sub read_config_txt {
+ my ( $file ) = @_;
+ my $input;
+ my $path ="$dir/$path/$path-$file.txt";
+ if ( ! -e $path ) {
+ warn "missing $path";
+ return;
+ }
+ foreach ( split(/[\n\r]+/, read_file( $path ) ) ) {
+ my ( $val,$label ) = split(/\s*\t\s*/,$_,2);
+ push @{ $input->{ '-values' } }, $val;
+ $input->{ '-labels' }->{$val} = $label;
+ }
+ return $input;
+}
+
+my $attr_labels = read_config_txt 'labels';
+my $attr_operators = read_config_txt 'operators';
+
+my @attr = @{ $attr_labels->{'-values'} };
+@attr = keys %{ $stats->{attr} } unless @attr;
+
+
+warn dump( $attr_labels, $attr_operators );
+
+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 );
+
+my @style = ( '../../style.css' );
+push @style, "../../$path/$path.css" if -e "$dir/$path/$path.css";
+dump_yaml( 'style', \@style );
+
+sub search_form {
+ qq|<a name="form"></a>|,
+ start_form( -action => self_url( query => 0 ) ),
+ checkbox_group(
+ -name => 'attr',
+ %$attr_labels,
+# -linebreak => 0,
+ ),
+ textfield( -name => 'search' ),
+ $attr_operators ? popup_menu( -name => 'attr_operator', %$attr_operators ) : '',
+ submit,
+ hidden( -name => 'entries_per_page', -default => $entries_per_page ),
+ # we need current_page fixed at 1 so that every submit through form will reset it
+ qq|<input type=hidden name=current_page value=1 >|,
+ checkbox( -name => 'debug', -default => 0 ), # FIXME hidden?
+ qq|<div id=inputs>|,
+ h2( 'Select input' ),
+ checkbox_group(
+ -name => 'only_input',
+ %$only_input,
+ -linebreak=> 'true',
+ ),
+ qq|</div>|,
+ end_form,
+ ;
+}
+