Permalink
Browse files

More new UI conversion

  • Loading branch information...
1 parent 5ca5b0b commit 579a3f5ec17d515747a9a95d4f188c624c0c6fcf @jcameron jcameron committed Apr 3, 2012
Showing with 88 additions and 134 deletions.
  1. +88 −134 samba/conf_smb.cgi
View
@@ -13,151 +13,105 @@ require './samba-lib.pl';
&get_share("global");
-print "<form action=save_smb.cgi>\n";
-print "<table border width=100%>\n";
-print "<tr $tb> <td><b>$text{'smb_title'}</b></td> </tr>\n";
-print "<tr $cb> <td><table width=100%>\n";
-$gap = "&nbsp;" x 3;
-
-print "<tr> <td><b>$text{'smb_workgroup'}</b></td>\n";
-print "<td colspan=3>\n";
-printf "<input type=radio name=workgroup_def value=1 %s> $text{'default'}\n",
- &getval("workgroup") eq "" ? "checked" : "";
-printf "$gap <input type=radio name=workgroup_def value=0 %s>\n",
- &getval("workgroup") eq "" ? "" : "checked";
-printf "<input name=workgroup size=15 value=\"%s\"></td> </tr>\n",
- &getval("workgroup");
-
-print "<tr> <td><b>$text{'smb_wins'}</b></td>\n";
-print "<td colspan=3>\n";
-printf "<input type=radio name=wins value=0 %s> $text{'smb_winsserver'}\n",
- &isfalse("wins support") ? "" : "checked";
-printf "$gap <input type=radio name=wins value=1 %s> $text{'smb_useserver'}\n",
- &getval("wins server") eq "" ? "" : "checked";
-printf "<input name=wins_server size=10 value=\"%s\">\n",
- &getval("wins server");
-printf "$gap <input type=radio name=wins value=2 %s> $text{'config_neither'}\n",
- &isfalse("wins support") && &getval("wins server") eq "" ? "checked" : "";
-print "</td> </tr>\n";
+print &ui_form_start("save_smb.cgi", "post");
+print &ui_table_start($text{'smb_title'}, undef, 2);
+
+print &ui_table_row($text{'smb_workgroup'},
+ &ui_opt_textbox("workgroup", &getval("workgroup"), 20,
+ $text{'default'}));
+
+$wmode = &isfalse("wins support") && &getval("wins server") eq "" ? 2 :
+ &getval("wins server") ne "" ? 1 : 0;
+print &ui_table_row($text{'smb_wins'},
+ &ui_radio("wins", $wmode,
+ [ [ 0, $text{'smb_winsserver'} ],
+ [ 1, $text{'smb_useserver'}." ".
+ &ui_textbox("wins_server", &getval("wins server"),20) ],
+ [ 2, $text{'config_neither'} ] ]));
$desc = &getval("server string");
-print "<tr> <td><b>$text{'smb_description'}</b></td>\n";
-print "<td colspan=3>\n";
-print &ui_radio("server_string_def", !defined($desc) ? 1 :
+print &ui_table_row($text{'smb_description'},
+ &ui_radio("server_string_def", !defined($desc) ? 1 :
$desc eq "" ? 2 : 0,
[ [ 1, $text{'default'} ],
[ 2, $text{'smb_descriptionnone'} ],
- [ 0, &ui_textbox("server_string", $desc, 40) ] ]);
-print "</td> </tr>\n";
-
-print "<tr> <td><b>$text{'smb_name'}</b></td>\n";
-printf "<td><input name=netbios_name size=15 value=\"%s\"></td>\n",
- &getval("netbios name");
-
-print "<td><b>$text{'smb_aliase'}</b></td>\n";
-printf "<td><input name=netbios_aliases size=30 value=\"%s\"></td> </tr>\n",
- &getval("netbios aliases");
-
-print "<tr> <td><b>$text{'smb_default'}</b></td>\n";
-print "<td><select name=default>\n";
-printf "<option value=\"\" %s> $text{'config_none'}\n", &getval("default") eq "";
-foreach $s (&list_shares()) {
- next unless &can('r', \%access, $s) || !$access{'hide'};
- printf "<option value=\"$s\" %s> $s\n",
- &getval("default") eq $s ? "selected" : "";
- }
-print "</select></td>\n";
-
-print "<td><b>$text{'smb_show'}</b></td>\n";
-print "<td rowspan=2><select name=auto_services multiple size=3>\n";
-foreach $s (split(/s\+/, &getval("auto services"))) { $autos{$s}++; }
-foreach $s (&list_shares()) {
- next unless &can('r', \%access, $s) || !$access{'hide'};
- printf "<option value=\"$s\" %s> $s\n",
- $autos{$s} ? "checked" : "";
- }
-print "</select></td> </tr>\n";
-
-print "<tr> <td><b>$text{'smb_disksize'}</b></td>\n";
-print "<td colspan=2>\n";
-printf "<input type=radio name=max_disk_size_def value=1 %s> $text{'smb_unlimited'}\n",
- &getval("max disk size") eq "" ? "checked" : "";
-printf "$gap <input type=radio name=max_disk_size_def value=0 %s>\n",
- &getval("max disk size") eq "" ? "" : "checked";
-printf "<input name=max_disk_size size=5 value=\"%s\"> kB</td>\n",
- &getval("max disk size");
-
-print "<tr> <td><b>$text{'smb_winpopup'}</b></td>\n";
-printf "<td><input name=message_command size=15 value=\"%s\"></td>\n",
- &getval("message command");
-
-print "<td><b>$text{'smb_priority'}</b></td>\n";
-printf "<td><input name=os_level size=5 value=\"%d\"></td> </tr>\n",
- &getval("os level");
-
-print "<tr> <td><b>$text{'smb_protocol'}</b></td>\n";
-print "<td><select name=protocol>\n";
-printf "<option value=\"\" %s> $text{'default'}\n",
- &getval("protocol") eq "" ? "selected" : "";
-foreach $p (@protocols) {
- printf "<option value=\"$p\" %s> $p\n",
- &getval("protocol") eq $p ? "selected" : "";
- }
-print "</select></td>\n";
-
-print "<td><b>$text{'smb_master'}</b></td>\n";
-print "<td>";
-printf "<input type=radio name=preferred_master value=yes %s> $text{'yes'}\n",
- &istrue("preferred master") ? "checked" : "";
-printf "$gap <input type=radio name=preferred_master value=no %s> $text{'no'}\n",
- &isfalse("preferred master") ? "checked" : "";
-printf "<input type=radio name=preferred_master value=auto %s> $text{'smb_master_auto'}\n",
- &getval("preferred master") =~ /auto/ ||
- !&getval("preferred master") ? "checked" : "";
-print "</td> </tr>\n";
-
-print "<tr> <td><b>$text{'smb_security'}</b></td>\n";
-print "<td><select name=security>\n";
-printf "<option value='' %s> $text{'default'}\n",
- &getval("security") ? "" : "selected";
-printf "<option value=share %s> $text{'smb_sharelevel'}\n",
- &getval("security") =~ /^share$/i ? "selected" : "";
-printf "<option value=user %s> $text{'smb_userlevel'}\n",
- &getval("security") =~ /^user$/i ? "selected" : "";
-printf "<option value=server %s> $text{'smb_passwdserver'}\n",
- &getval("security") =~ /^server$/i ? "selected" : "";
-printf "<option value=domain %s> $text{'smb_domain'}\n",
- &getval("security") =~ /^domain$/i ? "selected" : "";
-printf "<option value=ads %s> $text{'smb_ads'}\n",
- &getval("security") =~ /^ads$/i ? "selected" : "";
-print "</select></td>\n";
-
-print "<td><b>$text{'smb_passwdserver'}</b></td>\n";
-printf "<td><input name=password_server size=10 value=\"%s\"></td> </tr>\n",
- &getval("password server");
-
-print "<tr> <td valign=top><b>$text{'smb_announce'}</b></td>\n";
-print "<td colspan=3>\n";
-printf "<input type=radio name=remote_def value=1 %s> $text{'smb_nowhere'}\n",
- &getval("remote announce") ? "" : "checked";
-printf "$gap <input type=radio name=remote_def value=0 %s> $text{'smb_fromlist'}<br>\n",
- &getval("remote announce") ? "checked" : "";
-print "<table border> <tr> <td><b>$text{'smb_ip'}</b></td> ",
- "<td>$text{'smb_asworkgroup'}</td> </tr>\n";
-@rem = split(/\s+/, &getval("remote announce")); $len = @rem ? @rem+1 : 2;
+ [ 0, &ui_textbox("server_string", $desc, 40) ] ]));
+
+print &ui_table_row($text{'smb_name'},
+ &ui_textbox("netbios_name", &getval("netbios name"), 20));
+
+print &ui_table_row($text{'smb_aliase'},
+ &ui_textbox("netbios_aliases", &getval("netbios aliases"), 30));
+
+print &ui_table_row($text{'smb_default'},
+ &ui_select("default", &getval("default"),
+ [ [ "", $text{'config_none'} ],
+ (grep { &can('r', \%access, $_) }
+ &list_shares()) ]));
+
+print &ui_table_row($text{'smb_show'},
+ &ui_select("auto_services", [ split(/s\+/, &getval("auto services")) ],
+ [ grep { &can('r', \%access, $_) }
+ &list_shares() ],
+ 1, 5));
+
+print &ui_table_row($text{'smb_disksize'},
+ &ui_opt_textbox("max_disk_size", &getval("max disk size"), 6,
+ $text{'smb_unlimited'})." kB");
+
+print &ui_table_row($text{'smb_winpopup'},
+ &ui_textbox("message_command", &getval("message command"), 40));
+
+print &ui_table_row($text{'smb_priority'},
+ &ui_textbox("os_level", &getval("os level"), 6));
+
+print &ui_table_row($text{'smb_protocol'},
+ &ui_select("protocol", &getval("protocol"),
+ [ [ "", $text{'default'} ],
+ @protocols ]));
+
+print &ui_table_row($text{'smb_master'},
+ &ui_radio("preferred_master",
+ &istrue("preferred master") ? "yes" :
+ &isfalse("preferred master") ? "no" :
+ &getval("preferred master") =~ /auto/ ||
+ !&getval("preferred master") ? "auto" : "",
+ [ [ "yes", $text{'yes'} ],
+ [ "no", $text{'no'} ],
+ [ "auto", $text{'smb_master_auto'} ] ]));
+
+print &ui_table_row($text{'smb_security'},
+ &ui_select("security", $security,
+ [ [ "", $text{'default'} ],
+ map { [ $_, $text{'smb_'.$_.'level'} ||
+ $text{'smb_'.$_} ] }
+ ( "share", "user", "passwd", "domain", "ads" ) ],
+ 1, 0, 1));
+
+print &ui_table_row($text{'smb_passwdserver'},
+ &ui_textbox("password_server", &getval("password server"), 20));
+
+$ra = &getval("remote announce");
+$atable = &ui_radio("remote_def", $ra ? 0 : 1,
+ [ [ 1, $text{'smb_nowhere'} ],
+ [ 0, $text{'smb_fromlist'} ] ])."<br>\n";
+$atable .= &ui_columns_start([ $text{'smb_ip'}, $text{'smb_asworkgroup'} ]);
+@rem = split(/\s+/, $ra);
+$len = @rem ? @rem+1 : 2;
for($i=0; $i<$len; $i++) {
- print "<tr>\n";
if ($rem[$i] =~ /^([\d\.]+)\/(.+)$/) { $ip = $1; $wg = $2; }
elsif ($rem[$i] =~ /^([\d\.]+)$/) { $ip = $1; $wg = ""; }
else { $ip = $wg = ""; }
- print "<td><input name=remote_ip$i size=15 value=\"$ip\"></td>\n";
- print "<td><input name=remote_wg$i size=15 value=\"$wg\"></td>\n";
- print "</tr>\n";
+ $atable .= &ui_columns_row([
+ &ui_textbox("remote_ip$i", $ip, 15),
+ &ui_textbox("remote_wg$i", $wg, 20),
+ ]);
}
-print "</table></td> </tr>\n";
+$atable .= &ui_columns_end();
+print &ui_table_row($text{'smb_announce'}, $atable);
-print "</table></td></tr></table><p>\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_sharelist'});

0 comments on commit 579a3f5

Please sign in to comment.