Skip to content

Commit

Permalink
Item9232: configure Checkers docco update - it seems the Checker is …
Browse files Browse the repository at this point in the history
…the guesser :)

git-svn-id: http://svn.foswiki.org/trunk@8015 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
SvenDowideit authored and SvenDowideit committed Jul 3, 2010
1 parent a44071d commit 15c7ddd
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 15 deletions.
5 changes: 3 additions & 2 deletions core/bin/configure
Expand Up @@ -39,8 +39,9 @@
# that generate views. They are all subclasses of Foswiki::Configure::UI
# UIs - are top-level and pluggable UI components. All the main screens are
# implemented here.
# Checkers - are specialised UIs designed to give checking support for
# variable values. Checkers also include the read-only checking
# Checkers - are specialised UIs designed to give checking and guessing support for
# variable values (see Checker.pm for an example).
# Checkers also include the read-only checking
# UIs used for checking environment.
# Types - provide some UI support in the form of type-specific prompters.
# this is really an abuse of the Model, but it saves creating
Expand Down
41 changes: 33 additions & 8 deletions core/lib/Foswiki/Configure/Checker.pm
Expand Up @@ -11,6 +11,39 @@ our @ISA = ('Foswiki::Configure::UI');
use File::Spec ();
use CGI ();

=begin
---+++ ObjectMethod check($value, $root) -> 'html'
* $value - **UNDOCUMENTED**
* $root - **UNDOCUMENTED**
Entry point for the value check. Overridden by subclasses.
returns html formatted by $this->ERROR(), WARN(), NOTE(), guessed() or hand made
_OR_ and empty string to be inserted in the configure UI
the checker can either check the sanity of the previously saved value, or guess a one if none exists:
in MySetting.pm...
#The NOT SET is automatically assigned in BasicSanity when a required or all else fails setting isn't found
#(currently DataDir DefaultUrlHost PubUrlPath PubDir TemplateDir ScriptUrlPath LocalesDir).
#In this case this part of the condition will never fire, but if !defined($val)
#it will still guess that $Foswiki::cfg{DispScriptUrlPath} = $Foswiki::cfg{ScriptUrlPath}.
my $val = $Foswiki::cfg{DispScriptUrlPath};
if ( !defined($val) || $val eq 'NOT SET' ) {
$Foswiki::cfg{MySetting} = your guess;
return $this->guessed(0);
}
=cut

sub check {
my ( $this, $value, $root ) = @_;

# default behaviour; do nothing
return '';
}

sub guessed {
my ( $this, $error ) = @_;

Expand Down Expand Up @@ -223,14 +256,6 @@ MESS
return '';
}

# Entry point for the value check. Overridden by subclasses.
sub check {
my ( $this, $value, $root ) = @_;

# default behaviour; do nothing
return '';
}

sub copytree {
my ( $this, $from, $to ) = @_;
my $e = '';
Expand Down
5 changes: 0 additions & 5 deletions core/lib/Foswiki/Configure/Checkers/DispScriptUrlPath.pm
Expand Up @@ -10,12 +10,7 @@ our @ISA = ('Foswiki::Configure::Checker');
sub check {
my $this = shift;

# Check Script URL Path against REQUEST_URI
my $n;
my $val = $Foswiki::cfg{DispScriptUrlPath};
my $guess = $ENV{REQUEST_URI} || $ENV{SCRIPT_NAME} || '';
$guess =~ s(/+configure[^/]*$)();

if ( !defined($val) || $val eq 'NOT SET' ) {
$Foswiki::cfg{DispScriptUrlPath} = $Foswiki::cfg{ScriptUrlPath};
return $this->guessed(0);
Expand Down

0 comments on commit 15c7ddd

Please sign in to comment.