diff options
| author | Fyorl <gaelreth@gmail.com> | 2012-07-08 15:12:08 +0100 |
|---|---|---|
| committer | Fyorl <gaelreth@gmail.com> | 2012-07-08 20:41:22 +0100 |
| commit | d0cb5bb093d09a15f422f84e19d781a8260512a0 (patch) | |
| tree | 897bd9ae227cc4c7891f30f8ec538e01e9f14fdd | |
| parent | d5896239068e1063970f398a12ffb5a0707fb286 (diff) | |
| download | forums-d0cb5bb093d09a15f422f84e19d781a8260512a0.tar forums-d0cb5bb093d09a15f422f84e19d781a8260512a0.tar.gz forums-d0cb5bb093d09a15f422f84e19d781a8260512a0.tar.bz2 forums-d0cb5bb093d09a15f422f84e19d781a8260512a0.tar.xz forums-d0cb5bb093d09a15f422f84e19d781a8260512a0.zip | |
[ticket/10970] Added support for forms such as {FOO}bar.{EXT}
PHPBB3-10970
| -rw-r--r-- | phpBB/includes/template/filter.php | 30 | ||||
| -rw-r--r-- | tests/template/template_includejs_test.php | 3 | ||||
| -rw-r--r-- | tests/template/templates/includejs.html | 1 |
3 files changed, 12 insertions, 22 deletions
diff --git a/phpBB/includes/template/filter.php b/phpBB/includes/template/filter.php index a8985a771c..568727be82 100644 --- a/phpBB/includes/template/filter.php +++ b/phpBB/includes/template/filter.php @@ -373,33 +373,21 @@ class phpbb_template_filter extends php_user_filter */ private function parse_dynamic_path($path, $include_type) { - $segments = explode('/', $path); - $is_expr = true; - $str = array(); - $vars = array(); + $matches = array(); + $replace = array(); - foreach ($segments as $segment) + preg_match_all('/{[^}]+}/', $path, $matches); + foreach ($matches[0] as $var_str) { - if ($segment[0] === '{') - { - $var = $this->get_varref($segment, $tmp_is_expr); - $is_expr = $is_expr && $tmp_is_expr; - $vars[] = "isset($var)"; - $str[] = "$var . '/'"; - } - else - { - $str[] = "'$segment/'"; - } + $var = $this->get_varref($var_str, $tmp_is_expr); + $is_expr = $is_expr && $tmp_is_expr; + $vars[] = "isset($var)"; + $replace[] = "' . $var . '"; } - // Remove trailing slash from last element - $last = array_pop($str); - $str[] = str_replace('/', '', $last); - if (!$is_expr) { - return ' if (' . implode(' && ', $vars) . ") { \$_template->$include_type(" . implode(' . ', $str) . ', true); }'; + return ' if (' . implode(' && ', $vars) . ") { \$_template->$include_type('" . str_replace($matches[0], $replace, $path) . "', true); }"; } else { diff --git a/tests/template/template_includejs_test.php b/tests/template/template_includejs_test.php index d8c7170e94..22b020208b 100644 --- a/tests/template/template_includejs_test.php +++ b/tests/template/template_includejs_test.php @@ -23,10 +23,11 @@ class phpbb_template_template_includejs_test extends phpbb_template_template_tes '<script src="' . $this->test_path . '/templates/child_only.js?assets_version=1"></script>', '<script src="' . $this->test_path . '/templates/subdir/parent_only.js?assets_version=1"></script>', '<script src="' . $this->test_path . '/templates/subdir/subsubdir/parent_only.js?assets_version=1"></script>', + '<script src="' . $this->test_path . '/templates/subdir/parent_only.js?assets_version=1"></script>', ); // Run test $cache_file = $this->template->cachepath . 'includejs.html.php'; - $this->run_template('includejs.html', array('PARENT' => 'parent_only.js', 'SUBDIR' => 'subdir'), array(), array(), implode('', $scripts), $cache_file); + $this->run_template('includejs.html', array('PARENT' => 'parent_only.js', 'SUBDIR' => 'subdir', 'EXT' => 'js'), array(), array(), implode('', $scripts), $cache_file); } } diff --git a/tests/template/templates/includejs.html b/tests/template/templates/includejs.html index dbcf6e04a8..ef73700eeb 100644 --- a/tests/template/templates/includejs.html +++ b/tests/template/templates/includejs.html @@ -4,4 +4,5 @@ <!-- INCLUDEJS {$TEST} --> <!-- INCLUDEJS subdir/{PARENT} --> <!-- INCLUDEJS {SUBDIR}/subsubdir/{PARENT} --> +<!-- INCLUDEJS {SUBDIR}/parent_only.{EXT} --> {SCRIPTS} |
