Skip to content

Commit

Permalink
Item11528: Hide irrelevant configure options based on the values of o…
Browse files Browse the repository at this point in the history
…ther options

git-svn-id: http://svn.foswiki.org/trunk@14005 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
CrawfordCurrie authored and CrawfordCurrie committed Feb 16, 2012
1 parent deecffe commit f560719
Show file tree
Hide file tree
Showing 8 changed files with 580 additions and 542 deletions.
6 changes: 0 additions & 6 deletions core/lib/Foswiki.pm
Expand Up @@ -335,12 +335,6 @@ BEGIN {
$Foswiki::cfg{isVALID} = 1;
}

if ( $Foswiki::cfg{WarningsAreErrors} ) {

# Note: Warnings are always errors if ASSERTs are enabled
$SIG{'__WARN__'} = sub { die @_ };
}

if ( $Foswiki::cfg{UseLocale} ) {
require locale;
import locale();
Expand Down
293 changes: 143 additions & 150 deletions core/lib/Foswiki.spec

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions core/lib/Foswiki/Configure/Load.pm
Expand Up @@ -7,6 +7,9 @@
Handling for loading configuration information (Foswiki.spec, Config.spec and
LocalSite.cfg) as efficiently and flexibly as possible.
This reads *values* from these files and does *not* parse the structured comments. For that,
see FoswikiCfg.pm
=cut

package Foswiki::Configure::Load;
Expand Down
1 change: 0 additions & 1 deletion core/lib/Foswiki/Configure/Types/SELECT.pm
Expand Up @@ -12,7 +12,6 @@ sub prompt {
my ( $this, $id, $opts, $value, $class ) = @_;
$opts =~ s/^\s+//;
$opts =~ s/\s+$//;
$opts =~ s/(\b|^)EXPERT(\b|$)//i;
my $sopts = '';
if ( defined($value) ) {
$sopts .= '<option selected="selected">' . $value . '</option>';
Expand Down
35 changes: 15 additions & 20 deletions core/lib/Foswiki/Configure/UIs/Value.pm
Expand Up @@ -40,11 +40,11 @@ sub renderHtml {

return '' if $value->{hidden};

my $isExpert = $value->isExpertsOnly();
my $info = '';

$info .= $value->{desc};
my $keys = $value->getKeys();
my $isExpert = $value->isExpertsOnly();
my $displayIf = $value->displayIf();
my $enableIf = $value->enableIf();
my $info = $value->{desc};
my $keys = $value->getKeys();

my $checker = Foswiki::Configure::UI::loadChecker( $keys, $value );
my $isUnused = 0;
Expand Down Expand Up @@ -139,12 +139,17 @@ HERE
"<div id='info_$tip' class='configureInfoText foswikiMakeHidden'>$info</div>";
}

my $class = join( ' ', @cssClasses );
my %props;
$props{class} = join( ' ', @cssClasses ) if ( scalar @cssClasses );
$props{'data-displayif'} = $displayIf if $displayIf;
$props{'data-enableif'} = $enableIf if $enableIf;

$output .=
_getRowHtml( $class, "$index$hiddenTypeOf", $helpTextLink,
"$control&nbsp;$resetToDefaultLinkText$check$helpText" )
. "\n";
$output .= CGI::Tr(
\%props,
CGI::th( "$index$hiddenTypeOf" )
. CGI::td( "$control&nbsp;$resetToDefaultLinkText$check$helpText" )
. CGI::td( { class => "configureHelp" }, $helpTextLink ) )
. "\n";

return (
$output,
Expand All @@ -158,16 +163,6 @@ HERE
);
}

sub _getRowHtml {
my ( $class, $header, $info, $data ) = @_;

my $classProp = $class ? { class => $class } : undef;
return CGI::Tr( $classProp,
CGI::th( $classProp, $header )
. CGI::td( {}, $data )
. CGI::td( { class => "$class configureHelp" }, $info ) );
}

1;
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Expand Down
16 changes: 15 additions & 1 deletion core/lib/Foswiki/Configure/Value.pm
Expand Up @@ -69,7 +69,11 @@ sub new {
$this->{mandatory} = ( $this->{opts} =~ /(\b|^)M(\b|$)/ );
$this->{hidden} = ( $this->{opts} =~ /(\b|^)H(\b|$)/ );
$this->{expertsOnly} = 1
if ( $this->{opts} =~ s/\bEXPERT\b// );
if ( $this->{opts} =~ s/(\b|^)EXPERT(\b|$)// );
$this->{displayIf} = $1
if ( $this->{opts} =~ s/(?:\b|^)DISPLAY_IF\s+(.*?)(\/DISPLAY_IF|$)// );
$this->{enableIf} = $1
if ( $this->{opts} =~ s/(?:\b|^)ENABLE_IF\s+(.*?)(\/ENABLE_IF|$)// );
}

return $this;
Expand All @@ -81,6 +85,16 @@ sub isExpertsOnly {
return $this->{expertsOnly};
}

sub displayIf {
my $this = shift;
return $this->{displayIf} || '';
}

sub enableIf {
my $this = shift;
return $this->{enableIf} || '';
}

# See Foswiki::Configure::Item
sub getKeys {
my $this = shift;
Expand Down

0 comments on commit f560719

Please sign in to comment.