mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 06:03:28 +00:00
Total ui-lib conversion
This commit is contained in:
@@ -1,2 +1,4 @@
|
||||
---- Changes since 1.270 ----
|
||||
Added a button for deleting multiple recipes at once.
|
||||
---- Changes since 1.390 ----
|
||||
Converted all code to use the new Webmin UI library, for a more consistent look.
|
||||
|
||||
@@ -13,41 +13,29 @@ else {
|
||||
$env = $conf[$in{'idx'}];
|
||||
}
|
||||
|
||||
print "<form action=save_env.cgi>\n";
|
||||
print "<input type=hidden name=new value='$in{'new'}'>\n";
|
||||
print "<input type=hidden name=idx value='$in{'idx'}'>\n";
|
||||
print &ui_form_start("save_env.cgi");
|
||||
print &ui_hidden("new", $in{'new'});
|
||||
print &ui_hidden("idx", $in{'idx'});
|
||||
print &ui_table_start($text{'env_header'}, "width=100%", 2);
|
||||
|
||||
print "<table border width=100%>\n";
|
||||
print "<tr $tb> <td><b>$text{'env_header'}</b></td> </tr>\n";
|
||||
print "<tr $cb> <td><table width=100%>\n";
|
||||
# Variable name
|
||||
print &ui_table_row($text{'env_name'},
|
||||
&ui_textbox("name", $env->{'name'}, 60));
|
||||
|
||||
print "<tr> <td><b>$text{'env_name'}</b></td>\n";
|
||||
printf "<td><input name=name size=60 value='%s'></td> </tr>\n",
|
||||
&html_escape($env->{'name'});
|
||||
|
||||
print "<tr> <td valign=top><b>$text{'env_value'}</b></td>\n";
|
||||
if ($env->{'value'} =~ /\n/) {
|
||||
print "<td><textarea name=value rows=4 cols=60>",
|
||||
&html_escape($env->{'value'}),"</textarea></td> </tr>\n";
|
||||
}
|
||||
else {
|
||||
printf "<td><input name=value size=60 value='%s'></td> </tr>\n",
|
||||
&html_escape($env->{'value'});
|
||||
}
|
||||
|
||||
print "</table></td></tr></table>\n";
|
||||
# Value or values
|
||||
print &ui_table_row($text{'env_value'},
|
||||
$env->{'value'} =~ /\n/ ? &ui_textarea("value", $env->{'value'}, 4, 60)
|
||||
: &ui_textbox("value", $env->{'value'}, 60));
|
||||
|
||||
# Show save buttons
|
||||
print "<table width=100%><tr>\n";
|
||||
print &ui_table_end();
|
||||
if ($in{'new'}) {
|
||||
print "<td><input type=submit value='$text{'create'}'></td>\n";
|
||||
print &ui_form_end([ [ undef, $text{'create'} ] ]);
|
||||
}
|
||||
else {
|
||||
print "<td><input type=submit value='$text{'save'}'></td>\n";
|
||||
print "<td align=right><input type=submit name=delete ",
|
||||
"value='$text{'delete'}'></td>\n";
|
||||
print &ui_form_end([ [ undef, $text{'save'} ],
|
||||
[ 'delete', $text{'delete'} ] ]);
|
||||
}
|
||||
print "</tr></table></form>\n";
|
||||
|
||||
&ui_print_footer("", $text{'index_return'});
|
||||
|
||||
|
||||
@@ -13,31 +13,25 @@ else {
|
||||
$inc = $conf[$in{'idx'}];
|
||||
}
|
||||
|
||||
print "<form action=save_inc.cgi>\n";
|
||||
print "<input type=hidden name=new value='$in{'new'}'>\n";
|
||||
print "<input type=hidden name=idx value='$in{'idx'}'>\n";
|
||||
print &ui_form_start("save_inc.cgi");
|
||||
print &ui_hidden("new", $in{'new'});
|
||||
print &ui_hidden("idx", $in{'idx'});
|
||||
print &ui_table_start($text{'inc_header'}, "width=100%", 2);
|
||||
|
||||
print "<table border width=100%>\n";
|
||||
print "<tr $tb> <td><b>$text{'inc_header'}</b></td> </tr>\n";
|
||||
print "<tr $cb> <td><table width=100%>\n";
|
||||
|
||||
print "<tr> <td><b>$text{'inc_inc'}</b></td>\n";
|
||||
printf "<td><input name=inc size=60 value='%s'> %s</td> </tr>\n",
|
||||
&html_escape($inc->{'include'}), &file_chooser_button("inc");
|
||||
|
||||
print "</table></td></tr></table>\n";
|
||||
# Included file
|
||||
print &ui_table_row($text{'inc_inc'},
|
||||
&ui_textbox("inc", $inc->{'include'}, 60)." ".
|
||||
&file_chooser_button("inc"));
|
||||
|
||||
# Show save buttons
|
||||
print "<table width=100%><tr>\n";
|
||||
print &ui_table_end();
|
||||
if ($in{'new'}) {
|
||||
print "<td><input type=submit value='$text{'create'}'></td>\n";
|
||||
print &ui_form_end([ [ undef, $text{'create'} ] ]);
|
||||
}
|
||||
else {
|
||||
print "<td><input type=submit value='$text{'save'}'></td>\n";
|
||||
print "<td align=right><input type=submit name=delete ",
|
||||
"value='$text{'delete'}'></td>\n";
|
||||
print &ui_form_end([ [ undef, $text{'save'} ],
|
||||
[ 'delete', $text{'delete'} ] ]);
|
||||
}
|
||||
print "</tr></table></form>\n";
|
||||
|
||||
&ui_print_footer("", $text{'index_return'});
|
||||
|
||||
|
||||
@@ -15,111 +15,84 @@ else {
|
||||
$block++ if (defined($rec->{'block'}));
|
||||
}
|
||||
|
||||
print "<form action=save_recipe.cgi>\n";
|
||||
print "<input type=hidden name=new value='$in{'new'}'>\n";
|
||||
print "<input type=hidden name=idx value='$in{'idx'}'>\n";
|
||||
print "<input type=hidden name=before value='$in{'before'}'>\n";
|
||||
print "<input type=hidden name=after value='$in{'after'}'>\n";
|
||||
print "<input type=hidden name=block value='$block'>\n";
|
||||
|
||||
# Show action section
|
||||
print "<table border width=100%>\n";
|
||||
print "<tr $tb> <td><b>$text{'edit_header1'}</b></td> </tr>\n";
|
||||
print "<tr $cb> <td><table width=100%>\n";
|
||||
print &ui_form_start("save_recipe.cgi");
|
||||
print &ui_hidden("new", $in{'new'});
|
||||
print &ui_hidden("idx", $in{'idx'});
|
||||
print &ui_hidden("before", $in{'before'});
|
||||
print &ui_hidden("after", $in{'after'});
|
||||
print &ui_hidden("block", $block);
|
||||
print &ui_table_start($text{'edit_header1'}, "width=100%", 2);
|
||||
|
||||
if ($block) {
|
||||
# Start of a conditional block
|
||||
local @lines = split(/\n/, $rec->{'block'});
|
||||
local $r = @lines > 5 ? 10 : 5;
|
||||
print "<tr> <td valign=top><b>$text{'edit_block'}</b></td>\n";
|
||||
print "<td colspan=3><textarea name=bdata rows=$r cols=80>",
|
||||
$rec->{'block'},"</textarea></td> </tr>\n";
|
||||
print &ui_table_row($text{'edit_block'},
|
||||
&ui_textarea("bdata", $rec->{'block'}, $r, 80));
|
||||
}
|
||||
else {
|
||||
# Simple action
|
||||
($t, $a) = &parse_action($rec);
|
||||
print "<tr> <td><b>$text{'edit_action'}</b></td>\n";
|
||||
print "<td colspan=3><select name=amode>\n";
|
||||
foreach $i (0, 2, 1, 3, 4, 6) {
|
||||
printf "<option value=%d %s>%s\n",
|
||||
$i, $t == $i ? "selected" : "", $text{"edit_amode_$i"};
|
||||
}
|
||||
print "</select>\n";
|
||||
printf "<input name=action size=40 value='%s'></td> </tr>\n",
|
||||
&html_escape($t == 6 ? $rec->{'action'} : $a);
|
||||
print &ui_table_row($text{'edit_action'},
|
||||
&ui_select("amode", $t,
|
||||
[ map { [ $_, $text{"edit_amode_".$_} ] }
|
||||
(0, 2, 1, 3, 4, 6) ])." ".
|
||||
&ui_textbox("action", $t == 6 ? $rec->{'action'} : $a, 40));
|
||||
}
|
||||
|
||||
print "<tr> <td colspan=4><table>\n";
|
||||
$i = 0;
|
||||
# Action options
|
||||
@grid = ( );
|
||||
foreach $f (@known_flags) {
|
||||
print "<tr>\n" if ($i%2 == 0);
|
||||
print "<td width=50% nowrap>\n";
|
||||
printf "<input type=checkbox name=flag value=%s %s> %s\n",
|
||||
$f, &indexof($f, @{$rec->{'flags'}}) >= 0 ? "checked" : "",
|
||||
$text{"edit_flag_$f"};
|
||||
print "</td>\n";
|
||||
print "</tr>\n" if ($i%2 == 1);
|
||||
$i++;
|
||||
push(@grid, &ui_checkbox("flag", $f, $text{"edit_flag_$f"},
|
||||
&indexof($f, @{$rec->{'flags'}}) >= 0));
|
||||
}
|
||||
print "</table></td> </tr>\n";
|
||||
print &ui_table_row(undef, &ui_grid_table(\@grid, 2, 100), 2);
|
||||
|
||||
# Lock file
|
||||
$ldef = $rec->{'lockfile'} ? 0 :
|
||||
defined($rec->{'lockfile'}) ? 2 : 1;
|
||||
print "<tr> <td><b>$text{'edit_lockfile'}</b></td> <td colspan=3>\n";
|
||||
printf "<input type=radio name=lockfile_def value=1 %s> %s\n",
|
||||
$ldef == 1 ? "checked" : "", $text{'edit_none'};
|
||||
printf "<input type=radio name=lockfile_def value=2 %s> %s\n",
|
||||
$ldef == 2 ? "checked" : "", $text{'default'};
|
||||
printf "<input type=radio name=lockfile_def value=0 %s> %s\n",
|
||||
$ldef == 0 ? "checked" : "", $text{'edit_lock'};
|
||||
printf "<input name=lockfile size=40 value='%s'></td> </tr>\n",
|
||||
&html_escape($rec->{'lockfile'});
|
||||
print &ui_table_row($text{'edit_lockfile'},
|
||||
&ui_radio("lockfile_def", $ldef,
|
||||
[ [ 1, $text{'edit_none'} ],
|
||||
[ 2, $text{'default'} ],
|
||||
[ 0, $text{'edit_lock'}." ".
|
||||
&ui_textbox("lockfile", $rec->{'lockfile'}, 40) ] ]));
|
||||
|
||||
print "</table></td></tr></table><br>\n";
|
||||
print &ui_table_end();
|
||||
|
||||
# Show conditions section
|
||||
print "<table border width=100%>\n";
|
||||
print "<tr $tb> <td><b>$text{'edit_header2'}</b></td> </tr>\n";
|
||||
print "<tr $cb> <td>\n";
|
||||
|
||||
print "$text{'edit_conddesc'}<p>\n";
|
||||
print &ui_table_start($text{'edit_header2'}, "width=100%", 2);
|
||||
print &ui_table_row(undef, $text{'edit_conddesc'}, 2);
|
||||
|
||||
$ctable = &ui_columns_start([ $text{'edit_ctype'}, $text{'edit_cvalue'} ], 100);
|
||||
$i = 0;
|
||||
foreach $c (@{$rec->{'conds'}}, [ '-' ], [ '-' ] ) {
|
||||
print "<select name=cmode_$i>\n";
|
||||
printf "<option value='-' %s> \n",
|
||||
$c->[0] eq '-' ? "selected" : "";
|
||||
printf "<option value='' %s> %s\n",
|
||||
$c->[0] eq '' ? "selected" : "", $text{'edit_cmode_re'};
|
||||
printf "<option value='!' %s> %s\n",
|
||||
$c->[0] eq '!' ? "selected" : "", $text{'edit_cmode_nre'};
|
||||
printf "<option value='\$' %s> %s\n",
|
||||
$c->[0] eq '$' ? "selected" : "", $text{'edit_cmode_shell'};
|
||||
printf "<option value='?' %s> %s\n",
|
||||
$c->[0] eq '?' ? "selected" : "", $text{'edit_cmode_exit'};
|
||||
printf "<option value='<' %s> %s\n",
|
||||
$c->[0] eq '<' ? "selected" : "", $text{'edit_cmode_lt'};
|
||||
printf "<option value='>' %s> %s\n",
|
||||
$c->[0] eq '>' ? "selected" : "", $text{'edit_cmode_gt'};
|
||||
print "</select>\n";
|
||||
printf "<input name=cond_$i size=60 value='%s'><br>\n",
|
||||
&html_escape($c->[1]);
|
||||
$ctable .= &ui_columns_row([
|
||||
&ui_select("cmode_$i", $c->[0],
|
||||
[ [ '-', ' ' ],
|
||||
[ '', $text{'edit_cmode_re'} ],
|
||||
[ '!', $text{'edit_cmode_nre'} ],
|
||||
[ '$', $text{'edit_cmode_shell'} ],
|
||||
[ '?', $text{'edit_cmode_exit'} ],
|
||||
[ '<', $text{'edit_cmode_lt'} ],
|
||||
[ '>', $text{'edit_cmode_gt'} ] ]),
|
||||
&ui_textbox("cond_$i", $c->[1], 60, 0, undef,
|
||||
"style='width:100%'"),
|
||||
]);
|
||||
$i++;
|
||||
}
|
||||
|
||||
print "</td></tr></table>\n";
|
||||
$ctable .= &ui_columns_end();
|
||||
print &ui_table_row(undef, $ctable, 2);
|
||||
print &ui_table_end();
|
||||
|
||||
# Show save buttons
|
||||
print "<table width=100%><tr>\n";
|
||||
if ($in{'new'}) {
|
||||
print "<td><input type=submit value='$text{'create'}'></td>\n";
|
||||
print &ui_form_end([ [ undef, $text{'create'} ] ]);
|
||||
}
|
||||
else {
|
||||
print "<td><input type=submit value='$text{'save'}'></td>\n";
|
||||
print "<td align=right><input type=submit name=delete ",
|
||||
"value='$text{'delete'}'></td>\n";
|
||||
print &ui_form_end([ [ undef, $text{'save'} ],
|
||||
[ 'delete', $text{'delete'} ] ]);
|
||||
}
|
||||
print "</tr></table></form>\n";
|
||||
|
||||
&ui_print_footer("", $text{'index_return'});
|
||||
|
||||
|
||||
@@ -68,6 +68,8 @@ edit_cmode_gt=Mail is bigger than
|
||||
edit_conddesc=For the above action to be carried out, all the conditions below must match. If there are no conditions, the action will always be executed.
|
||||
edit_none=None
|
||||
edit_lock=Specific file
|
||||
edit_ctype=Condition type
|
||||
edit_cvalue=Regular expression or command
|
||||
|
||||
save_err=Failed to save action
|
||||
save_eaction_0=Missing file to append to
|
||||
|
||||
@@ -6,13 +6,12 @@ require './procmail-lib.pl';
|
||||
&ui_print_header(undef, $text{'manual_title'}, "");
|
||||
|
||||
print &text('manual_desc', "<tt>$procmailrc</tt>"),"<p>\n";
|
||||
print "<form action=manual_save.cgi method=post enctype=multipart/form-data>\n";
|
||||
print "<textarea name=data rows=20 cols=80>";
|
||||
open(FILE, $procmailrc);
|
||||
while(<FILE>) { print &html_escape($_); }
|
||||
close(FILE);
|
||||
print "</textarea><br>\n";
|
||||
print "<input type=submit value='$text{'save'}'>\n";
|
||||
print &ui_form_start("manual_save.cgi", "form-data");
|
||||
print &ui_table_start(undef, undef, 2);
|
||||
$data = &read_file_contents($procmailrc);
|
||||
print &ui_table_row(undef, &ui_textarea("data", $data, 20, 80), 2);
|
||||
print &ui_table_end();
|
||||
print &ui_form_end([ [ undef, $text{'save'} ] ]);
|
||||
|
||||
&ui_print_footer("", $text{'index_return'});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user