diff options
Diffstat (limited to 'phpBB/includes/template')
-rw-r--r-- | phpBB/includes/template/filter.php | 24 | ||||
-rw-r--r-- | phpBB/includes/template/template.php | 27 |
2 files changed, 28 insertions, 23 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/phpBB/includes/template/template.php b/phpBB/includes/template/template.php index 0495ade9c5..ec5fbe2829 100644 --- a/phpBB/includes/template/template.php +++ b/phpBB/includes/template/template.php @@ -307,36 +307,31 @@ class phpbb_template */ private function _tpl_load($handle) { - $virtual_source_file = $this->locator->get_virtual_source_file_for_handle($handle); - $source_file = null; - - $compiled_path = $this->cachepath . str_replace('/', '.', $virtual_source_file) . '.' . $this->phpEx; + $output_file = $this->_compiled_file_for_handle($handle); $recompile = defined('DEBUG_EXTRA') || - !file_exists($compiled_path) || - @filesize($compiled_path) === 0 || - ($this->config['load_tplcompile'] && @filemtime($compiled_path) < @filemtime($source_file)); + !file_exists($output_file) || + @filesize($output_file) === 0; - if (!$recompile && $this->config['load_tplcompile']) + if ($recompile || $this->config['load_tplcompile']) { + // Set only if a recompile or an mtime check are required. $source_file = $this->locator->get_source_file_for_handle($handle); - $recompile = (@filemtime($compiled_path) < @filemtime($source_file)) ? true : false; + + if (!$recompile && @filemtime($output_file) < @filemtime($source_file)) + { + $recompile = true; + } } // Recompile page if the original template is newer, otherwise load the compiled version if (!$recompile) { - return new phpbb_template_renderer_include($compiled_path, $this); - } - - if ($source_file === null) - { - $source_file = $this->locator->get_source_file_for_handle($handle); + return new phpbb_template_renderer_include($output_file, $this); } $compile = new phpbb_template_compile($this->config['tpl_allow_php']); - $output_file = $this->_compiled_file_for_handle($handle); if ($compile->compile_file_to_file($source_file, $output_file) !== false) { $renderer = new phpbb_template_renderer_include($output_file, $this); |