Skip to content

Commit

Permalink
Item12180: Standardize test presentation & correct initial guess
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@16185 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
TimotheLitt authored and TimotheLitt committed Dec 10, 2012
1 parent bc885fe commit ed934bf
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions core/lib/Foswiki/Configure/Checkers/PubUrlPath.pm
Expand Up @@ -11,28 +11,34 @@ use Foswiki::Configure qw/:cgi/;

sub check {
my $this = shift;
my ($valobj) = @_;

unless ( $Foswiki::cfg{PubUrlPath}
&& $Foswiki::cfg{PubUrlPath} ne 'NOT SET' )
{
my $guess = $this->getItemCurrentValue('ScriptUrlPath');
$guess =~ s/\/[^\/]*?bin$/\/pub/;
my $value = $this->getCfg;
unless ( $value && $value ne 'NOT SET' ) {
my $guess = $this->getItemCurrentValue('{ScriptUrlPath}');
$guess =~ s,/[^/]*?bin$,/pub,;
$guess .= '/pub' unless ( $guess =~ m/pub$/ );
$this->{GuessedValue} = $guess;
$this->setItemValue($guess);
return $this->SUPER::check(@_);
$value = $guess;
}
my $d = $this->getCfg;
my $mess = $this->SUPER::check(@_);
return $mess if ( $mess =~ /Error:/ );

my $t = "/System/ProjectLogos/foswiki-logo.png";
my $ok = $this->NOTE("Successfully accessed a file under $value");
my $fail = $this->ERROR("Failed to acccess a file under $value");
$valobj->{errors}--;

$mess .= $this->NOTE("Please wait while the path is tested")
. qq{<div class='configureSetting' onload='\$("[name=\\"\\{PubUrlPath\\}Error\\"]").hide();\$("[name=\\"\\{PubUrlPath\\}Ok\\"]").hide();'>
<img name="{PubUrlPath}TestImage" src="$d$t" testImg="$t" style="height:20px;"
$mess .= $this->NOTE(
"Please wait while the setting is tested. Disregard any message that appears only briefly."
. qq{<span onload='\$("[name=\\"\\{PubUrlPath\\}Error\\"]").hide();\$("[name=\\"\\{PubUrlPath\\}Ok\\"]").hide();'>
<img name="{PubUrlPath}TestImage" src="$value$t" testImg="$t" style="height:1px;opacity:0"
onload='\$("[name=\\"\\{PubUrlPath\\}Error\\"]").hide();\$("[name=\\"\\{PubUrlPath\\}Ok\\"]").show();'
onerror='\$("[name=\\"\\{PubUrlPath\\}Ok\\"]").hide();\$("[name=\\"\\{PubUrlPath\\}Error\\"]").show();'>
<span name="{PubUrlPath}Ok">This setting is correct.</span>
<span name="{PubUrlPath}Error"><img src="${resourceURI}icon_error.png" style="margin-right:5px;">Path is not correct.</span></div>};
<span name="{PubUrlPath}Ok">$ok</span>
<span name="{PubUrlPath}Error">$fail</span></span>}
);

return $mess;
}
Expand Down

0 comments on commit ed934bf

Please sign in to comment.