Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
Dwoo
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Common
Dwoo
Commits
0887207e
Commit
0887207e
authored
Dec 08, 2009
by
seldaek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed a bug in {tif} that didn't work when 0 was given as the true or false value
git-svn-id:
http://svn.dwoo.org/trunk@318
0598d79b-80c4-4d41-97ba-ac86fbbd088b
parent
27642e40
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
3 deletions
+8
-3
CHANGELOG
CHANGELOG
+2
-0
tif.php
lib/plugins/builtin/functions/tif.php
+6
-3
No files found.
CHANGELOG
View file @
0887207e
...
...
@@ -18,6 +18,8 @@
*
Fixed
a
bug
when
accessing
array
indices
that
contain
a
minus
sign
,
it
is
now
possible
to
access
those
using
{$
var
[
index
-
foo
]},
{$
var
[
'index-foo'
]}
or
{$
index
=
"index-foo"
}
{$
var
[$
index
]}
*
Fixed
a
bug
in
{
tif
}
that
didn
't work when 0 was given as the true or
false value
* Fixed a bug when using the autoEscape feature with sub-templates (the
compiled sub-template couldn'
t
access
the
dwoo
charset
property
,
resulting
in
a
fatal
error
)
...
...
lib/plugins/builtin/functions/tif.php
View file @
0887207e
...
...
@@ -28,7 +28,7 @@ function Dwoo_Plugin_tif_compile(Dwoo_Compiler $compiler, array $rest)
throw
new
Dwoo_Compilation_Exception
(
$compiler
,
'Tif: the if plugin is required to use Tif'
);
}
}
if
(
count
(
$rest
)
==
1
)
{
return
$rest
[
0
];
}
...
...
@@ -40,6 +40,9 @@ function Dwoo_Plugin_tif_compile(Dwoo_Compiler $compiler, array $rest)
// remove the ':' if present
array_pop
(
$rest
);
}
elseif
(
trim
(
end
(
$rest
),
'"\''
)
===
'?'
||
count
(
$rest
)
===
1
)
{
if
(
$falseResult
===
'?'
||
$falseResult
===
':'
)
{
throw
new
Dwoo_Compilation_Exception
(
$compiler
,
'Tif: incomplete tif statement, value missing after '
.
$falseResult
);
}
// there was in fact no false result provided, so we move it to be the true result instead
$trueResult
=
$falseResult
;
$falseResult
=
"''"
;
...
...
@@ -60,12 +63,12 @@ function Dwoo_Plugin_tif_compile(Dwoo_Compiler $compiler, array $rest)
}
// check params were correctly provided
if
(
empty
(
$rest
)
||
empty
(
$trueResult
)
||
empty
(
$falseResult
)
)
{
if
(
empty
(
$rest
)
||
$trueResult
===
null
||
$falseResult
===
null
)
{
throw
new
Dwoo_Compilation_Exception
(
$compiler
,
'Tif: you must provide three parameters serving as <expression> ? <true value> : <false value>'
);
}
// parse condition
$condition
=
Dwoo_Plugin_if
::
replaceKeywords
(
$rest
,
$compiler
);
return
'(('
.
implode
(
' '
,
$condition
)
.
') ? '
.
(
$trueResult
===
true
?
implode
(
' '
,
$condition
)
:
$trueResult
)
.
' : '
.
$falseResult
.
')'
;
return
'(('
.
implode
(
' '
,
$condition
)
.
') ? '
.
(
$trueResult
===
true
?
implode
(
' '
,
$condition
)
:
$trueResult
)
.
' : '
.
$falseResult
.
')'
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment