phpBB

Code Changes

File: includes/template.php

  Unmodified   Added   Modified   Removed
Line 39Line 39
	var $files_inherit = array();
var $files_template = array();
var $inherit_root = '';

	var $files_inherit = array();
var $files_template = array();
var $inherit_root = '';

 
	var $orig_tpl_storedb;
var $orig_tpl_inherits_id;


// this will hash handle names to the compiled/uncompiled code for that handle.
var $compiled_code = array();


// this will hash handle names to the compiled/uncompiled code for that handle.
var $compiled_code = array();

Line 55Line 57
		{
$this->root = $phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/template';
$this->cachepath = $phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $user->theme['template_path']) . '_';

		{
$this->root = $phpbb_root_path . 'styles/' . $user->theme['template_path'] . '/template';
$this->cachepath = $phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $user->theme['template_path']) . '_';

 

if ($this->orig_tpl_storedb === null)
{
$this->orig_tpl_storedb = $user->theme['template_storedb'];
}

if ($this->orig_tpl_inherits_id === null)
{
$this->orig_tpl_inherits_id = $user->theme['template_inherits_id'];
}

$user->theme['template_storedb'] = $this->orig_tpl_storedb;
$user->theme['template_inherits_id'] = $this->orig_tpl_inherits_id;

			
if ($user->theme['template_inherits_id'])
{

			
if ($user->theme['template_inherits_id'])
{

Line 75Line 90
	* Set custom template location (able to use directory outside of phpBB)
* @access public
*/

	* Set custom template location (able to use directory outside of phpBB)
* @access public
*/

	function set_custom_template($template_path, $template_name)

	function set_custom_template($template_path, $template_name, $fallback_template_path = false)

	{

	{

		global $phpbb_root_path;







		global $phpbb_root_path, $user;

// Make sure $template_path has no ending slash
if (substr($template_path, -1) == '/')
{
$template_path = substr($template_path, 0, -1);
}


$this->root = $template_path;
$this->cachepath = $phpbb_root_path . 'cache/ctpl_' . str_replace('_', '-', $template_name) . '_';


$this->root = $template_path;
$this->cachepath = $phpbb_root_path . 'cache/ctpl_' . str_replace('_', '-', $template_name) . '_';

 

if ($fallback_template_path !== false)
{
if (substr($fallback_template_path, -1) == '/')
{
$fallback_template_path = substr($fallback_template_path, 0, -1);
}

$this->inherit_root = $fallback_template_path;
$this->orig_tpl_inherits_id = true;
}
else
{
$this->orig_tpl_inherits_id = false;
}

// the database does not store the path or name of a custom template
// so there is no way we can properly store custom templates there
$this->orig_tpl_storedb = false;

$this->_rootref = &$this->_tpldata['.'][0];


return true;
}


return true;
}

Line 122Line 164
	function destroy()
{
$this->_tpldata = array('.' => array(0 => array()));

	function destroy()
{
$this->_tpldata = array('.' => array(0 => array()));

 
		$this->_rootref = &$this->_tpldata['.'][0];

	}

/**

	}

/**

Line 162Line 205
	{
global $user, $phpbb_hook;


	{
global $user, $phpbb_hook;


		if (!empty($phpbb_hook) && $phpbb_hook->call_hook(array(__CLASS__, __FUNCTION__), $handle, $include_once))

		if (!empty($phpbb_hook) && $phpbb_hook->call_hook(array(__CLASS__, __FUNCTION__), $handle, $include_once, $this))

		{
if ($phpbb_hook->hook_return(array(__CLASS__, __FUNCTION__)))
{

		{
if ($phpbb_hook->hook_return(array(__CLASS__, __FUNCTION__)))
{

Line 217Line 260
	function _tpl_load(&$handle)
{
global $user, $phpEx, $config;

	function _tpl_load(&$handle)
{
global $user, $phpEx, $config;

 

if (!isset($this->filename[$handle]))
{
trigger_error("template->_tpl_load(): No file specified for handle $handle", E_USER_ERROR);
}

// reload these settings to have the values they had when this object was initialised
// using set_template or set_custom_template, they might otherwise have been overwritten
// by other template class instances in between.
$user->theme['template_storedb'] = $this->orig_tpl_storedb;
$user->theme['template_inherits_id'] = $this->orig_tpl_inherits_id;


$filename = $this->cachepath . str_replace('/', '.', $this->filename[$handle]) . '.' . $phpEx;


$filename = $this->cachepath . str_replace('/', '.', $this->filename[$handle]) . '.' . $phpEx;

		$this->files_template[$handle] = $user->theme['template_id'];

		$this->files_template[$handle] = (isset($user->theme['template_id'])) ? $user->theme['template_id'] : 0;

		
$recompile = false;

		
$recompile = false;

		if (!file_exists($filename) || @filesize($filename) === 0)

		if (!file_exists($filename) || @filesize($filename) === 0 || defined('DEBUG_EXTRA'))

		{
$recompile = true;
}

		{
$recompile = true;
}

Line 613Line 667
			}
eval(' ?>' . $this->compiled_code[$handle] . '<?php ');
}

			}
eval(' ?>' . $this->compiled_code[$handle] . '<?php ');
}

 
	}

/**
* Include a php-file
* @access private
*/
function _php_include($filename)
{
global $phpbb_root_path;

$file = $phpbb_root_path . $filename;

if (!file_exists($file))
{
// trigger_error cannot be used here, as the output already started
echo 'template->_php_include(): File ' . htmlspecialchars($file) . ' does not exist or is empty';
return;
}
include($file);

	}
}


	}
}