diff options
Diffstat (limited to 'phpBB/includes')
| -rw-r--r-- | phpBB/includes/classes/template.php | 6 | ||||
| -rw-r--r-- | phpBB/includes/classes/template_compile.php | 41 | ||||
| -rw-r--r-- | phpBB/includes/functions.php | 6 |
3 files changed, 30 insertions, 23 deletions
diff --git a/phpBB/includes/classes/template.php b/phpBB/includes/classes/template.php index 167f33f3e8..f574f4d9fb 100644 --- a/phpBB/includes/classes/template.php +++ b/phpBB/includes/classes/template.php @@ -180,9 +180,6 @@ class phpbb_template $_rootref = &$this->_rootref; $_lang = &phpbb::$user->lang; - // These _are_ used the included files. - $_tpldata; $_rootref; $_lang; - if (($filename = $this->_tpl_load($handle)) !== false) { ($include_once) ? include_once($filename) : include($filename); @@ -497,9 +494,6 @@ class phpbb_template $_rootref = &$this->_rootref; $_lang = &phpbb::$user->lang; - // These _are_ used the included files. - $_tpldata; $_rootref; $_lang; - if ($filename) { include($filename); diff --git a/phpBB/includes/classes/template_compile.php b/phpBB/includes/classes/template_compile.php index b8fc662208..a5ead08b35 100644 --- a/phpBB/includes/classes/template_compile.php +++ b/phpBB/includes/classes/template_compile.php @@ -17,11 +17,10 @@ if (!defined('IN_PHPBB')) } /** - * The template filter that does the actual compilation - * @see template_compile - * @package phpBB3 - * - */ +* The template filter that does the actual compilation +* @see template_compile +* @package phpBB3 +*/ class phpbb_template_filter extends php_user_filter { /** @@ -184,25 +183,33 @@ class phpbb_template_filter extends php_user_filter $text_blocks = str_replace($var_val[0], $new, $text_blocks); } + // Handle special language tags L_ and LA_ + $this->compile_language_tags($text_blocks); + // This will handle the remaining root-level varrefs + $text_blocks = preg_replace('#\{([a-z0-9\-_]*)\}#is', "<?php echo (isset(\$_rootref['\\1'])) ? \$_rootref['\\1'] : ''; ?>", $text_blocks); + $text_blocks = preg_replace('#\{\$([a-z0-9\-_]*)\}#is', "<?php echo (isset(\$_tpldata['DEFINE']['.']['\\1'])) ? \$_tpldata['DEFINE']['.']['\\1'] : ''; ?>", $text_blocks); + + return $text_blocks; + } + + /** + * Handlse special language tags L_ and LA_ + */ + private function compile_language_tags(&$text_blocks) + { // 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_([a-z0-9\-_]*)\}#is', "<?php echo ((isset(\$_rootref['L_\\1'])) ? \$_rootref['L_\\1'] : ((isset(\$_lang['\\1'])) ? \$_lang['\\1'] : '{ \\1 }')); ?>", $text_blocks); + $text_blocks = preg_replace('#\{L_([a-z0-9\-_]*)\}#is', "<?php echo (isset(\$_rootref['L_\\1'])) ? \$_rootref['L_\\1'] : (isset(\$_lang['\\1']) ? \$_lang['\\1'] : '{ \\1 }'); ?>", $text_blocks); } // Handle addslashed language variables prefixed with LA_ // 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_([a-z0-9\-_]*)\}#is', "<?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); + $text_blocks = preg_replace('#\{LA_([a-z0-9\-_]*)\}#is', "<?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); } - - // Handle remaining varrefs - $text_blocks = preg_replace('#\{([a-z0-9\-_]*)\}#is', "<?php echo (isset(\$_rootref['\\1'])) ? \$_rootref['\\1'] : ''; ?>", $text_blocks); - $text_blocks = preg_replace('#\{\$([a-z0-9\-_]*)\}#is', "<?php echo (isset(\$_tpldata['DEFINE']['.']['\\1'])) ? \$_tpldata['DEFINE']['.']['\\1'] : ''; ?>", $text_blocks); - - return $text_blocks; } /** @@ -508,7 +515,13 @@ class phpbb_template_filter extends php_user_filter private function compile_tag_if($tag_args, $elseif) { $tokens = $this->compile_expression($tag_args); - return (($elseif) ? '} else if (' : 'if (') . (implode(' ', $tokens) . ') { '); + + // @todo We suppress notices within IF statements until we find a way to correctly check them + $tpl = ($elseif) ? '} else if (@(' : 'if (@('; + $tpl .= implode(' ', $tokens); + $tpl .= ')) { '; + + return $tpl; } /** diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 9ca0424791..0b9b714c14 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2575,7 +2575,7 @@ function page_header($page_title = '', $display_online_list = true) 'T_ICONS_PATH' => PHPBB_ROOT_PATH . phpbb::$config['icons_path'] . '/', 'T_RANKS_PATH' => PHPBB_ROOT_PATH . phpbb::$config['ranks_path'] . '/', 'T_UPLOAD_PATH' => PHPBB_ROOT_PATH . phpbb::$config['upload_path'] . '/', - 'T_STYLESHEET_LINK' => (!phpbb::$user->theme['theme_storedb']) ? PHPBB_ROOT_PATH . 'styles/' . phpbb::$user->theme['theme_path'] . '/theme/stylesheet.css' : phpbb::$url->get(PHPBB_ROOT_PATH . 'style.' . PHP_EXT . '?sid=' . phpbb::$user->session_id . '&id=' . phpbb::$user->theme['style_id'] . '&lang=' . phpbb::$user->data['user_lang']), //PHPBB_ROOT_PATH . "store/{$user->theme['theme_id']}_{$user->theme['imageset_id']}_{$user->lang_name}.css" + 'T_STYLESHEET_LINK' => (!phpbb::$user->theme['theme_storedb']) ? PHPBB_ROOT_PATH . 'styles/' . phpbb::$user->theme['theme_path'] . '/theme/stylesheet.css' : phpbb::$url->get(PHPBB_ROOT_PATH . 'style.' . PHP_EXT . '?id=' . phpbb::$user->theme['style_id'] . '&lang=' . phpbb::$user->data['user_lang']), //PHPBB_ROOT_PATH . "store/{$user->theme['theme_id']}_{$user->theme['imageset_id']}_{$user->lang_name}.css" 'T_STYLESHEET_NAME' => phpbb::$user->theme['theme_name'], 'SITE_LOGO_IMG' => phpbb::$user->img('site_logo'), @@ -2712,9 +2712,9 @@ function garbage_collection() function exit_handler() { // needs to be run prior to the hook - if (request::super_globals_disabled()) + if (phpbb_request::super_globals_disabled()) { - request::enable_super_globals(); + phpbb_request::enable_super_globals(); } // As a pre-caution... some setups display a blank page if the flush() is not there. |
