mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-06 15:45:34 +02:00
ok, we are not able to cover all possibilities (IF A eq (B & C)) for example... or IF A == B... this would require a lot more code we do not see the need for.
git-svn-id: file:///svn/phpbb/trunk@8043 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
b29d76b558
commit
6b75e8ffcb
@ -526,60 +526,7 @@ class template_compile
|
||||
}
|
||||
}
|
||||
|
||||
// Try to combine some tokens...
|
||||
$new_tokens = array();
|
||||
$j = 0;
|
||||
|
||||
for ($i = 0, $size = sizeof($tokens); $i < $size; $i++)
|
||||
{
|
||||
$token = &$tokens[$i];
|
||||
|
||||
if ($token != '&&' && $token != '||')
|
||||
{
|
||||
$new_tokens[$j][] = $token;
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->_merge_tokens(' ', $new_tokens[$j]);
|
||||
$new_tokens[$j++] .= $token;
|
||||
}
|
||||
|
||||
if (!sizeof($new_tokens))
|
||||
{
|
||||
$new_tokens[$j] = &$tokens;
|
||||
}
|
||||
|
||||
if (isset($new_tokens[$j]) && is_array($new_tokens[$j]))
|
||||
{
|
||||
$this->_merge_tokens('', $new_tokens[$j]);
|
||||
}
|
||||
|
||||
return (($elseif) ? '} else if (' : 'if (') . (implode(' ', $new_tokens) . ') { ');
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge tokens from IF expression, correctly adding isset() calls.
|
||||
* @access private
|
||||
*/
|
||||
function _merge_tokens($suffix, &$tokens)
|
||||
{
|
||||
for ($i = 0, $size = sizeof($tokens); $i < $size; $i++)
|
||||
{
|
||||
$token = &$tokens[$i];
|
||||
|
||||
if (strpos($token, '$this') === 0)
|
||||
{
|
||||
$token = '(isset(' . $token . ') && ' . $token;
|
||||
$suffix = ')' . $suffix;
|
||||
}
|
||||
else if (strpos($token, 'sizeof(') === 0)
|
||||
{
|
||||
$token = '(isset(' . substr($token, 7, -1) . ') && ' . $token;
|
||||
$suffix = ')' . $suffix;
|
||||
}
|
||||
}
|
||||
|
||||
$tokens = implode(' ', $tokens) . $suffix;
|
||||
return (($elseif) ? '} else if (' : 'if (') . (implode(' ', $tokens) . ') { ');
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user