aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/includes/template/filter.php24
-rw-r--r--tests/profile/custom_test.php2
-rw-r--r--tests/template/template_test.php12
-rw-r--r--tests/template/templates/lang.html2
-rw-r--r--tests/template/templates/loop_nested_deep_multilevel_ref.html3
-rw-r--r--tests/utf/normalizer_test.php4
6 files changed, 30 insertions, 17 deletions
diff --git a/phpBB/includes/template/filter.php b/phpBB/includes/template/filter.php
index f24c3f4d09..115fe21e35 100644
--- a/phpBB/includes/template/filter.php
+++ b/phpBB/includes/template/filter.php
@@ -40,6 +40,7 @@ class phpbb_template_filter extends php_user_filter
const REGEX_NS = '[a-z_][a-z_0-9]+';
const REGEX_VAR = '[A-Z_][A-Z_0-9]+';
+ const REGEX_VAR_SUFFIX = '[A-Z_0-9]+';
const REGEX_TAG = '<!-- ([A-Z][A-Z_0-9]+)(?: (.*?) ?)?-->';
@@ -374,7 +375,7 @@ class phpbb_template_filter extends php_user_filter
// transform vars prefixed by L_ into their language variable pendant if nothing is set within the tpldata array
if (strpos($text_blocks, '{L_') !== false)
{
- $text_blocks = preg_replace('#\{L_(' . self::REGEX_VAR . ')\}#', "<?php echo ((isset(\$_rootref['L_\\1'])) ? \$_rootref['L_\\1'] : ((isset(\$_lang['\\1'])) ? \$_lang['\\1'] : '{ \\1 }')); /**/?>", $text_blocks, -1, $replacements);
+ $text_blocks = preg_replace('#\{L_(' . self::REGEX_VAR_SUFFIX . ')\}#', "<?php echo ((isset(\$_rootref['L_\\1'])) ? \$_rootref['L_\\1'] : ((isset(\$_lang['\\1'])) ? \$_lang['\\1'] : '{ \\1 }')); /**/?>", $text_blocks, -1, $replacements);
return (bool) $replacements;
}
@@ -382,7 +383,7 @@ class phpbb_template_filter extends php_user_filter
// If a template variable already exist, it will be used in favor of it...
if (strpos($text_blocks, '{LA_') !== false)
{
- $text_blocks = preg_replace('#\{LA_(' . self::REGEX_VAR . '+)\}#', "<?php echo ((isset(\$_rootref['LA_\\1'])) ? \$_rootref['LA_\\1'] : ((isset(\$_rootref['L_\\1'])) ? addslashes(\$_rootref['L_\\1']) : ((isset(\$_lang['\\1'])) ? addslashes(\$_lang['\\1']) : '{ \\1 }'))); /**/?>", $text_blocks, -1, $replacements);
+ $text_blocks = preg_replace('#\{LA_(' . self::REGEX_VAR_SUFFIX . '+)\}#', "<?php echo ((isset(\$_rootref['LA_\\1'])) ? \$_rootref['LA_\\1'] : ((isset(\$_rootref['L_\\1'])) ? addslashes(\$_rootref['L_\\1']) : ((isset(\$_lang['\\1'])) ? addslashes(\$_lang['\\1']) : '{ \\1 }'))); /**/?>", $text_blocks, -1, $replacements);
return (bool) $replacements;
}
@@ -872,6 +873,15 @@ class phpbb_template_filter extends php_user_filter
// Strip the trailing period.
$namespace = substr($namespace, 0, -1);
+ if (($pos = strrpos($namespace, '.')) !== false)
+ {
+ $local_namespace = substr($namespace, $pos + 1);
+ }
+ else
+ {
+ $local_namespace = $namespace;
+ }
+
$expr = true;
// S_ROW_COUNT is deceptive, it returns the current row number now the number of rows
@@ -880,23 +890,23 @@ class phpbb_template_filter extends php_user_filter
{
case 'S_ROW_NUM':
case 'S_ROW_COUNT':
- $varref = "\$_${namespace}_i";
+ $varref = "\$_${local_namespace}_i";
break;
case 'S_NUM_ROWS':
- $varref = "\$_${namespace}_count";
+ $varref = "\$_${local_namespace}_count";
break;
case 'S_FIRST_ROW':
- $varref = "(\$_${namespace}_i == 0)";
+ $varref = "(\$_${local_namespace}_i == 0)";
break;
case 'S_LAST_ROW':
- $varref = "(\$_${namespace}_i == \$_${namespace}_count - 1)";
+ $varref = "(\$_${local_namespace}_i == \$_${local_namespace}_count - 1)";
break;
case 'S_BLOCK_NAME':
- $varref = "'$namespace'";
+ $varref = "'$local_namespace'";
break;
default:
diff --git a/tests/profile/custom_test.php b/tests/profile/custom_test.php
index 0e0a851243..585182e583 100644
--- a/tests/profile/custom_test.php
+++ b/tests/profile/custom_test.php
@@ -48,7 +48,7 @@ class phpbb_profile_custom_test extends phpbb_database_test_case
);
$cp = new custom_profile;
- $result = $cp->validate_profile_field(FIELD_DROPDOWN, &$field_value, $field_data);
+ $result = $cp->validate_profile_field(FIELD_DROPDOWN, $field_value, $field_data);
$this->assertEquals($expected, $result, $description);
}
diff --git a/tests/template/template_test.php b/tests/template/template_test.php
index 28eba05217..86ff2e9ec6 100644
--- a/tests/template/template_test.php
+++ b/tests/template/template_test.php
@@ -211,21 +211,21 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array(),
array(),
array(),
- "{ VARIABLE }\n{ VARIABLE }",
+ "{ VARIABLE }\n{ 1_VARIABLE }\n{ VARIABLE }\n{ 1_VARIABLE }",
),
array(
'lang.html',
- array('L_VARIABLE' => "Value'"),
+ array('L_VARIABLE' => "Value'", 'L_1_VARIABLE' => "1 O'Clock"),
array(),
array(),
- "Value'\nValue\'",
+ "Value'\n1 O'Clock\nValue\'\n1 O\'Clock",
),
array(
'lang.html',
- array('LA_VARIABLE' => "Value'"),
+ array('LA_VARIABLE' => "Value'", 'LA_1_VARIABLE' => "1 O'Clock"),
array(),
array(),
- "{ VARIABLE }\nValue'",
+ "{ VARIABLE }\n{ 1_VARIABLE }\nValue'\n1 O'Clock",
),
array(
'loop_nested_multilevel_ref.html',
@@ -248,7 +248,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array('outer' => array(array()), 'outer.middle' => array(array()), 'outer.middle.inner' => array(array('VARIABLE' => 'z'), array('VARIABLE' => 'zz'))),
array(),
// I don't completely understand this output, hopefully it's correct
- "top-level content\nouter\n\ninner z\nfirst row\n\ninner zz",
+ "top-level content\nouter\nmiddle\ninner z\nfirst row of 2 in inner\n\ninner zz",
),
array(
'loop_size.html',
diff --git a/tests/template/templates/lang.html b/tests/template/templates/lang.html
index 2b5ea1cafe..3eecc298cb 100644
--- a/tests/template/templates/lang.html
+++ b/tests/template/templates/lang.html
@@ -1,3 +1,5 @@
{L_VARIABLE}
+{L_1_VARIABLE}
{LA_VARIABLE}
+{LA_1_VARIABLE}
diff --git a/tests/template/templates/loop_nested_deep_multilevel_ref.html b/tests/template/templates/loop_nested_deep_multilevel_ref.html
index 60fad7b4cd..bcc2a7c07b 100644
--- a/tests/template/templates/loop_nested_deep_multilevel_ref.html
+++ b/tests/template/templates/loop_nested_deep_multilevel_ref.html
@@ -2,10 +2,11 @@ top-level content
<!-- BEGIN outer -->
outer
<!-- BEGIN middle -->
+ {outer.middle.S_BLOCK_NAME}
<!-- BEGIN inner -->
inner {inner.VARIABLE}
<!-- IF outer.middle.inner.S_FIRST_ROW -->
- first row
+ first row of {outer.middle.inner.S_NUM_ROWS} in {middle.inner.S_BLOCK_NAME}
<!-- ENDIF -->
<!-- END inner -->
<!-- END middle -->
diff --git a/tests/utf/normalizer_test.php b/tests/utf/normalizer_test.php
index a0ba470416..f8f2467082 100644
--- a/tests/utf/normalizer_test.php
+++ b/tests/utf/normalizer_test.php
@@ -102,7 +102,7 @@ class phpbb_utf_normalizer_test extends phpbb_test_case
foreach ($tests as $test)
{
$utf_result = $utf_expected;
- call_user_func(array('utf_normalizer', $form), &$utf_result);
+ call_user_func(array('utf_normalizer', $form), $utf_result);
$hex_result = $this->utf_to_hexseq($utf_result);
$this->assertEquals($utf_expected, $utf_result, "$expected == $form($test) ($hex_expected != $hex_result)");
@@ -154,7 +154,7 @@ class phpbb_utf_normalizer_test extends phpbb_test_case
foreach (array('nfc', 'nfkc', 'nfd', 'nfkd') as $form)
{
$utf_result = $utf_expected;
- call_user_func(array('utf_normalizer', $form), &$utf_result);
+ call_user_func(array('utf_normalizer', $form), $utf_result);
$hex_result = $this->utf_to_hexseq($utf_result);
$this->assertEquals($utf_expected, $utf_result, "$hex_expected == $form($hex_tested) ($hex_expected != $hex_result)");