mirror of
https://github.com/webmin/webmin.git
synced 2025-07-20 16:48:46 +00:00
Add ability to resolve compatibility-level conditionals
https://sourceforge.net/p/webadmin/bugs/5653/
This commit is contained in:
@ -89,7 +89,7 @@ print &ui_table_start($text{'general_title_others'}, "width=100%", 4);
|
||||
&option_radios_freefield("mynetworks", 60, $text{'default'});
|
||||
|
||||
&option_select("mynetworks_style",
|
||||
[ [ "", $text{'default'} ],
|
||||
[ [ &resolve_current_value("mynetworks_style"), $text{'default'} ],
|
||||
[ "subnet", $text{'opts_mynetworks_subnet'} ],
|
||||
[ "class", $text{'opts_mynetworks_class'} ],
|
||||
[ "host", $text{'opts_mynetworks_host'} ] ]);
|
||||
|
@ -163,6 +163,24 @@ if ($key) {
|
||||
return $out;
|
||||
}
|
||||
|
||||
# resolve_current_value(parameter_name)
|
||||
# Returns the value of the parameter, with compatibility-level conditionals
|
||||
sub resolve_current_value
|
||||
{
|
||||
my ($parameter_name) = @_;
|
||||
|
||||
my $raw_value = &get_current_value($parameter_name);
|
||||
my $compatibility_level = &get_current_value("compatibility_level");
|
||||
|
||||
if ($raw_value =~ /\{\{\$compatibility_level\}\s*([<>=!]+)\s*\{(\d+)\}\s*\?\s*\{(.*?)\}\s*:\s*\{(.*?)\}\}/) {
|
||||
my ($op, $lvl, $tval, $fval) = ($1, $2, $3, $4);
|
||||
return undef if ($op !~ /^([<>]=?|==|!=)$/);
|
||||
return eval "\$compatibility_level $op $lvl" ? $tval : $fval;
|
||||
}
|
||||
|
||||
return $raw_value;
|
||||
}
|
||||
|
||||
# if_default_value(parameter_name)
|
||||
# returns if the value is the default value
|
||||
sub if_default_value
|
||||
|
Reference in New Issue
Block a user