Blame Extras/phpBB/3.0.4/includes/template.php

4c79b5
4c79b5
/**
4c79b5
*
4c79b5
* @package phpBB3
4c79b5
* @version $Id: template.php 8943 2008-09-26 13:09:56Z acydburn $
4c79b5
* @copyright (c) 2005 phpBB Group, sections (c) 2001 ispi of Lincoln Inc
4c79b5
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
4c79b5
*
4c79b5
*/
4c79b5
4c79b5
/**
4c79b5
* @ignore
4c79b5
*/
4c79b5
if (!defined('IN_PHPBB'))
4c79b5
{
4c79b5
	exit;
4c79b5
}
4c79b5
4c79b5
/**
4c79b5
* Base Template class.
4c79b5
* @package phpBB3
4c79b5
*/
4c79b5
class template
4c79b5
{
4c79b5
	/** variable that holds all the data we'll be substituting into
4c79b5
	* the compiled templates. Takes form:
4c79b5
	* --> $this->_tpldata[block][iteration#][child][iteration#][child2][iteration#][variablename] == value
4c79b5
	* if it's a root-level variable, it'll be like this:
4c79b5
	* --> $this->_tpldata[.][0][varname] == value
4c79b5
	*/
4c79b5
	var $_tpldata = array('.' => array(0 => array()));
4c79b5
	var $_rootref;
4c79b5
4c79b5
	// Root dir and hash of filenames for each template handle.
4c79b5
	var $root = '';
4c79b5
	var $cachepath = '';
4c79b5
	var $files = array();
4c79b5
	var $filename = array();
4c79b5
	var $files_inherit = array();
4c79b5
	var $files_template = array();
4c79b5
	var $inherit_root = '';
4c79b5
4c79b5
	// this will hash handle names to the compiled/uncompiled code for that handle.
4c79b5
	var $compiled_code = array();
4c79b5
4c79b5
	/**
4c79b5
	* Set template location
4c79b5
	* @access public
4c79b5
	*/
4c79b5
	function set_template()
4c79b5
	{
4c79b5
		global $phpbb_root_path, $user;
4c79b5
4c79b5
		if (file_exists($phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/template'))
4c79b5
		{
4c79b5
			$this->root = $phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/template';
4c79b5
			$this->cachepath = $phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $user->theme['template_path']) . '_';
4c79b5
			
4c79b5
			if ($user->theme['template_inherits_id'])
4c79b5
			{
4c79b5
				$this->inherit_root = $phpbb_root_path . 'styles/' . $user->theme['template_inherit_path'] . '/template';
4c79b5
			}
4c79b5
		}
4c79b5
		else
4c79b5
		{
4c79b5
			trigger_error('Template path could not be found: styles/' . $user->theme['template_path'] . '/template', E_USER_ERROR);
4c79b5
		}
4c79b5
4c79b5
		$this->_rootref = &$this->_tpldata['.'][0];
4c79b5
4c79b5
		return true;
4c79b5
	}
4c79b5
4c79b5
	/**
4c79b5
	* Set custom template location (able to use directory outside of phpBB)
4c79b5
	* @access public
4c79b5
	*/
4c79b5
	function set_custom_template($template_path, $template_name)
4c79b5
	{
4c79b5
		global $phpbb_root_path;
4c79b5
4c79b5
		$this->root = $template_path;
4c79b5
		$this->cachepath = $phpbb_root_path . 'cache/ctpl_' . str_replace('_', '-', $template_name) . '_';
4c79b5
4c79b5
		return true;
4c79b5
	}
4c79b5
4c79b5
	/**
4c79b5
	* Sets the template filenames for handles. $filename_array
4c79b5
	* should be a hash of handle => filename pairs.
4c79b5
	* @access public
4c79b5
	*/
4c79b5
	function set_filenames($filename_array)
4c79b5
	{
4c79b5
		if (!is_array($filename_array))
4c79b5
		{
4c79b5
			return false;
4c79b5
		}
4c79b5
		foreach ($filename_array as $handle => $filename)
4c79b5
		{
4c79b5
			if (empty($filename))
4c79b5
			{
4c79b5
				trigger_error("template->set_filenames: Empty filename specified for $handle", E_USER_ERROR);
4c79b5
			}
4c79b5
4c79b5
			$this->filename[$handle] = $filename;
4c79b5
			$this->files[$handle] = $this->root . '/' . $filename;
4c79b5
			
4c79b5
			if ($this->inherit_root)
4c79b5
			{
4c79b5
				$this->files_inherit[$handle] = $this->inherit_root . '/' . $filename;
4c79b5
			}
4c79b5
		}
4c79b5
		
4c79b5
		return true;
4c79b5
	}
4c79b5
4c79b5
	/**
4c79b5
	* Destroy template data set
4c79b5
	* @access public
4c79b5
	*/
4c79b5
	function destroy()
4c79b5
	{
4c79b5
		$this->_tpldata = array('.' => array(0 => array()));
4c79b5
	}
4c79b5
4c79b5
	/**
4c79b5
	* Reset/empty complete block
4c79b5
	* @access public
4c79b5
	*/
4c79b5
	function destroy_block_vars($blockname)
4c79b5
	{
4c79b5
		if (strpos($blockname, '.') !== false)
4c79b5
		{
4c79b5
			// Nested block.
4c79b5
			$blocks = explode('.', $blockname);
4c79b5
			$blockcount = sizeof($blocks) - 1;
4c79b5
4c79b5
			$str = &$this->_tpldata;
4c79b5
			for ($i = 0; $i < $blockcount; $i++)
4c79b5
			{
4c79b5
				$str = &$str[$blocks[$i]];
4c79b5
				$str = &$str[sizeof($str) - 1];
4c79b5
			}
4c79b5
4c79b5
			unset($str[$blocks[$blockcount]]);
4c79b5
		}
4c79b5
		else
4c79b5
		{
4c79b5
			// Top-level block.
4c79b5
			unset($this->_tpldata[$blockname]);
4c79b5
		}
4c79b5
4c79b5
		return true;
4c79b5
	}
4c79b5
4c79b5
	/**
4c79b5
	* Display handle
4c79b5
	* @access public
4c79b5
	*/
4c79b5
	function display($handle, $include_once = true)
4c79b5
	{
4c79b5
		global $user, $phpbb_hook;
4c79b5
4c79b5
		if (!empty($phpbb_hook) && $phpbb_hook->call_hook(array(__CLASS__, __FUNCTION__), $handle, $include_once))
4c79b5
		{
4c79b5
			if ($phpbb_hook->hook_return(array(__CLASS__, __FUNCTION__)))
4c79b5
			{
4c79b5
				return $phpbb_hook->hook_return_result(array(__CLASS__, __FUNCTION__));
4c79b5
			}
4c79b5
		}
4c79b5
4c79b5
		if (defined('IN_ERROR_HANDLER'))
4c79b5
		{
4c79b5
			if ((E_NOTICE & error_reporting()) == E_NOTICE)
4c79b5
			{
4c79b5
				error_reporting(error_reporting() ^ E_NOTICE);
4c79b5
			}
4c79b5
		}
4c79b5
4c79b5
		if ($filename = $this->_tpl_load($handle))
4c79b5
		{
4c79b5
			($include_once) ? include_once($filename) : include($filename);
4c79b5
		}
4c79b5
		else
4c79b5
		{
4c79b5
			eval(' ?>' . $this->compiled_code[$handle] . '
4c79b5
		}
4c79b5
4c79b5
		return true;
4c79b5
	}
4c79b5
4c79b5
	/**
4c79b5
	* Display the handle and assign the output to a template variable or return the compiled result.
4c79b5
	* @access public
4c79b5
	*/
4c79b5
	function assign_display($handle, $template_var = '', $return_content = true, $include_once = false)
4c79b5
	{
4c79b5
		ob_start();
4c79b5
		$this->display($handle, $include_once);
4c79b5
		$contents = ob_get_clean();
4c79b5
4c79b5
		if ($return_content)
4c79b5
		{
4c79b5
			return $contents;
4c79b5
		}
4c79b5
4c79b5
		$this->assign_var($template_var, $contents);
4c79b5
4c79b5
		return true;
4c79b5
	}
4c79b5
	
4c79b5
	/**
4c79b5
	* Load a compiled template if possible, if not, recompile it
4c79b5
	* @access private
4c79b5
	*/
4c79b5
	function _tpl_load(&$handle)
4c79b5
	{
4c79b5
		global $user, $phpEx, $config;
4c79b5
4c79b5
		$filename = $this->cachepath . str_replace('/', '.', $this->filename[$handle]) . '.' . $phpEx;
4c79b5
		$this->files_template[$handle] = $user->theme['template_id'];
4c79b5
		
4c79b5
		$recompile = false;
4c79b5
		if (!file_exists($filename) || @filesize($filename) === 0)
4c79b5
		{
4c79b5
			$recompile = true;
4c79b5
		}
4c79b5
		else if ($config['load_tplcompile'])
4c79b5
		{
4c79b5
			// No way around it: we need to check inheritance here
4c79b5
			if ($user->theme['template_inherits_id'] && !file_exists($this->files[$handle]))
4c79b5
			{
4c79b5
				$this->files[$handle] = $this->files_inherit[$handle];
4c79b5
				$this->files_template[$handle] = $user->theme['template_inherits_id'];
4c79b5
			}
4c79b5
			$recompile = (@filemtime($filename) < filemtime($this->files[$handle])) ? true : false;
4c79b5
		}
4c79b5
		
4c79b5
		// Recompile page if the original template is newer, otherwise load the compiled version
4c79b5
		if (!$recompile)
4c79b5
		{
4c79b5
			return $filename;
4c79b5
		}
4c79b5
4c79b5
		global $db, $phpbb_root_path;
4c79b5
4c79b5
		if (!class_exists('template_compile'))
4c79b5
		{
4c79b5
			include($phpbb_root_path . 'includes/functions_template.' . $phpEx);
4c79b5
		}
4c79b5
		
4c79b5
		// Inheritance - we point to another template file for this one. Equality is also used for store_db
4c79b5
		if (isset($user->theme['template_inherits_id']) && $user->theme['template_inherits_id'] && !file_exists($this->files[$handle]))
4c79b5
		{
4c79b5
			$this->files[$handle] = $this->files_inherit[$handle];
4c79b5
			$this->files_template[$handle] = $user->theme['template_inherits_id'];
4c79b5
		}
4c79b5
		
4c79b5
		$compile = new template_compile($this);
4c79b5
4c79b5
		// If we don't have a file assigned to this handle, die.
4c79b5
		if (!isset($this->files[$handle]))
4c79b5
		{
4c79b5
			trigger_error("template->_tpl_load(): No file specified for handle $handle", E_USER_ERROR);
4c79b5
		}
4c79b5
4c79b5
		// Just compile if no user object is present (happens within the installer)
4c79b5
		if (!$user)
4c79b5
		{
4c79b5
			$compile->_tpl_load_file($handle);
4c79b5
			return false;
4c79b5
		}
4c79b5
4c79b5
		if (isset($user->theme['template_storedb']) && $user->theme['template_storedb'])
4c79b5
		{
4c79b5
			$rows = array();
4c79b5
			$ids = array();
4c79b5
			// Inheritance
4c79b5
			if (isset($user->theme['template_inherits_id']) && $user->theme['template_inherits_id'])
4c79b5
			{
4c79b5
				$ids[] = $user->theme['template_inherits_id'];
4c79b5
			}
4c79b5
			$ids[] = $user->theme['template_id'];
4c79b5
			
4c79b5
			foreach ($ids as $id)
4c79b5
			{
4c79b5
				$sql = 'SELECT *
4c79b5
				FROM ' . STYLES_TEMPLATE_DATA_TABLE . '
4c79b5
				WHERE template_id = ' . $id . "
4c79b5
					AND (template_filename = '" . $db->sql_escape($this->filename[$handle]) . "'
4c79b5
						OR template_included " . $db->sql_like_expression($db->any_char . $this->filename[$handle] . ':' . $db->any_char) . ')';
4c79b5
			
4c79b5
				$result = $db->sql_query($sql);
4c79b5
				while ($row = $db->sql_fetchrow($result))
4c79b5
				{
4c79b5
					$rows[$row['template_filename']] = $row;
4c79b5
				}
4c79b5
				$db->sql_freeresult($result);
4c79b5
			}
4c79b5
					
4c79b5
			if (sizeof($rows))
4c79b5
			{
4c79b5
				foreach ($rows as $row)
4c79b5
				{
4c79b5
					$file = $this->root . '/' . $row['template_filename'];
4c79b5
					$force_reload = false;
4c79b5
					if ($row['template_id'] != $user->theme['template_id'])
4c79b5
					{
4c79b5
						// make sure that we are not overlooking a file not in the db yet
4c79b5
						if (isset($user->theme['template_inherits_id']) && $user->theme['template_inherits_id'] && !file_exists($file))
4c79b5
						{
4c79b5
							$file = $this->inherit_root . '/' . $row['template_filename'];
4c79b5
							$this->files[$row['template_filename']] = $file;
4c79b5
							$this->files_inherit[$row['template_filename']] = $file;
4c79b5
							$this->files_template[$row['template_filename']] = $user->theme['template_inherits_id'];
4c79b5
						}
4c79b5
						else if (isset($user->theme['template_inherits_id']) && $user->theme['template_inherits_id'])
4c79b5
						{
4c79b5
							// Ok, we have a situation. There is a file in the subtemplate, but nothing in the DB. We have to fix that.
4c79b5
							$force_reload = true;
4c79b5
							$this->files_template[$row['template_filename']] = $user->theme['template_inherits_id'];
4c79b5
						}
4c79b5
					}
4c79b5
					else
4c79b5
					{
4c79b5
						$this->files_template[$row['template_filename']] = $user->theme['template_id'];
4c79b5
					}
4c79b5
					
4c79b5
					if ($force_reload || $row['template_mtime'] < filemtime($file))
4c79b5
					{
4c79b5
						if ($row['template_filename'] == $this->filename[$handle])
4c79b5
						{
4c79b5
							$compile->_tpl_load_file($handle, true);
4c79b5
						}
4c79b5
						else
4c79b5
						{
4c79b5
							$this->files[$row['template_filename']] = $file;
4c79b5
							$this->filename[$row['template_filename']] = $row['template_filename'];
4c79b5
							$compile->_tpl_load_file($row['template_filename'], true);
4c79b5
							unset($this->compiled_code[$row['template_filename']]);
4c79b5
							unset($this->files[$row['template_filename']]);
4c79b5
							unset($this->filename[$row['template_filename']]);
4c79b5
						}
4c79b5
					}
4c79b5
4c79b5
					if ($row['template_filename'] == $this->filename[$handle])
4c79b5
					{
4c79b5
						$this->compiled_code[$handle] = $compile->compile(trim($row['template_data']));
4c79b5
						$compile->compile_write($handle, $this->compiled_code[$handle]);
4c79b5
					}
4c79b5
					else
4c79b5
					{
4c79b5
						// Only bother compiling if it doesn't already exist
4c79b5
						if (!file_exists($this->cachepath . str_replace('/', '.', $row['template_filename']) . '.' . $phpEx))
4c79b5
						{
4c79b5
							$this->filename[$row['template_filename']] = $row['template_filename'];
4c79b5
							$compile->compile_write($row['template_filename'], $compile->compile(trim($row['template_data'])));
4c79b5
							unset($this->filename[$row['template_filename']]);
4c79b5
						}
4c79b5
					}
4c79b5
				}
4c79b5
			}
4c79b5
			else
4c79b5
			{
4c79b5
				$file = $this->root . '/' . $row['template_filename'];
4c79b5
4c79b5
				if (isset($user->theme['template_inherits_id']) && $user->theme['template_inherits_id'] && !file_exists($file))
4c79b5
				{
4c79b5
					$file = $this->inherit_root . '/' . $row['template_filename'];
4c79b5
					$this->files[$row['template_filename']] = $file;
4c79b5
					$this->files_inherit[$row['template_filename']] = $file;
4c79b5
					$this->files_template[$row['template_filename']] = $user->theme['template_inherits_id'];
4c79b5
				}
4c79b5
				// Try to load from filesystem and instruct to insert into the styles table...
4c79b5
				$compile->_tpl_load_file($handle, true);
4c79b5
				return false;
4c79b5
			}
4c79b5
4c79b5
			return false;
4c79b5
		}
4c79b5
4c79b5
		$compile->_tpl_load_file($handle);
4c79b5
		return false;
4c79b5
	}
4c79b5
4c79b5
	/**
4c79b5
	* Assign key variable pairs from an array
4c79b5
	* @access public
4c79b5
	*/
4c79b5
	function assign_vars($vararray)
4c79b5
	{
4c79b5
		foreach ($vararray as $key => $val)
4c79b5
		{
4c79b5
			$this->_rootref[$key] = $val;
4c79b5
		}
4c79b5
4c79b5
		return true;
4c79b5
	}
4c79b5
4c79b5
	/**
4c79b5
	* Assign a single variable to a single key
4c79b5
	* @access public
4c79b5
	*/
4c79b5
	function assign_var($varname, $varval)
4c79b5
	{
4c79b5
		$this->_rootref[$varname] = $varval;
4c79b5
4c79b5
		return true;
4c79b5
	}
4c79b5
4c79b5
	/**
4c79b5
	* Assign key variable pairs from an array to a specified block
4c79b5
	* @access public
4c79b5
	*/
4c79b5
	function assign_block_vars($blockname, $vararray)
4c79b5
	{
4c79b5
		if (strpos($blockname, '.') !== false)
4c79b5
		{
4c79b5
			// Nested block.
4c79b5
			$blocks = explode('.', $blockname);
4c79b5
			$blockcount = sizeof($blocks) - 1;
4c79b5
4c79b5
			$str = &$this->_tpldata;
4c79b5
			for ($i = 0; $i < $blockcount; $i++)
4c79b5
			{
4c79b5
				$str = &$str[$blocks[$i]];
4c79b5
				$str = &$str[sizeof($str) - 1];
4c79b5
			}
4c79b5
4c79b5
			$s_row_count = isset($str[$blocks[$blockcount]]) ? sizeof($str[$blocks[$blockcount]]) : 0;
4c79b5
			$vararray['S_ROW_COUNT'] = $s_row_count;
4c79b5
4c79b5
			// Assign S_FIRST_ROW
4c79b5
			if (!$s_row_count)
4c79b5
			{
4c79b5
				$vararray['S_FIRST_ROW'] = true;
4c79b5
			}
4c79b5
4c79b5
			// Now the tricky part, we always assign S_LAST_ROW and remove the entry before
4c79b5
			// This is much more clever than going through the complete template data on display (phew)
4c79b5
			$vararray['S_LAST_ROW'] = true;
4c79b5
			if ($s_row_count > 0)
4c79b5
			{
4c79b5
				unset($str[$blocks[$blockcount]][($s_row_count - 1)]['S_LAST_ROW']);
4c79b5
			}
4c79b5
4c79b5
			// Now we add the block that we're actually assigning to.
4c79b5
			// We're adding a new iteration to this block with the given
4c79b5
			// variable assignments.
4c79b5
			$str[$blocks[$blockcount]][] = $vararray;
4c79b5
		}
4c79b5
		else
4c79b5
		{
4c79b5
			// Top-level block.
4c79b5
			$s_row_count = (isset($this->_tpldata[$blockname])) ? sizeof($this->_tpldata[$blockname]) : 0;
4c79b5
			$vararray['S_ROW_COUNT'] = $s_row_count;
4c79b5
4c79b5
			// Assign S_FIRST_ROW
4c79b5
			if (!$s_row_count)
4c79b5
			{
4c79b5
				$vararray['S_FIRST_ROW'] = true;
4c79b5
			}
4c79b5
4c79b5
			// We always assign S_LAST_ROW and remove the entry before
4c79b5
			$vararray['S_LAST_ROW'] = true;
4c79b5
			if ($s_row_count > 0)
4c79b5
			{
4c79b5
				unset($this->_tpldata[$blockname][($s_row_count - 1)]['S_LAST_ROW']);
4c79b5
			}
4c79b5
			
4c79b5
			// Add a new iteration to this block with the variable assignments we were given.
4c79b5
			$this->_tpldata[$blockname][] = $vararray;
4c79b5
		}
4c79b5
4c79b5
		return true;
4c79b5
	}
4c79b5
4c79b5
	/**
4c79b5
	* Change already assigned key variable pair (one-dimensional - single loop entry)
4c79b5
	*
4c79b5
	* An example of how to use this function:
4c79b5
	* {@example alter_block_array.php}
4c79b5
	*
4c79b5
	* @param	string	$blockname	the blockname, for example 'loop'
4c79b5
	* @param	array	$vararray	the var array to insert/add or merge
4c79b5
	* @param	mixed	$key		Key to search for
4c79b5
	*
4c79b5
	* array: KEY => VALUE [the key/value pair to search for within the loop to determine the correct position]
4c79b5
	*
4c79b5
	* int: Position [the position to change or insert at directly given]
4c79b5
	*
4c79b5
	* If key is false the position is set to 0
4c79b5
	* If key is true the position is set to the last entry
4c79b5
	*
4c79b5
	* @param	string	$mode		Mode to execute (valid modes are 'insert' and 'change')
4c79b5
	*
4c79b5
	*	If insert, the vararray is inserted at the given position (position counting from zero).
4c79b5
	*	If change, the current block gets merged with the vararray (resulting in new key/value pairs be added and existing keys be replaced by the new value).
4c79b5
	*
4c79b5
	* Since counting begins by zero, inserting at the last position will result in this array: array(vararray, last positioned array)
4c79b5
	* and inserting at position 1 will result in this array: array(first positioned array, vararray, following vars)
4c79b5
	*
4c79b5
	* @return bool false on error, true on success
4c79b5
	* @access public
4c79b5
	*/
4c79b5
	function alter_block_array($blockname, $vararray, $key = false, $mode = 'insert')
4c79b5
	{
4c79b5
		if (strpos($blockname, '.') !== false)
4c79b5
		{
4c79b5
			// Nested blocks are not supported
4c79b5
			return false;
4c79b5
		}
4c79b5
		
4c79b5
		// Change key to zero (change first position) if false and to last position if true
4c79b5
		if ($key === false || $key === true)
4c79b5
		{
4c79b5
			$key = ($key === false) ? 0 : sizeof($this->_tpldata[$blockname]);
4c79b5
		}
4c79b5
4c79b5
		// Get correct position if array given
4c79b5
		if (is_array($key))
4c79b5
		{
4c79b5
			// Search array to get correct position
4c79b5
			list($search_key, $search_value) = @each($key);
4c79b5
4c79b5
			$key = NULL;
4c79b5
			foreach ($this->_tpldata[$blockname] as $i => $val_ary)
4c79b5
			{
4c79b5
				if ($val_ary[$search_key] === $search_value)
4c79b5
				{
4c79b5
					$key = $i;
4c79b5
					break;
4c79b5
				}
4c79b5
			}
4c79b5
4c79b5
			// key/value pair not found
4c79b5
			if ($key === NULL)
4c79b5
			{
4c79b5
				return false;
4c79b5
			}
4c79b5
		}
4c79b5
4c79b5
		// Insert Block
4c79b5
		if ($mode == 'insert')
4c79b5
		{
4c79b5
			// Make sure we are not exceeding the last iteration
4c79b5
			if ($key >= sizeof($this->_tpldata[$blockname]))
4c79b5
			{
4c79b5
				$key = sizeof($this->_tpldata[$blockname]);
4c79b5
				unset($this->_tpldata[$blockname][($key - 1)]['S_LAST_ROW']);
4c79b5
				$vararray['S_LAST_ROW'] = true;
4c79b5
			}
4c79b5
			else if ($key === 0)
4c79b5
			{
4c79b5
				unset($this->_tpldata[$blockname][0]['S_FIRST_ROW']);
4c79b5
				$vararray['S_FIRST_ROW'] = true;
4c79b5
			}
4c79b5
4c79b5
			// Re-position template blocks
4c79b5
			for ($i = sizeof($this->_tpldata[$blockname]); $i > $key; $i--)
4c79b5
			{
4c79b5
				$this->_tpldata[$blockname][$i] = $this->_tpldata[$blockname][$i-1];
4c79b5
				$this->_tpldata[$blockname][$i]['S_ROW_COUNT'] = $i;
4c79b5
			}
4c79b5
4c79b5
			// Insert vararray at given position
4c79b5
			$vararray['S_ROW_COUNT'] = $key;
4c79b5
			$this->_tpldata[$blockname][$key] = $vararray;
4c79b5
4c79b5
			return true;
4c79b5
		}
4c79b5
4c79b5
		// Which block to change?
4c79b5
		if ($mode == 'change')
4c79b5
		{
4c79b5
			if ($key == sizeof($this->_tpldata[$blockname]))
4c79b5
			{
4c79b5
				$key--;
4c79b5
			}
4c79b5
4c79b5
			$this->_tpldata[$blockname][$key] = array_merge($this->_tpldata[$blockname][$key], $vararray);
4c79b5
			return true;
4c79b5
		}
4c79b5
4c79b5
		return false;
4c79b5
	}
4c79b5
4c79b5
	/**
4c79b5
	* Include a separate template
4c79b5
	* @access private
4c79b5
	*/
4c79b5
	function _tpl_include($filename, $include = true)
4c79b5
	{
4c79b5
		$handle = $filename;
4c79b5
		$this->filename[$handle] = $filename;
4c79b5
		$this->files[$handle] = $this->root . '/' . $filename;
4c79b5
		if ($this->inherit_root)
4c79b5
		{
4c79b5
			$this->files_inherit[$handle] = $this->inherit_root . '/' . $filename;
4c79b5
		}
4c79b5
4c79b5
		$filename = $this->_tpl_load($handle);
4c79b5
4c79b5
		if ($include)
4c79b5
		{
4c79b5
			global $user;
4c79b5
4c79b5
			if ($filename)
4c79b5
			{
4c79b5
				include($filename);
4c79b5
				return;
4c79b5
			}
4c79b5
			eval(' ?>' . $this->compiled_code[$handle] . '
4c79b5
		}
4c79b5
	}
4c79b5
}
4c79b5
4c79b5
?>