Fix the if macro to recognize that 0 is a false value.

This commit is contained in:
Colin Kuskie 2009-07-12 20:44:00 +00:00
parent 84d8b24cec
commit b8ae0f8da8
2 changed files with 13 additions and 13 deletions

View file

@ -2,6 +2,7 @@
- fixed #10629: WebGUI::ProfileField create new field bug - fixed #10629: WebGUI::ProfileField create new field bug
- fixed #10626: Carriage returns stripped from Wiki comments - fixed #10626: Carriage returns stripped from Wiki comments
- fixed #10572: CDN / CloudFront breaks 7.7.11 upgrade - fixed #10572: CDN / CloudFront breaks 7.7.11 upgrade
- fixed #10630: If macro says that 0 is true
7.7.14 7.7.14
- fixed #10606: shelf selector - fixed #10606: shelf selector

View file

@ -18,24 +18,23 @@ Package WebGUI::Macro::If
=head1 DESCRIPTION =head1 DESCRIPTION
Macro for displaying text based on whether or not the value entered it empty. Macro for displaying text based on whether or not the value entered is true.
=head2 process ( value, textIfValue, textIfNotValule ) =head2 process ( value, textIfTrue, textIfFalse )
Either the textIfValue or textIfNotValue fields can be empty
=head3 value =head3 value
The value to test to see if it's empty. The value to test to see if it's true or not. False values are the empty string, 0 and
any string which is only whitespace.
=head3 textIfValue =head3 textIfTrue
The text to be displayed if the value is not empty. Use %s to represent the value itself. The text to be displayed if the value is not false. Use %s to represent the value itself.
ex: ^HasValueText(test,<li>%s</li>,); ex: ^If(test,<li>%s</li>,);
returns: <li>test</li> returns: <li>test</li>
=head3 textIfNoValue =head3 textIfFalse
Text to be displayed if the value is empty. Text to be displayed if the value is empty.
@ -44,13 +43,13 @@ Text to be displayed if the value is empty.
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub process { sub process {
my $session = shift; my $session = shift;
my ($value, $valueText, $noValueText ) = @_; my ($value, $trueText, $falseText ) = @_;
$value =~ s/^\s//; $value =~ s/^\s//;
$value =~ s/\s$//; $value =~ s/\s$//;
if ($value eq "") { if (!$value) {
return $noValueText; return $falseText;
} }
return sprintf($valueText,$value); return sprintf($trueText,$value);
} }