2 # Directives in both mod_dir.pl and mod_autoindex.pl
4 @AddIcon_dirs = ("AddIcon", "AddIconByType", "AddIconByEncoding");
5 @AddIcon_descs = ("$text{'autoindex_fname'}", "$text{'autoindex_mime'}", "$text{'autoindex_enc'}");
7 sub edit_AddIcon_AddIconByType_AddIconByEncoding
9 local($rv, @all, $i, $j, $icon, $alt, $mode, $file);
10 $rv = "<table border>\n".
11 "<tr $tb> <td><b>$text{'autoindex_icon'}</b></td> <td><b>$text{'autoindex_alt'}</b></td>\n".
12 "<td><b>$text{'autoindex_match'}</b></td> <td><b>$text{'autoindex_fte'}</b></td></tr>\n";
13 @all = (@{$_[0]}, @{$_[1]}, @{$_[2]});
14 for($i=0; $i<=@all; $i++) {
17 if ($d->{'value'} =~ /^\((.*),(\S+)\)\s*(.*)$/) {
18 $alt = $1; $icon = $2; $file = $3;
20 elsif ($d->{'value'} =~ /^(\S+)\s*(.*)$/) {
21 $alt = ""; $icon = $1; $file = $2;
23 $mode = &indexof($d->{'name'}, @AddIcon_dirs);
25 else { $alt = $icon = $file = ""; $mode = 0; }
28 $rv .="<td><input name=AddIcon_icon_$i size=25 value=\"$icon\"></td>\n";
29 $rv .="<td><input name=AddIcon_alt_$i size=10 value=\"$alt\"></td>\n";
30 $rv .="<td><select name=AddIcon_mode_$i>\n";
31 for($j=0; $j<@AddIcon_descs; $j++) {
32 $rv .= sprintf "<option value=$j %s>%s\n",
33 $mode == $j ? "selected" : "", $AddIcon_descs[$j];
35 $rv .="</select></td>\n";
36 $rv .="<td><input name=AddIcon_file_$i size=20 value=\"$file\"></td>\n";
40 return (2, "$text{'autoindex_diricon'}", $rv);
42 sub save_AddIcon_AddIconByType_AddIconByEncoding
44 local($i, $icon, $alt, $file, $mode, $aref, @ai, @ait, @aie);
45 for($i=0; defined($in{"AddIcon_icon_$i"}); $i++) {
46 $icon = $in{"AddIcon_icon_$i"}; $alt = $in{"AddIcon_alt_$i"};
47 $mode = $in{"AddIcon_mode_$i"}; $file = $in{"AddIcon_file_$i"};
48 if ($icon !~ /\S/ && $file !~ /\S/) { next; }
49 $icon =~ /^\S+$/ || &error(&text('autoindex_eiconurl', $icon));
50 $file =~ /\S/ || &error(&text('autoindex_emiss', $AddIcon_descs[$mode], $icon));
51 $aref = $mode==0 ? \@ai : $mode==1 ? \@ait : \@aie;
52 if ($alt) { push(@$aref, "($alt,$icon) $file"); }
53 else { push(@$aref, "$icon $file"); }
55 return ( \@ai, \@ait, \@aie );
60 return (1, "$text{'autoindex_deficon'}",
61 &opt_input($_[0]->{'value'}, "DefaultIcon", "$text{'autoindex_default'}", 20));
65 return &parse_opt("DefaultIcon", '^\S+$', "$text{'autoindex_edeficon'}");
68 @AddAlt_dirs = ("AddAlt", "AddAltByType", "AddAltByEncoding");
69 @AddAlt_descs = ("Filename", "MIME type", "Encoding");
71 sub edit_AddAlt_AddAltByType_AddAltByEncoding
73 local($rv, @all, $i, $j, $alt, $mode, $file);
74 $rv = "<table border>\n".
75 "<tr $tb> <td><b>$text{'autoindex_alt'}</b></td>\n".
76 "<td><b>$text{'autoindex_match'}</b></td> <td><b>$text{'autoindex_fte'}</b></td></tr>\n";
77 @all = (@{$_[0]}, @{$_[1]}, @{$_[2]});
78 for($i=0; $i<=@all; $i++) {
81 $alt = $d->{'words'}->[0];
82 @w = @{$d->{'words'}};
83 $file = join(' ', @w[1..$#w]);
84 $mode = &indexof($d->{'name'}, @AddAlt_dirs);
86 else { $alt = $file = ""; $mode = 0; }
89 $rv .="<td><input name=AddAlt_alt_$i size=20 value=\"$alt\"></td>\n";
90 $rv .="<td><select name=AddAlt_mode_$i>\n";
91 for($j=0; $j<@AddAlt_descs; $j++) {
92 $rv .= sprintf "<option value=$j %s>%s\n",
93 $mode == $j ? "selected" : "", $AddAlt_descs[$j];
95 $rv .="</select></td>\n";
96 $rv .="<td><input name=AddAlt_file_$i size=20 value=\"$file\"></td>\n";
100 return (2, "$text{'autoindex_diralt'}", $rv);
102 sub save_AddAlt_AddAltByType_AddAltByEncoding
104 local($i, $alt, $file, $mode, $aref, @ai, @ait, @aie);
105 for($i=0; defined($alt = $in{"AddAlt_alt_$i"}); $i++) {
106 $mode = $in{"AddAlt_mode_$i"}; $file = $in{"AddAlt_file_$i"};
107 if ($alt !~ /\S/ && $file !~ /\S/) { next; }
108 $file =~ /\S/ || &error(&text('autoindex_emissquot', $AddAlt_descs[$mode], $alt));
109 $aref = $mode==0 ? \@ai : $mode==1 ? \@ait : \@aie;
110 push(@$aref, "\"$alt\" $file");
112 return ( \@ai, \@ait, \@aie );
115 sub edit_AddDescription
117 local($rv, $i, $desc, $file);
118 $rv = "<table border>\n".
119 "<tr $tb> <td><b>$text{'autoindex_desc'}</b></td> <td><b>$text{'autoindex_fnames'}</b></td> </tr>\n";
120 for($i=0; $i<=@{$_[0]}; $i++) {
121 if ($_[0]->[$i] && $_[0]->[$i]->{'value'} =~ /^"(.*)"\s*(.*)$/)
122 { $desc = $1; $file = $2; }
123 else { $desc = $file = ""; }
124 $rv .= "<tr $cb> <td><input size=40 name=AddDescription_desc_$i ".
125 "value=\"$desc\"></td>\n";
126 $rv .= "<td><input size=20 name=AddDescription_file_$i ".
127 "value=\"$file\"></td> </tr>\n";
130 return (2, "$text{'autoindex_dirdesc'}", $rv);
132 sub save_AddDescription
134 local($i, $desc, $file, @rv);
135 for($i=0; defined($in{"AddDescription_desc_$i"}); $i++) {
136 $desc = $in{"AddDescription_desc_$i"};
137 $file = $in{"AddDescription_file_$i"};
138 if ($desc !~ /\S/ && $file !~ /\S/) { next; }
139 $desc =~ /\S/ || &error(&text('autoindex_enodesc', $file));
140 $file =~ /\S/ || &error(&text('autoindex_enofile', $desc));
141 push(@rv, "\"$desc\" $file");
147 ( "FancyIndexing", "ScanHTMLTitles", "IconHeight", "IconWidth",
148 "SuppressColumnSorting", "SuppressDescription",
149 "SuppressHTMLPreamble", "SuppressLastModified", "SuppressSize",
150 "IconsAreLinks", "NameWidth", "DescriptionWidth", "FoldersFirst",
151 "HTMLTable", "IgnoreClient", "SuppressIcon", "SuppressRules",
152 "TrackModified", "VersionSort" );
154 ( $text{'autoindex_fancy'},
155 $text{'autoindex_htmltitle'},
156 $text{'autoindex_iheight'},
157 $text{'autoindex_iwidth'},
158 $text{'autoindex_sort'},
159 $text{'autoindex_fildesc'},
160 $text{'autoindex_htags'},
161 $text{'autoindex_mtime'},
162 $text{'autoindex_size'},
163 $text{'autoindex_iconlink'},
164 $text{'autoindex_fwidth'},
165 $text{'autoindex_dwidth'},
166 $text{'autoindex_dirfirst'},
167 $text{'autoindex_html'},
168 $text{'autoindex_client'},
169 $text{'autoindex_sicon'},
170 $text{'autoindex_srules'},
171 $text{'autoindex_track'},
172 $text{'autoindex_version'} );
173 @IndexOptions_i = ( 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0 );
174 @IndexOptions_n = ( 0, 0, 1.3, 1.3,
177 1.302, 1.302, 1.310, 1.310,
178 2.023, 2.023, 2.023, 2.023,
181 sub edit_IndexOptions_FancyIndexing
183 local($o, %opts, $i, $rv);
184 $rv = &choice_input($_[0] || $_[1] ? 0 : 1, "IndexOptions_def", 1,
185 "$text{'autoindex_default2'},1", "$text{'autoindex_select'},0");
186 foreach $o (split(/\s+/, $_[0]->{'value'})) {
187 if ($o =~ /^(\S+)=(\S+)$/) { $opts{$1} = $2; }
188 else { $opts{$o} = -1; }
190 if ($_[1]->{'value'} eq "on") { $opts{'FancyIndexing'} = -1; }
191 $rv .= "<table border><tr><td><table cellpadding=0>\n";
193 for($i=0; $i<@IndexOptions_v; $i++) {
194 $o = $IndexOptions_v[$i];
195 next if ($_[2]->{'version'} < $IndexOptions_n[$i]);
197 $rv .= "<tr>\n" if (!$sw);
198 if ($IndexOptions_i[$i]) { $opts{$o} = -$opts{$o}-1; }
199 $rv .= sprintf "<td><input type=checkbox name=Index_$o value=1 %s> %s\n",
200 $opts{$o} ? "checked" : "", $IndexOptions_d[$i];
201 if ($o =~ /IconWidth|IconHeight/) {
204 "<input type=radio name=Index_${o}_def value=1 %s> $text{'autoindex_default3'}\n",
205 $opts{$o} < 0 ? "checked" : "";
207 " <input type=radio name=Index_${o}_def value=0 %s>\n",
208 $opts{$o} < 0 ? "" : "checked";
210 "<input name=Index_${o}_wh size=5 value=\"%s\"> $text{'autoindex_pixels'}\n",
211 $opts{$o} < 0 ? "" : $opts{$o};
213 elsif ($o =~ /NameWidth|DescriptionWidth/) {
216 "<input name=Index_${o}_w size=5 value=\"%s\"> $text{'autoindex_chars'}\n",
217 $opts{$o} < 0 ? "" : $opts{$o};
220 $rv .= "</tr>\n" if ($sw);
223 $rv .= "</table></td></tr></table>\n";
224 return (2, "$text{'autoindex_diropt'}", $rv);
226 sub save_IndexOptions_FancyIndexing
228 local($i, $o, @rv, %opts);
229 if ($in{'IndexOptions_def'}) { return ( [ ], [ ] ); }
230 for($i=0; $i<@IndexOptions_v; $i++) {
231 $o = $IndexOptions_v[$i];
232 next if ($_[0]->{'version'} < $IndexOptions_n[$i]);
234 if ($in{"Index_$o"}) { $opts{$o} = -1; }
235 if ($o =~ /IconWidth|IconHeight/ &&
236 $in{"Index_${o}"} && !$in{"Index_${o}_def"}) {
237 $in{"Index_${o}_wh"} =~ /^[1-9]\d*$/ ||
238 &error(&text('autoindex_eiconsize', $in{"Index_${o}_wh"}));
239 $opts{$o} = $in{"Index_${o}_wh"};
241 elsif ($o =~ /NameWidth|DescriptionWidth/ && $in{"Index_${o}"}) {
242 $in{"Index_${o}_w"} =~ /^[1-9]\d*$/ ||
243 $in{"Index_${o}_w"} eq '*' ||
244 &error(&text('autoindex_ewidth', $in{"Index_$(o)_h"}));
245 $opts{$o} = $in{"Index_${o}_w"};
247 if ($IndexOptions_i[$i]) { $opts{$o} = -$opts{$o}-1; }
248 if ($opts{$o} < 0) { push(@rv, "$o"); }
249 elsif ($opts{$o} > 0) { push(@rv, "$o=$opts{$o}"); }
251 return ( [ join(' ', @rv) ], [ ] );
256 return (1, "$text{'autoindex_dirhead'}",
257 &opt_input($_[0]->{'value'}, "HeaderName", "$text{'autoindex_default4'}", 20));
261 return &parse_opt("HeaderName", '^\S+$', "$text{'autoindex_edirhead'}");
266 return (1, "$text{'autoindex_dirfoot'}",
267 &opt_input($_[0]->{'value'}, "ReadmeName", "$text{'autoindex_default4'}", 20));
271 return &parse_opt("ReadmeName", '^\S+$', "$text{'autoindex_edirfoot'}");
277 foreach $i (@{$_[0]}) { push(@ii, split(/\s+/, $i->{'value'})); }
278 $rv = join("\n", @ii);
279 return (1, "$text{'autoindex_ignore'}",
280 "<textarea name=IndexIgnore rows=5 cols=20>$rv</textarea>");
284 local(@rv); @rv = split(/\s+/, $in{'IndexIgnore'});
285 if (!@rv) { return ( [ ] ); }
286 else { return ( [ join(' ', @rv) ] ); }