3 # Displays a form for editing or creating some M4 file entry, which may be a
4 # feature, define, mailer or other line.
6 require './sendmail-lib.pl';
7 require './features-lib.pl';
9 $features_access || &error($text{'features_ecannot'});
12 # Display manual edit form
13 &ui_print_header(undef, $text{'feature_manual'}, "");
15 print "<form action=manual_features.cgi method=post ",
16 "enctype=multipart/form-data>\n";
17 print &text('feature_mdesc', "<tt>$config{'sendmail_mc'}</tt>"),
19 print "<textarea name=data rows=20 cols=80>";
20 open(FEAT, $config{'sendmail_mc'});
22 print &html_escape($_);
25 print "</textarea><br>\n";
26 print "<input type=submit value='$text{'save'}'></form>\n";
28 &ui_print_footer("list_features.cgi", $text{'features_return'});
32 &ui_print_header(undef, $text{'feature_add'}, "");
33 $feature = { 'type' => $in{'type'} };
36 &ui_print_header(undef, $text{'feature_edit'}, "");
37 @features = &list_features();
38 $feature = $features[$in{'idx'}];
41 print "<form action=save_feature.cgi>\n";
42 print "<input type=hidden name=new value='$in{'new'}'>\n";
43 print "<input type=hidden name=idx value='$in{'idx'}'>\n";
44 print "<input type=hidden name=type value='$feature->{'type'}'>\n";
46 print "<table border width=100%>\n";
47 print "<tr $tb> <td><b>$text{'feature_header'}</b></td> </tr>\n";
48 print "<tr $cb> <td><table>\n";
50 if (!$in{'new'} && $feature->{'type'}) {
51 print "<tr> <td><b>$text{'feature_old'}</b></td>\n";
52 print "<td><tt>$feature->{'text'}</tt></td> </tr>\n";
55 if ($feature->{'type'} == 0) {
56 # Unsupported text line
57 print "<tr> <td><b>$text{'feature_text'}</b></td>\n";
58 printf "<td><input name=text size=50 value='%s'></td> </tr>\n",
59 &html_escape($feature->{'text'});
61 elsif ($feature->{'type'} == 1) {
62 # A FEATURE() definition
63 print "<tr> <td><b>$text{'feature_feat'}</b></td>\n";
64 print "<td><select name=name>\n";
65 foreach $f (&list_feature_types()) {
66 printf "<option value=%s %s>%s\n",
67 $f->[0], $feature->{'name'} eq $f->[0] ? 'selected' : '',
70 print "</select></td> </tr>\n";
72 print "<tr> <td valign=top><b>$text{'feature_values'}</b></td> <td>\n";
73 local @v = @{$feature->{'values'}};
75 for($i=0; $i<=@v; $i++) {
76 print "<input name=value_$i size=50 value='$v[$i]'><br>\n";
78 print "</td> </tr>\n";
80 elsif ($feature->{'type'} == 2 || $feature->{'type'} == 3) {
81 # A define() or undefine()
82 print "<tr> <td><b>$text{'feature_def'}</b></td>\n";
83 print "<td><select name=name>\n";
84 foreach $d (&list_define_types()) {
85 printf "<option value=%s %s>%s\n",
86 $d->[0], $d->[0] eq $feature->{'name'} ? "selected" : "",
88 $found++ if ($d->[0] eq $feature->{'name'});
90 print "<option value=$feature->{'name'} selected>$feature->{'name'}\n"
91 if (!$found && !$in{'new'});
94 print "<tr> <td valign=top><b>$text{'feature_defval'}</b></td>\n";
95 print "<td valign=top>\n";
96 printf "<input type=radio name=undef value=0 %s> %s\n",
97 $feature->{'type'} == 2 ? "checked" : "", $text{'feature_defmode1'};
98 printf "<input name=value size=50 value='%s'><br>\n",
100 printf "<input type=radio name=undef value=1 %s> %s\n",
101 $feature->{'type'} == 3 ? "checked" : "", $text{'feature_defmode0'};
102 print "</td> </tr>\n";
104 elsif ($feature->{'type'} == 4) {
105 # A MAILER() definition
106 print "<tr> <td><b>$text{'feature_mailer'}</b></td>\n";
107 print "<td><select name=mailer>\n";
108 foreach $m (&list_mailer_types()) {
109 printf "<option value=%s %s>%s\n",
110 $m->[0], $feature->{'mailer'} eq $m->[0] ? 'selected' : '',
113 print "</select></td> </tr>\n";
115 elsif ($feature->{'type'} == 5) {
116 # An OSTYPE() definition
117 print "<tr> <td><b>$text{'feature_ostype'}</b></td>\n";
118 print "<td><select name=ostype>\n";
119 foreach $m (&list_ostype_types()) {
120 printf "<option value=%s %s>%s\n",
121 $m->[0], $feature->{'ostype'} eq $m->[0] ? 'selected' : '',
124 print "</select></td> </tr>\n";
127 print "</table></td></tr></table>\n";
128 print "<table width=100%><tr>\n";
130 print "<td><input type=submit value='$text{'create'}'></td>\n";
133 print "<td><input type=submit value='$text{'save'}'></td>\n";
134 print "<td align=right><input type=submit name=delete ",
135 "value='$text{'delete'}'></td>\n";
137 print "</tr></table></form>\n";
139 &ui_print_footer("list_features.cgi", $text{'features_return'});