aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/template.php
diff options
context:
space:
mode:
authordougk_ff7 <dougk_ff7@users.sourceforge.net>2001-08-13 04:08:02 +0000
committerdougk_ff7 <dougk_ff7@users.sourceforge.net>2001-08-13 04:08:02 +0000
commit0073e1ffe4e505cf0e38db15f2cfd175466ee598 (patch)
tree93a981eb9883077f649759b74148f1f79261a32f /phpBB/includes/template.php
parent1e1eaa8146dc051f1d51a6d46beb405821f1c55f (diff)
downloadforums-0073e1ffe4e505cf0e38db15f2cfd175466ee598.tar
forums-0073e1ffe4e505cf0e38db15f2cfd175466ee598.tar.gz
forums-0073e1ffe4e505cf0e38db15f2cfd175466ee598.tar.bz2
forums-0073e1ffe4e505cf0e38db15f2cfd175466ee598.tar.xz
forums-0073e1ffe4e505cf0e38db15f2cfd175466ee598.zip
Fixes a template parsing error.
git-svn-id: file:///svn/phpbb/trunk@847 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/template.php')
-rw-r--r--phpBB/includes/template.php89
1 files changed, 64 insertions, 25 deletions
diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php
index 3e9c7d33d8..268fd46da4 100644
--- a/phpBB/includes/template.php
+++ b/phpBB/includes/template.php
@@ -324,32 +324,73 @@ class Template {
$code_lines[$i] = chop($code_lines[$i]);
if (preg_match('#<!-- BEGIN (.*?) -->#', $code_lines[$i], $m))
{
- // We have the start of a block.
- $block_nesting_level++;
- $block_names[$block_nesting_level] = $m[1];
-
- if ($block_nesting_level < 2)
+ $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 is not nested.
- $code_lines[$i] = '$_' . $m[1] . '_count = sizeof($this->_tpldata[\'' . $m[1] . '.\']);';
- $code_lines[$i] .= "\n" . 'for ($_' . $m[1] . '_i = 0; $_' . $m[1] . '_i < $_' . $m[1] . '_count; $_' . $m[1] . '_i++)';
- $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
{
- // 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" . '{';
+ // 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.
+ $code_lines[$i] = '$_' . $m[1] . '_count = sizeof($this->_tpldata[\'' . $m[1] . '.\']);';
+ $code_lines[$i] .= "\n" . 'for ($_' . $m[1] . '_i = 0; $_' . $m[1] . '_i < $_' . $m[1] . '_count; $_' . $m[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] = '$_' . $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))
@@ -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);
-
+ $code = implode("\n", $code_lines);
return $code ;
}