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
|
@ -324,32 +324,73 @@ class Template {
|
||||||
$code_lines[$i] = chop($code_lines[$i]);
|
$code_lines[$i] = chop($code_lines[$i]);
|
||||||
if (preg_match('#<!-- BEGIN (.*?) -->#', $code_lines[$i], $m))
|
if (preg_match('#<!-- BEGIN (.*?) -->#', $code_lines[$i], $m))
|
||||||
{
|
{
|
||||||
// We have the start of a block.
|
$n[0] = $m[0];
|
||||||
$block_nesting_level++;
|
$n[1] = $m[1];
|
||||||
$block_names[$block_nesting_level] = $m[1];
|
|
||||||
|
// Added: dougk_ff7-Keeps templates from bombing if begin is on the same line as end.. I think. :)
|
||||||
if ($block_nesting_level < 2)
|
if (preg_match('#<!-- END (.*?) -->#', $code_lines[$i], $n))
|
||||||
{
|
{
|
||||||
// Block is not nested.
|
$block_nesting_level++;
|
||||||
$code_lines[$i] = '$_' . $m[1] . '_count = sizeof($this->_tpldata[\'' . $m[1] . '.\']);';
|
$block_names[$block_nesting_level] = $m[1];
|
||||||
$code_lines[$i] .= "\n" . 'for ($_' . $m[1] . '_i = 0; $_' . $m[1] . '_i < $_' . $m[1] . '_count; $_' . $m[1] . '_i++)';
|
if ($block_nesting_level < 2)
|
||||||
$code_lines[$i] .= "\n" . '{';
|
{
|
||||||
|
// 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
|
else
|
||||||
{
|
{
|
||||||
// This block is nested.
|
// We have the start of a block.
|
||||||
|
$block_nesting_level++;
|
||||||
// Generate a namespace string for this block.
|
$block_names[$block_nesting_level] = $m[1];
|
||||||
$namespace = implode('.', $block_names);
|
if ($block_nesting_level < 2)
|
||||||
// strip leading period from root level..
|
{
|
||||||
$namespace = substr($namespace, 2);
|
// Block is not nested.
|
||||||
// Get a reference to the data array for this block that depends on the
|
$code_lines[$i] = '$_' . $m[1] . '_count = sizeof($this->_tpldata[\'' . $m[1] . '.\']);';
|
||||||
// current indices of all parent blocks.
|
$code_lines[$i] .= "\n" . 'for ($_' . $m[1] . '_i = 0; $_' . $m[1] . '_i < $_' . $m[1] . '_count; $_' . $m[1] . '_i++)';
|
||||||
$varref = $this->generate_block_data_ref($namespace, false);
|
$code_lines[$i] .= "\n" . '{';
|
||||||
// Create the for loop code to iterate over this block.
|
}
|
||||||
$code_lines[$i] = '$_' . $m[1] . '_count = sizeof(' . $varref . ');';
|
else
|
||||||
$code_lines[$i] .= "\n" . 'for ($_' . $m[1] . '_i = 0; $_' . $m[1] . '_i < $_' . $m[1] . '_count; $_' . $m[1] . '_i++)';
|
{
|
||||||
$code_lines[$i] .= "\n" . '{';
|
// 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] = '$_' . $m[1] . '_count = sizeof(' . $varref . ');';
|
||||||
|
$code_lines[$i] .= "\n" . 'for ($_' . $m[1] . '_i = 0; $_' . $m[1] . '_i < $_' . $m[1] . '_count; $_' . $m[1] . '_i++)';
|
||||||
|
$code_lines[$i] .= "\n" . '{';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (preg_match('#<!-- END (.*?) -->#', $code_lines[$i], $m))
|
else if (preg_match('#<!-- END (.*?) -->#', $code_lines[$i], $m))
|
||||||
|
@ -367,12 +408,10 @@ class Template {
|
||||||
$code_lines[$i] = 'echo \'' . $code_lines[$i] . '\' . "\\n";';
|
$code_lines[$i] = 'echo \'' . $code_lines[$i] . '\' . "\\n";';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bring it back into a single string of lines of code.
|
// Bring it back into a single string of lines of code.
|
||||||
$code = implode("\n", $code_lines);
|
$code = implode("\n", $code_lines);
|
||||||
|
|
||||||
return $code ;
|
return $code ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue