mirror of
https://github.com/webmin/webmin.git
synced 2026-09-21 13:00:38 +01:00
ui-lib conversion of forwarding page
This commit is contained in:
@@ -593,11 +593,12 @@ $dir = { 'name' => $_[0], 'type' => 1, 'members' => \@vals };
|
||||
}
|
||||
|
||||
# forwarders_input(text, name, &config)
|
||||
# Returns a form field containing a table of forwarding IPs and ports
|
||||
sub forwarders_input
|
||||
{
|
||||
local($v, $rv, $av, @ips, @prs);
|
||||
$v = &find($_[1], $_[2]);
|
||||
foreach $av (@{$v->{'members'}}) {
|
||||
my $v = &find($_[1], $_[2]);
|
||||
my (@ips, @prs);
|
||||
foreach my $av (@{$v->{'members'}}) {
|
||||
push(@ips, $av->{'name'});
|
||||
if ($av->{'values'}->[0] eq 'port') {
|
||||
push(@prs, $av->{'values'}->[1]);
|
||||
@@ -606,18 +607,16 @@ foreach $av (@{$v->{'members'}}) {
|
||||
push(@prs, undef);
|
||||
}
|
||||
}
|
||||
$rv = "<td valign=top><b>$_[0]</b></td> <td valign=top>\n";
|
||||
$rv .= "<table border>\n";
|
||||
$rv .= "<tr $tb> <td><b>$text{'forwarding_ip'}</b></td> ".
|
||||
"<td><b>$text{'forwarding_port'}</b></td> </tr>\n";
|
||||
for($i=0; $i<@ips+3; $i++) {
|
||||
$rv .= "<tr $cb>\n";
|
||||
$rv .= "<td><input name=$_[1]_ip_$i size=20 value='$ips[$i]'></td>\n";
|
||||
$rv .= "<td><input name=$_[1]_pr_$i size=15 value='$prs[$i]'></td>\n";
|
||||
$rv .= "</tr>\n";
|
||||
my @table;
|
||||
for(my $i=0; $i<@ips+3; $i++) {
|
||||
push(@table, [ &ui_textbox("$_[1]_ip_$i", $ips[$i], 20),
|
||||
&ui_opt_textbox("$_[1]_pr_$i", $prs[$i], 5,
|
||||
$text{'default'}),
|
||||
]);
|
||||
}
|
||||
$rv .= "</table>\n";
|
||||
return $rv;
|
||||
return &ui_table_row($_[0],
|
||||
&ui_columns_table([ $text{'forwarding_ip'}, $text{'forwarding_port'} ],
|
||||
undef, \@table, undef, 1), 3);
|
||||
}
|
||||
|
||||
# save_forwarders(name, &parent, indent)
|
||||
@@ -627,7 +626,7 @@ local ($i, $ip, $pr, @vals);
|
||||
for($i=0; defined($ip = $in{"$_[0]_ip_$i"}); $i++) {
|
||||
next if (!$ip);
|
||||
&check_ipaddress($ip) || &error(&text('eip', $ip));
|
||||
$pr = $in{"$_[0]_pr_$i"};
|
||||
$pr = $in{"$_[0]_pr_${i}_def"} ? undef : $in{"$_[0]_pr_$i"};
|
||||
!$pr || $pr =~ /^\d+$/ || &error(&text('eport', $pr));
|
||||
push(@vals, { 'name' => $ip,
|
||||
'values' => $pr ? [ "port", $pr ] : [ ] });
|
||||
|
||||
@@ -10,40 +10,29 @@ $conf = &get_config();
|
||||
$options = &find("options", $conf);
|
||||
$mems = $options->{'members'};
|
||||
|
||||
print "<form action=save_forwarding.cgi>\n";
|
||||
print "<table border>\n";
|
||||
print "<tr $tb> <td><b>$text{'forwarding_header'}</b></td> </tr>\n";
|
||||
print "<tr $cb> <td><table width=100%>\n";
|
||||
# Start of the form
|
||||
print &ui_form_start("save_forwarding.cgi");
|
||||
print &ui_table_start($text{'forwarding_header'}, "width=100%", 4);
|
||||
|
||||
print "<tr>\n";
|
||||
print &forwarders_input($text{'forwarding_fwders'}, 'forwarders', $mems);
|
||||
print "</tr>\n";
|
||||
|
||||
print "<tr>\n";
|
||||
print &choice_input($text{'forwarding_fwd'}, 'forward', $mems,
|
||||
$text{'yes'}, 'first', $text{'no'}, 'only',
|
||||
$text{'default'}, undef);
|
||||
print "</tr>\n";
|
||||
|
||||
print "<tr>\n";
|
||||
print &opt_input($text{'forwarding_max'}, "max-transfer-time-in",
|
||||
$mems, $text{'default'}, 4, $text{'forwarding_minutes'});
|
||||
print "</tr>\n";
|
||||
|
||||
print "<tr>\n";
|
||||
print &choice_input($text{'forwarding_format'}, 'transfer-format', $mems,
|
||||
$text{'forwarding_one'}, 'one-answer',
|
||||
$text{'forwarding_many'}, 'many-answers',
|
||||
$text{'default'}, undef);
|
||||
print "</tr>\n";
|
||||
|
||||
print "<tr>\n";
|
||||
print &opt_input($text{'forwarding_in'}, "transfers-in",
|
||||
$mems, $text{'default'}, 4);
|
||||
print "</tr>\n";
|
||||
|
||||
print "</table></td></tr></table>\n";
|
||||
print "<input type=submit value=\"$text{'save'}\"></form>\n";
|
||||
print &ui_table_end();
|
||||
print &ui_form_end([ [ undef, $text{'save'} ] ]);
|
||||
|
||||
&ui_print_footer("", $text{'index_return'});
|
||||
|
||||
|
||||
@@ -558,7 +558,7 @@ forwarding_emins=Missing or invalid maximum transfer time
|
||||
forwarding_etrans=Missing or invalid maximum concurrent transfers
|
||||
forwarding_minutes=minutes
|
||||
forwarding_ip=IP address
|
||||
forwarding_port=Port (optional)
|
||||
forwarding_port=Port
|
||||
|
||||
net_title=Addresses and Topology
|
||||
net_ecannot=You are not allowed to edit address and topology options
|
||||
|
||||
Reference in New Issue
Block a user