From 4fa1f307ce23ababd310222b45157b9f300e840d Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Wed, 30 Nov 2011 21:42:43 -0800 Subject: [PATCH] Add new parameter type which is actually a submit button --- custom/CHANGELOG | 2 ++ custom/config.info | 1 - custom/custom-lib.pl | 6 ++++++ custom/form.cgi | 6 ++++-- custom/index.cgi | 6 +++++- custom/lang/en | 1 + 6 files changed, 18 insertions(+), 4 deletions(-) diff --git a/custom/CHANGELOG b/custom/CHANGELOG index da61b997b..2a430190f 100644 --- a/custom/CHANGELOG +++ b/custom/CHANGELOG @@ -38,3 +38,5 @@ A command can now be configured to not display any output at all, and instead re ---- Changes since 1.560 ---- Added an option to the file editor to run a command before the file is displayed, thanks to a suggestion from Sart Cole. Added new date and left-right menu parameter types. +---- Changes since 1.570 ---- +Added a new parameter type which is a submit button. diff --git a/custom/config.info b/custom/config.info index cabdd0ab2..736e5932e 100644 --- a/custom/config.info +++ b/custom/config.info @@ -1,4 +1,3 @@ -line1=Configurable options,11 display_mode=Main page shows,1,0-All commands and parameters,1-Links to commands width=Width of file editor window,3,Default (80 chars) height=Height of file editor window,3,Default (20 chars) diff --git a/custom/custom-lib.pl b/custom/custom-lib.pl index da57682e8..e00ccc871 100755 --- a/custom/custom-lib.pl +++ b/custom/custom-lib.pl @@ -459,6 +459,9 @@ foreach my $a (@{$cmd->{'args'}}) { $setin->{$n."_month"}."-". $setin->{$n."_day"}; } + elsif ($a->{'type'} == 16) { + $rv = $setin->{$n} ? 1 : 0; + } if ($rv eq '' && $a->{'must'} && $a->{'type'} != 7) { &error(&text('run_emust', $a->{'desc'})); } @@ -620,6 +623,9 @@ elsif ($a->{'type'} == 15) { $n."_day", $n."_month", $n."_year")." ". &date_chooser_button($n."_day", $n."_month", $n."_year"); } +elsif ($a->{'type'} == 16) { + return &ui_submit($v || $a->{'name'}, $a->{'name'}); + } else { return "Unknown parameter type $a->{'type'}"; } diff --git a/custom/form.cgi b/custom/form.cgi index d9855507b..9b9000413 100755 --- a/custom/form.cgi +++ b/custom/form.cgi @@ -35,12 +35,14 @@ print &ui_table_row(undef, $cmd->{'html'}, 4) if ($cmd->{'html'}); foreach $a (@{$cmd->{'args'}}) { print &ui_table_row(&html_escape($a->{'desc'}), - &show_parameter_input($a, 0)); + &show_parameter_input($a, 0), 1, + [ "valign=top", "valign=top" ]); + $got_submit++ if ($a->{'type'} == 16); } $txt = $cmd->{'edit'} ? $text{'form_edit'} : $text{'form_exec'}; print &ui_table_end(); -print &ui_form_end([ [ undef, $txt ] ]); +print &ui_form_end($got_submit ? [ ] : [ [ undef, $txt ] ]); &ui_print_footer("", $text{'index_return'}); diff --git a/custom/index.cgi b/custom/index.cgi index de16ae53f..63d86870e 100755 --- a/custom/index.cgi +++ b/custom/index.cgi @@ -56,7 +56,11 @@ elsif ($config{'display_mode'} == 0) { $html .= &ui_table_start(undef, undef, $w, $config{'columns'} == 1 ? [ "width=20%", "width=30%" ] : [ "width=30%" ]); - $html .= &ui_table_row(undef, &ui_submit($c->{'desc'}), $w, []); + ($got_submit) = grep { $_->{'type'} == 16 } @a; + if (!$got_submit) { + $html .= &ui_table_row(undef, + &ui_submit($c->{'desc'}), $w, []); + } if ($c->{'html'}) { $html .= &ui_table_row(undef, &filter_javascript($c->{'html'}), $w, []); diff --git a/custom/lang/en b/custom/lang/en index a4aa21075..2cc517076 100644 --- a/custom/lang/en +++ b/custom/lang/en @@ -51,6 +51,7 @@ edit_type12=Multi menu.. edit_type13=Large multi menu.. edit_type14=Left-right menu.. edit_type15=Date +edit_type16=Submit button.. edit_noshow=Hide command when executing? edit_usermin=Available in Usermin? edit_timeout=Maximum time to wait for command?