- <select name="<%= $i->key. $n %>" <%= $type eq 'selectmultiple' ? 'MULTIPLE' : '' %>>
- <% my %saw;
- foreach my $value ( "", @{$i->select_enum} ) {
- local($^W)=0; next if $saw{$value}++; %>
- <option value="<%= $value %>"<%= $value eq $conf->config($i->key) || ( $type eq 'selectmultiple' && grep { $_ eq $value } $conf->config($i->key) ) ? ' SELECTED' : '' %>><%= $value %>
+
+ <select name="<%= $i->key. $n %>" <%= $type eq 'selectmultiple' ? 'MULTIPLE' : '' %>>
+ <%
+ my %hash = ();
+ if ( $i->select_enum ) {
+ tie %hash, 'Tie::IxHash',
+ '' => '', map { $_ => $_ } @{ $i->select_enum };
+ } elsif ( $i->select_hash ) {
+ if ( ref($i->select_hash) eq 'ARRAY' ) {
+ tie %hash, 'Tie::IxHash',
+ '' => '', @{ $i->select_hash };
+ } else {
+ tie %hash, 'Tie::IxHash',
+ '' => '', %{ $i->select_hash };
+ }
+ } else {
+ %hash = ( '' => 'WARNING: neither select_enum nor select_hash specified in Conf.pm for configuration option "'. $i->key. '"' );
+ }
+
+ my %saw = ();
+ foreach my $value ( keys %hash ) {
+ local($^W)=0; next if $saw{$value}++;
+ my $label = $hash{$value};
+ %>
+
+ <option value="<%= $value %>"<%= $value eq $conf->config($i->key) || ( $type eq 'selectmultiple' && grep { $_ eq $value } $conf->config($i->key) ) ? ' SELECTED' : '' %>><%= $label %>
+
+ <% } %>
+
+ <% my $curvalue = $conf->config($i->key);
+ if ( $conf->exists($i->key) && $curvalue
+ && ! grep { $curvalue eq $_ } @{$i->select_enum}
+ ) {
+ %>
+
+ <option value="<%= $conf->config($i->key) %>" SELECTED><%= exists( $hash{ $conf->config($i->key) } ) ? $hash{ $conf->config($i->key) } : $conf->config($i->key) %>
+
+ <% } %>
+
+ </select>
+
+ <% } elsif ( $type eq 'select-sub' ) { %>
+
+ <select name="<%= $i->key. $n %>">
+ <option value="">
+ <% my %options = &{$i->options_sub};
+ my @options = sort { $a <=> $b } keys %options;
+ my %saw;
+ foreach my $value ( @options ) {
+ local($^W)=0; next if $saw{$value}++;
+ %>
+ <option value="<%= $value %>"<%= $value eq $conf->config($i->key) ? ' SELECTED' : '' %>><%= $value %>: <%= $options{$value} %>