mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
Fixes a template parsing error.
git-svn-id: file:///svn/phpbb/trunk@847 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
1e1eaa8146
commit
0073e1ffe4
1 changed files with 64 additions and 25 deletions
|
@ -323,11 +323,51 @@ class Template {
|
|||
{
|
||||
$code_lines[$i] = chop($code_lines[$i]);
|
||||
if (preg_match('#<!-- BEGIN (.*?) -->#', $code_lines[$i], $m))
|
||||
{
|
||||
$n[0] = $m[0];
|
||||
$n[1] = $m[1];
|
||||
|
||||
// Added: dougk_ff7-Keeps templates from bombing if begin is on the same line as end.. I think. :)
|
||||
if (preg_match('#<!-- END (.*?) -->#', $code_lines[$i], $n))
|
||||
{
|
||||
$block_nesting_level++;
|
||||
$block_names[$block_nesting_level] = $m[1];
|
||||
if ($block_nesting_level < 2)
|
||||
{
|
||||
// Block is not nested.
|
||||
$code_lines[$i] = '$_' . $a[1] . '_count = sizeof($this->_tpldata[\'' . $n[1] . '.\']);';
|
||||
$code_lines[$i] .= "\n" . 'for ($_' . $n[1] . '_i = 0; $_' . $n[1] . '_i < $_' . $n[1] . '_count; $_' . $n[1] . '_i++)';
|
||||
$code_lines[$i] .= "\n" . '{';
|
||||
}
|
||||
else
|
||||
{
|
||||
// This block is nested.
|
||||
|
||||
// Generate a namespace string for this block.
|
||||
$namespace = implode('.', $block_names);
|
||||
// strip leading period from root level..
|
||||
$namespace = substr($namespace, 2);
|
||||
// Get a reference to the data array for this block that depends on the
|
||||
// current indices of all parent blocks.
|
||||
$varref = $this->generate_block_data_ref($namespace, false);
|
||||
// Create the for loop code to iterate over this block.
|
||||
$code_lines[$i] = '$_' . $a[1] . '_count = sizeof(' . $varref . ');';
|
||||
$code_lines[$i] .= "\n" . 'for ($_' . $n[1] . '_i = 0; $_' . $n[1] . '_i < $_' . $n[1] . '_count; $_' . $n[1] . '_i++)';
|
||||
$code_lines[$i] .= "\n" . '{';
|
||||
}
|
||||
|
||||
// We have the end of a block.
|
||||
unset($block_names[$block_nesting_level]);
|
||||
$block_nesting_level--;
|
||||
$code_lines[$i] .= '} // END ' . $n[1];
|
||||
$m[0] = $n[0];
|
||||
$m[1] = $n[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
// We have the start of a block.
|
||||
$block_nesting_level++;
|
||||
$block_names[$block_nesting_level] = $m[1];
|
||||
|
||||
if ($block_nesting_level < 2)
|
||||
{
|
||||
// Block is not nested.
|
||||
|
@ -352,6 +392,7 @@ class Template {
|
|||
$code_lines[$i] .= "\n" . '{';
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (preg_match('#<!-- END (.*?) -->#', $code_lines[$i], $m))
|
||||
{
|
||||
// We have the end of a block.
|
||||
|
@ -367,12 +408,10 @@ class Template {
|
|||
$code_lines[$i] = 'echo \'' . $code_lines[$i] . '\' . "\\n";';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Bring it back into a single string of lines of code.
|
||||
$code = implode("\n", $code_lines);
|
||||
|
||||
return $code ;
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue