mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-16 15:08:54 +00:00
hhmmm, was slap bang in the middle of working on this ;) Excess slashing(?) .. keep an eye out for errors ... fixed static lang preg
git-svn-id: file:///svn/phpbb/trunk@3933 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
444b49c50a
commit
13f7d92739
1 changed files with 10 additions and 6 deletions
|
@ -271,6 +271,11 @@ class Template
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
// Remove any "loose" php ... we want to give admins the ability
|
||||||
|
// to switch on/off PHP for a given template. Allowing unchecked
|
||||||
|
// php is a no-no
|
||||||
|
$code = preg_replace('#\<\?php(.*?)\?\>#is', '', $code);
|
||||||
|
|
||||||
// Pull out all block/statement level elements and seperate
|
// Pull out all block/statement level elements and seperate
|
||||||
// plain text
|
// plain text
|
||||||
preg_match_all('#<!-- PHP -->(.*?)<!-- ENDPHP -->#s', $code, $matches);
|
preg_match_all('#<!-- PHP -->(.*?)<!-- ENDPHP -->#s', $code, $matches);
|
||||||
|
@ -292,7 +297,6 @@ class Template
|
||||||
$this->compile_var_tags($text_blocks[$i]);
|
$this->compile_var_tags($text_blocks[$i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$compile_blocks = array();
|
$compile_blocks = array();
|
||||||
|
|
||||||
for ($curr_tb = 0; $curr_tb < count($text_blocks); $curr_tb++)
|
for ($curr_tb = 0; $curr_tb < count($text_blocks); $curr_tb++)
|
||||||
|
@ -371,9 +375,12 @@ class Template
|
||||||
$template_php .= (!$no_echo) ? ((!empty($trim_check_text)) ? $text_blocks[$i] : '') . ((!empty($compile_blocks[$i])) ? $compile_blocks[$i] : '') : ((!empty($trim_check_text)) ? $text_blocks[$i] : '') . ((!empty($compile_blocks[$i])) ? $compile_blocks[$i] : '');
|
$template_php .= (!$no_echo) ? ((!empty($trim_check_text)) ? $text_blocks[$i] : '') . ((!empty($compile_blocks[$i])) ? $compile_blocks[$i] : '') : ((!empty($trim_check_text)) ? $text_blocks[$i] : '') . ((!empty($compile_blocks[$i])) ? $compile_blocks[$i] : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// There will be a number of occassions where we switch into and out of
|
||||||
|
// PHP mode instantaneously. Rather than "burden" the parser with this
|
||||||
|
// we'll strip out such occurences, minimising such switching
|
||||||
$template_php = str_replace(' ?><?php ', '', $template_php);
|
$template_php = str_replace(' ?><?php ', '', $template_php);
|
||||||
|
|
||||||
return (!$no_echo) ? str_replace("\\'", "'", $template_php) : "\$$echo_var .= '" . addslashes($template_php) . "'";
|
return (!$no_echo) ? $template_php : "\$$echo_var .= '" . $template_php . "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
function compile_var_tags(&$text_blocks)
|
function compile_var_tags(&$text_blocks)
|
||||||
|
@ -381,9 +388,6 @@ class Template
|
||||||
// change template varrefs into PHP varrefs
|
// change template varrefs into PHP varrefs
|
||||||
$varrefs = array();
|
$varrefs = array();
|
||||||
|
|
||||||
$text_blocks = str_replace('\\', '\\\\', $text_blocks);
|
|
||||||
$text_blocks = str_replace('\'', '\\\'', $text_blocks);
|
|
||||||
|
|
||||||
// This one will handle varrefs WITH namespaces
|
// This one will handle varrefs WITH namespaces
|
||||||
preg_match_all('#\{(([a-z0-9\-_]+?\.)+?)([a-z0-9\-_]+?)\}#is', $text_blocks, $varrefs);
|
preg_match_all('#\{(([a-z0-9\-_]+?\.)+?)([a-z0-9\-_]+?)\}#is', $text_blocks, $varrefs);
|
||||||
|
|
||||||
|
@ -405,7 +409,7 @@ class Template
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$text_blocks = preg_replace('#\{L_([A-Z0-9\-_]*?)\}#e', "<?php echo ((isset(\$this->_tpldata[\'.\'][0][\'L_\\1\'])) ? \$this->_tpldata[\'.\'][0][\'L_\\1\'] : \'' . ((isset(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '') . '\'); ?>'" , $text_blocks);
|
$text_blocks = preg_replace('#\{L_([A-Z0-9\-_]*?)\}#e', "'<?php echo ((isset(\$this->_tpldata[\'.\'][0][\'L_\\1\'])) ? \$this->_tpldata[\'.\'][0][\'L_\\1\'] : \'' . ((isset(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '') . '\'); ?>'" , $text_blocks);
|
||||||
}
|
}
|
||||||
$text_blocks = preg_replace('#\{([a-z0-9\-_]*?)\}#is', "<?php echo \$this->_tpldata['.'][0]['\\1']; ?>", $text_blocks);
|
$text_blocks = preg_replace('#\{([a-z0-9\-_]*?)\}#is', "<?php echo \$this->_tpldata['.'][0]['\\1']; ?>", $text_blocks);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue