- some bugfixes

- allow template variables in defines


git-svn-id: file:///svn/phpbb/trunk@5238 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2005-10-02 17:49:16 +00:00
parent 2aad9c15cc
commit 83b43444a2

View file

@ -3,7 +3,7 @@
* *
* @package phpBB3 * @package phpBB3
* @version $Id$ * @version $Id$
* @copyright (c) 2005 phpBB Group * @copyright (c) 2005 phpBB Group, sections (c) 2001 ispi of Lincoln Inc
* @license http://opensource.org/licenses/gpl-license.php GNU Public License * @license http://opensource.org/licenses/gpl-license.php GNU Public License
* *
*/ */
@ -13,8 +13,6 @@
* *
* Template class. * Template class.
* *
* Nathan Codding - Original version design and implementation
* Crimsonbane - Initial caching proposal and work
* psoTFX - Completion of file caching, decompilation routines and implementation of * psoTFX - Completion of file caching, decompilation routines and implementation of
* conditionals/keywords and associated changes * conditionals/keywords and associated changes
* *
@ -455,6 +453,11 @@ class template
{ {
global $config; global $config;
if ($echo_var)
{
global $$echo_var;
}
// Remove any "loose" php ... we want to give admins the ability // Remove any "loose" php ... we want to give admins the ability
// to switch on/off PHP for a given template. Allowing unchecked // to switch on/off PHP for a given template. Allowing unchecked
// php is a no-no. There is a potential issue here in that non-php // php is a no-no. There is a potential issue here in that non-php
@ -487,6 +490,11 @@ class template
for ($curr_tb = 0, $tb_size = sizeof($text_blocks); $curr_tb < $tb_size; $curr_tb++) for ($curr_tb = 0, $tb_size = sizeof($text_blocks); $curr_tb < $tb_size; $curr_tb++)
{ {
if (!isset($blocks[1][$curr_tb]))
{
$blocks[1][$curr_tb] = '';
}
switch ($blocks[1][$curr_tb]) switch ($blocks[1][$curr_tb])
{ {
case 'BEGIN': case 'BEGIN':
@ -824,7 +832,13 @@ class template
// Are we a string? // Are we a string?
if ($match[5] && $match[7]) if ($match[5] && $match[7])
{ {
$match[6] = "'" . addslashes(str_replace(array('\\\'', '\\\\'), array('\'', '\\'), $match[6])) . "'"; $match[6] = addslashes(str_replace(array('\\\'', '\\\\'), array('\'', '\\'), $match[6]));
// Compile reference, we allow template variables in defines...
$match[6] = $this->compile($match[6]);
// Now replace the php code
$match[6] = "'" . str_replace(array('<?php echo ', '; ?>'), array("' . ", " . '"), $match[6]) . "'";
} }
else else
{ {
@ -935,7 +949,7 @@ class template
function generate_block_varref($namespace, $varname, $echo = true, $defop = false) function generate_block_varref($namespace, $varname, $echo = true, $defop = false)
{ {
// Strip the trailing period. // Strip the trailing period.
$namespace = substr($namespace, 0, strlen($namespace) - 1); $namespace = substr($namespace, 0, -1);
// Get a reference to the data block for this namespace. // Get a reference to the data block for this namespace.
$varref = $this->generate_block_data_ref($namespace, true, $defop); $varref = $this->generate_block_data_ref($namespace, true, $defop);