mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 10:24:26 +02:00
Cleaning up code, formatting mostly.
This commit is contained in:
377
Smarty.class.php
377
Smarty.class.php
@@ -43,16 +43,16 @@
|
|||||||
// set SMARTY_DIR to absolute path to Smarty library files.
|
// set SMARTY_DIR to absolute path to Smarty library files.
|
||||||
// if not defined, include_path will be used.
|
// if not defined, include_path will be used.
|
||||||
|
|
||||||
if(!defined("SMARTY_DIR")) {
|
if (!defined('SMARTY_DIR')) {
|
||||||
define("SMARTY_DIR","");
|
define('SMARTY_DIR', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once SMARTY_DIR.'Smarty.addons.php';
|
require_once SMARTY_DIR.'Smarty.addons.php';
|
||||||
|
|
||||||
define("SMARTY_PHP_PASSTHRU",0);
|
define('SMARTY_PHP_PASSTHRU', 0);
|
||||||
define("SMARTY_PHP_QUOTE",1);
|
define('SMARTY_PHP_QUOTE', 1);
|
||||||
define("SMARTY_PHP_REMOVE",2);
|
define('SMARTY_PHP_REMOVE', 2);
|
||||||
define("SMARTY_PHP_ALLOW",3);
|
define('SMARTY_PHP_ALLOW', 3);
|
||||||
|
|
||||||
class Smarty
|
class Smarty
|
||||||
{
|
{
|
||||||
@@ -69,10 +69,10 @@ class Smarty
|
|||||||
|
|
||||||
var $debugging = false; // enable debugging console true/false
|
var $debugging = false; // enable debugging console true/false
|
||||||
var $debug_tpl = 'file:debug.tpl'; // path to debug console template
|
var $debug_tpl = 'file:debug.tpl'; // path to debug console template
|
||||||
var $debugging_ctrl = 'NONE'; // Possible values:
|
var $debugging_ctrl = 'NONE'; // Possible values:
|
||||||
// NONE - no debug control allowed
|
// NONE - no debug control allowed
|
||||||
// URL - enable debugging when keyword
|
// URL - enable debugging when keyword
|
||||||
// SMARTY_DEBUG is found in $QUERY_STRING
|
// SMARTY_DEBUG is found in $QUERY_STRING
|
||||||
|
|
||||||
var $global_assign = array( 'HTTP_SERVER_VARS' => array( 'SCRIPT_NAME' )
|
var $global_assign = array( 'HTTP_SERVER_VARS' => array( 'SCRIPT_NAME' )
|
||||||
); // variables from the GLOBALS array
|
); // variables from the GLOBALS array
|
||||||
@@ -141,8 +141,8 @@ class Smarty
|
|||||||
'fetch' => 'smarty_func_fetch',
|
'fetch' => 'smarty_func_fetch',
|
||||||
'counter' => 'smarty_func_counter',
|
'counter' => 'smarty_func_counter',
|
||||||
'assign' => 'smarty_func_assign',
|
'assign' => 'smarty_func_assign',
|
||||||
'popup_init' => 'smarty_func_overlib_init',
|
'popup_init' => 'smarty_func_overlib_init',
|
||||||
'popup' => 'smarty_func_overlib',
|
'popup' => 'smarty_func_overlib',
|
||||||
'assign_debug_info' => 'smarty_func_assign_debug_info'
|
'assign_debug_info' => 'smarty_func_assign_debug_info'
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -198,7 +198,7 @@ class Smarty
|
|||||||
var $_compile_id = null; // for different compiled templates
|
var $_compile_id = null; // for different compiled templates
|
||||||
var $_smarty_debug_id = 'SMARTY_DEBUG'; // text in URL to enable debug mode
|
var $_smarty_debug_id = 'SMARTY_DEBUG'; // text in URL to enable debug mode
|
||||||
var $_smarty_debug_info = array(); // debugging information for debug console
|
var $_smarty_debug_info = array(); // debugging information for debug console
|
||||||
var $_cache_info = array(); // info that makes up a cache file
|
var $_cache_info = array(); // info that makes up a cache file
|
||||||
|
|
||||||
|
|
||||||
/*======================================================================*\
|
/*======================================================================*\
|
||||||
@@ -496,53 +496,51 @@ class Smarty
|
|||||||
global $HTTP_SERVER_VARS, $QUERY_STRING, $HTTP_COOKIE_VARS;
|
global $HTTP_SERVER_VARS, $QUERY_STRING, $HTTP_COOKIE_VARS;
|
||||||
|
|
||||||
if ($this->debugging_ctrl == 'URL'
|
if ($this->debugging_ctrl == 'URL'
|
||||||
&& (!empty($QUERY_STRING)
|
&& (!empty($QUERY_STRING) && strstr($QUERY_STRING,$this->_smarty_debug_id))) {
|
||||||
&& strstr($QUERY_STRING,$this->_smarty_debug_id))) {
|
$this->debugging = true;
|
||||||
$this->debugging = true;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if($this->debugging)
|
if($this->debugging) {
|
||||||
{
|
// capture time for debugging info
|
||||||
// capture time for debugging info
|
$debug_start_time = $this->_get_microtime();
|
||||||
$debug_start_time = $this->_get_microtime();
|
$this->_smarty_debug_info[] = array('type' => 'template',
|
||||||
$this->_smarty_debug_info[] = array('type' => 'template',
|
'filename' => $tpl_file,
|
||||||
'filename' => $tpl_file,
|
'depth' => 0);
|
||||||
'depth' => 0);
|
$included_tpls_idx = count($this->_smarty_debug_info) - 1;
|
||||||
$included_tpls_idx = count($this->_smarty_debug_info) - 1;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$this->_compile_id = $compile_id;
|
$this->_compile_id = $compile_id;
|
||||||
$this->_inclusion_depth = 0;
|
$this->_inclusion_depth = 0;
|
||||||
|
|
||||||
|
|
||||||
if ($this->caching) {
|
if ($this->caching) {
|
||||||
|
|
||||||
$this->_cache_info[] = array('template',$tpl_file);
|
$this->_cache_info[] = array('template', $tpl_file);
|
||||||
|
|
||||||
$cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $compile_id . $cache_id);
|
$cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $compile_id . $cache_id);
|
||||||
|
|
||||||
if (file_exists($cache_file) &&
|
if (file_exists($cache_file) &&
|
||||||
($this->cache_lifetime == 0 ||
|
($this->cache_lifetime == 0 ||
|
||||||
(time() - filemtime($cache_file) <= $this->cache_lifetime))) {
|
(time() - filemtime($cache_file) <= $this->cache_lifetime))) {
|
||||||
|
|
||||||
if($this->_read_cache_file($cache_file,$results)) {
|
if($this->_read_cache_file($cache_file,$results)) {
|
||||||
if ($this->insert_tag_check) {
|
if ($this->insert_tag_check) {
|
||||||
$results = $this->_process_cached_inserts($results);
|
$results = $this->_process_cached_inserts($results);
|
||||||
}
|
}
|
||||||
if ($display) {
|
if ($display) {
|
||||||
echo $results;
|
echo $results;
|
||||||
if ($this->debugging)
|
if ($this->debugging)
|
||||||
{
|
{
|
||||||
// capture time for debugging info
|
// capture time for debugging info
|
||||||
$this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = $this->_get_microtime() - $debug_start_time;
|
$this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = $this->_get_microtime() - $debug_start_time;
|
||||||
|
|
||||||
echo $this->_generate_debug_output();
|
echo $this->_generate_debug_output();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -570,33 +568,33 @@ class Smarty
|
|||||||
|
|
||||||
$compile_path = $this->_get_compile_path($tpl_file);
|
$compile_path = $this->_get_compile_path($tpl_file);
|
||||||
|
|
||||||
// if we just need to display the results, don't perform output
|
// if we just need to display the results, don't perform output
|
||||||
// buffering - for speed
|
// buffering - for speed
|
||||||
if ($display && !$this->caching) {
|
if ($display && !$this->caching) {
|
||||||
echo $info_header;
|
echo $info_header;
|
||||||
if($this->_process_template($tpl_file, $compile_path))
|
if ($this->_process_template($tpl_file, $compile_path))
|
||||||
{
|
{
|
||||||
if ($this->show_info_include) {
|
if ($this->show_info_include) {
|
||||||
echo "\n<!-- SMARTY_BEGIN: ".$tpl_file." -->\n";
|
echo "\n<!-- SMARTY_BEGIN: ".$tpl_file." -->\n";
|
||||||
}
|
}
|
||||||
include($compile_path);
|
include($compile_path);
|
||||||
if ($this->show_info_include) {
|
if ($this->show_info_include) {
|
||||||
echo "\n<!-- SMARTY_END: ".$tpl_file." -->\n";
|
echo "\n<!-- SMARTY_END: ".$tpl_file." -->\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ob_start();
|
ob_start();
|
||||||
echo $info_header;
|
echo $info_header;
|
||||||
if($this->_process_template($tpl_file, $compile_path))
|
if ($this->_process_template($tpl_file, $compile_path))
|
||||||
{
|
{
|
||||||
if ($this->show_info_include) {
|
if ($this->show_info_include) {
|
||||||
echo "\n<!-- SMARTY_BEGIN: ".$tpl_file." -->\n";
|
echo "\n<!-- SMARTY_BEGIN: ".$tpl_file." -->\n";
|
||||||
}
|
}
|
||||||
include($compile_path);
|
include($compile_path);
|
||||||
if ($this->show_info_include) {
|
if ($this->show_info_include) {
|
||||||
echo "\n<!-- SMARTY_END: ".$tpl_file." -->\n";
|
echo "\n<!-- SMARTY_END: ".$tpl_file." -->\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$results = ob_get_contents();
|
$results = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
}
|
}
|
||||||
@@ -609,12 +607,12 @@ class Smarty
|
|||||||
if ($display) {
|
if ($display) {
|
||||||
if (isset($results)) { echo $results; }
|
if (isset($results)) { echo $results; }
|
||||||
if ($this->debugging)
|
if ($this->debugging)
|
||||||
{
|
{
|
||||||
// capture time for debugging info
|
// capture time for debugging info
|
||||||
$this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = ($this->_get_microtime() - $debug_start_time);
|
$this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = ($this->_get_microtime() - $debug_start_time);
|
||||||
|
|
||||||
echo $this->_generate_debug_output();
|
echo $this->_generate_debug_output();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (isset($results)) { return $results; }
|
if (isset($results)) { return $results; }
|
||||||
@@ -653,7 +651,7 @@ class Smarty
|
|||||||
}
|
}
|
||||||
$smarty['request'] = array_merge($smarty['request'], $smarty['session']);
|
$smarty['request'] = array_merge($smarty['request'], $smarty['session']);
|
||||||
|
|
||||||
$smarty['now'] = time();
|
$smarty['now'] = time();
|
||||||
|
|
||||||
$this->assign('smarty', $smarty);
|
$this->assign('smarty', $smarty);
|
||||||
}
|
}
|
||||||
@@ -665,24 +663,24 @@ class Smarty
|
|||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
|
|
||||||
function _generate_debug_output() {
|
function _generate_debug_output() {
|
||||||
// we must force compile the debug template in case the environment
|
// we must force compile the debug template in case the environment
|
||||||
// changed between separate applications.
|
// changed between separate applications.
|
||||||
ob_start();
|
ob_start();
|
||||||
$force_compile_orig = $this->force_compile;
|
$force_compile_orig = $this->force_compile;
|
||||||
$this->force_compile = true;
|
$this->force_compile = true;
|
||||||
$compile_path = $this->_get_compile_path($tpl_file);
|
$compile_path = $this->_get_compile_path($tpl_file);
|
||||||
if($this->_process_template($this->debug_tpl, $compile_path))
|
if ($this->_process_template($this->debug_tpl, $compile_path))
|
||||||
{
|
{
|
||||||
if ($this->show_info_include) {
|
if ($this->show_info_include) {
|
||||||
echo "\n<!-- SMARTY_BEGIN: ".$this->debug_tpl." -->\n";
|
echo "\n<!-- SMARTY_BEGIN: ".$this->debug_tpl." -->\n";
|
||||||
}
|
}
|
||||||
include($compile_path);
|
include($compile_path);
|
||||||
if ($this->show_info_include) {
|
if ($this->show_info_include) {
|
||||||
echo "\n<!-- SMARTY_END: ".$this->debug_tpl." -->\n";
|
echo "\n<!-- SMARTY_END: ".$this->debug_tpl." -->\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$results = ob_get_contents();
|
$results = ob_get_contents();
|
||||||
$this->force_compile = $force_compile_orig;
|
$this->force_compile = $force_compile_orig;
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
@@ -700,9 +698,10 @@ function _generate_debug_output() {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// get template source and timestamp
|
// get template source and timestamp
|
||||||
if(!$this->_fetch_template_info($tpl_file, $template_source, $template_timestamp)) {
|
if (!$this->_fetch_template_info($tpl_file, $template_source,
|
||||||
return false;
|
$template_timestamp)) {
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
if ($template_timestamp <= $this->_fetch_compiled_template_timestamp($compile_path)) {
|
if ($template_timestamp <= $this->_fetch_compiled_template_timestamp($compile_path)) {
|
||||||
// template not expired, no recompile
|
// template not expired, no recompile
|
||||||
return true;
|
return true;
|
||||||
@@ -715,9 +714,10 @@ function _generate_debug_output() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// compiled template does not exist, or forced compile
|
// compiled template does not exist, or forced compile
|
||||||
if(!$this->_fetch_template_info($tpl_file, $template_source, $template_timestamp)) {
|
if (!$this->_fetch_template_info($tpl_file, $template_source,
|
||||||
return false;
|
$template_timestamp)) {
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
$this->_compile_template($tpl_file, $template_source, $template_compiled);
|
$this->_compile_template($tpl_file, $template_source, $template_compiled);
|
||||||
$this->_write_compiled_template($compile_path, $template_compiled);
|
$this->_write_compiled_template($compile_path, $template_compiled);
|
||||||
return true;
|
return true;
|
||||||
@@ -730,7 +730,8 @@ function _generate_debug_output() {
|
|||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function _get_compile_path($tpl_file)
|
function _get_compile_path($tpl_file)
|
||||||
{
|
{
|
||||||
return $this->_get_auto_filename($this->compile_dir, $tpl_file, $this->_compile_id);
|
return $this->_get_auto_filename($this->compile_dir, $tpl_file,
|
||||||
|
$this->_compile_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -768,7 +769,7 @@ function _generate_debug_output() {
|
|||||||
/*======================================================================*\
|
/*======================================================================*\
|
||||||
Function: _fetch_template_info()
|
Function: _fetch_template_info()
|
||||||
Purpose: fetch the template info. Gets timestamp, and source
|
Purpose: fetch the template info. Gets timestamp, and source
|
||||||
if get_source is true
|
if get_source is true
|
||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function _fetch_template_info($tpl_path, &$template_source, &$template_timestamp, $get_source=true)
|
function _fetch_template_info($tpl_path, &$template_source, &$template_timestamp, $get_source=true)
|
||||||
{
|
{
|
||||||
@@ -791,9 +792,9 @@ function _generate_debug_output() {
|
|||||||
$resource_name = $this->template_dir.'/'.$resource_name;
|
$resource_name = $this->template_dir.'/'.$resource_name;
|
||||||
}
|
}
|
||||||
if (file_exists($resource_name) && is_readable($resource_name)) {
|
if (file_exists($resource_name) && is_readable($resource_name)) {
|
||||||
if($get_source) {
|
if($get_source) {
|
||||||
$template_source = $this->_read_file($resource_name);
|
$template_source = $this->_read_file($resource_name);
|
||||||
}
|
}
|
||||||
$template_timestamp = filemtime($resource_name);
|
$template_timestamp = filemtime($resource_name);
|
||||||
} else {
|
} else {
|
||||||
$this->_trigger_error_msg("unable to read template resource: \"$tpl_path\"");
|
$this->_trigger_error_msg("unable to read template resource: \"$tpl_path\"");
|
||||||
@@ -880,13 +881,13 @@ function _generate_debug_output() {
|
|||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function _smarty_include($_smarty_include_tpl_file, $_smarty_include_vars)
|
function _smarty_include($_smarty_include_tpl_file, $_smarty_include_vars)
|
||||||
{
|
{
|
||||||
if($this->debugging) {
|
if($this->debugging) {
|
||||||
$debug_start_time = $this->_get_microtime();
|
$debug_start_time = $this->_get_microtime();
|
||||||
$this->_smarty_debug_info[] = array('type' => 'template',
|
$this->_smarty_debug_info[] = array('type' => 'template',
|
||||||
'filename' => $_smarty_include_tpl_file,
|
'filename' => $_smarty_include_tpl_file,
|
||||||
'depth' => ++$this->_inclusion_depth);
|
'depth' => ++$this->_inclusion_depth);
|
||||||
$included_tpls_idx = count($this->_smarty_debug_info) - 1;
|
$included_tpls_idx = count($this->_smarty_debug_info) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_tpl_vars = array_merge($this->_tpl_vars, $_smarty_include_vars);
|
$this->_tpl_vars = array_merge($this->_tpl_vars, $_smarty_include_vars);
|
||||||
extract($this->_tpl_vars);
|
extract($this->_tpl_vars);
|
||||||
@@ -908,14 +909,14 @@ function _generate_debug_output() {
|
|||||||
array_shift($this->_config);
|
array_shift($this->_config);
|
||||||
$this->_inclusion_depth--;
|
$this->_inclusion_depth--;
|
||||||
|
|
||||||
if ($this->debugging) {
|
if ($this->debugging) {
|
||||||
// capture time for debugging info
|
// capture time for debugging info
|
||||||
$this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = $this->_get_microtime() - $debug_start_time;
|
$this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = $this->_get_microtime() - $debug_start_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->caching) {
|
if ($this->caching) {
|
||||||
$this->_cache_info[] = array('template',$_smarty_include_tpl_file);
|
$this->_cache_info[] = array('template', $_smarty_include_tpl_file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -925,14 +926,13 @@ function _generate_debug_output() {
|
|||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function _config_load($file, $section, $scope)
|
function _config_load($file, $section, $scope)
|
||||||
{
|
{
|
||||||
if($this->debugging) {
|
if($this->debugging) {
|
||||||
$debug_start_time = $this->_get_microtime();
|
$debug_start_time = $this->_get_microtime();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->caching) {
|
|
||||||
$this->_cache_info[] = array('config',$file);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if ($this->caching) {
|
||||||
|
$this->_cache_info[] = array('config', $file);
|
||||||
|
}
|
||||||
|
|
||||||
$this->_config[0] = array_merge($this->_config[0], $this->_conf_obj->get($file));
|
$this->_config[0] = array_merge($this->_config[0], $this->_conf_obj->get($file));
|
||||||
if ($scope == 'parent') {
|
if ($scope == 'parent') {
|
||||||
@@ -951,13 +951,13 @@ function _generate_debug_output() {
|
|||||||
for ($i = 1; $i < count($this->_config); $i++)
|
for ($i = 1; $i < count($this->_config); $i++)
|
||||||
$this->_config[$i] = array_merge($this->_config[$i], $this->_conf_obj->get($file, $section));
|
$this->_config[$i] = array_merge($this->_config[$i], $this->_conf_obj->get($file, $section));
|
||||||
}
|
}
|
||||||
if($this->debugging) {
|
if($this->debugging) {
|
||||||
$debug_start_time = $this->_get_microtime();
|
$debug_start_time = $this->_get_microtime();
|
||||||
$this->_smarty_debug_info[] = array('type' => 'config',
|
$this->_smarty_debug_info[] = array('type' => 'config',
|
||||||
'filename' => $file.' ['.$section.'] '.$scope,
|
'filename' => $file.' ['.$section.'] '.$scope,
|
||||||
'depth' => $this->_inclusion_depth,
|
'depth' => $this->_inclusion_depth,
|
||||||
'exec_time' => $this->_get_microtime() - $debug_start_time);
|
'exec_time' => $this->_get_microtime() - $debug_start_time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -967,9 +967,9 @@ function _generate_debug_output() {
|
|||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function _process_cached_inserts($results)
|
function _process_cached_inserts($results)
|
||||||
{
|
{
|
||||||
if($this->debugging) {
|
if($this->debugging) {
|
||||||
$debug_start_time = $this->_get_microtime();
|
$debug_start_time = $this->_get_microtime();
|
||||||
}
|
}
|
||||||
|
|
||||||
preg_match_all('!'.$this->_smarty_md5.'{insert_cache (.*)}'.$this->_smarty_md5.'!Uis',
|
preg_match_all('!'.$this->_smarty_md5.'{insert_cache (.*)}'.$this->_smarty_md5.'!Uis',
|
||||||
$results, $match);
|
$results, $match);
|
||||||
@@ -986,15 +986,14 @@ function _generate_debug_output() {
|
|||||||
$replace = $function_name($args, $this);
|
$replace = $function_name($args, $this);
|
||||||
|
|
||||||
$results = str_replace($cached_inserts[$i], $replace, $results);
|
$results = str_replace($cached_inserts[$i], $replace, $results);
|
||||||
if ($this->debugging) {
|
if ($this->debugging) {
|
||||||
$this->_smarty_debug_info[] = array('type' => 'insert',
|
$this->_smarty_debug_info[] = array('type' => 'insert',
|
||||||
'filename' => 'insert_'.$name,
|
'filename' => 'insert_'.$name,
|
||||||
'depth' => $this->_inclusion_depth,
|
'depth' => $this->_inclusion_depth,
|
||||||
'exec_time' => $this->_get_microtime() - $debug_start_time);
|
'exec_time' => $this->_get_microtime() - $debug_start_time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1005,9 +1004,9 @@ function _generate_debug_output() {
|
|||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function _run_insert_handler($args)
|
function _run_insert_handler($args)
|
||||||
{
|
{
|
||||||
if($this->debugging) {
|
if($this->debugging) {
|
||||||
$debug_start_time = $this->_get_microtime();
|
$debug_start_time = $this->_get_microtime();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->caching) {
|
if ($this->caching) {
|
||||||
$arg_string = serialize($args);
|
$arg_string = serialize($args);
|
||||||
@@ -1016,12 +1015,12 @@ function _run_insert_handler($args)
|
|||||||
$function_name = 'insert_'.$args['name'];
|
$function_name = 'insert_'.$args['name'];
|
||||||
$content = $function_name($args, $this);
|
$content = $function_name($args, $this);
|
||||||
if ($this->debugging) {
|
if ($this->debugging) {
|
||||||
$this->_smarty_debug_info[] = array('type' => 'insert',
|
$this->_smarty_debug_info[] = array('type' => 'insert',
|
||||||
'filename' => 'insert_'.$args['name'],
|
'filename' => 'insert_'.$args['name'],
|
||||||
'depth' => $this->_inclusion_depth,
|
'depth' => $this->_inclusion_depth,
|
||||||
'exec_time' => $this->_get_microtime() - $debug_start_time);
|
'exec_time' => $this->_get_microtime() - $debug_start_time);
|
||||||
}
|
}
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1205,57 +1204,59 @@ function _run_mod_handler()
|
|||||||
/*======================================================================*\
|
/*======================================================================*\
|
||||||
Function: _write_cache_file
|
Function: _write_cache_file
|
||||||
Purpose: Prepend the cache information to the cache file
|
Purpose: Prepend the cache information to the cache file
|
||||||
and write it to disk
|
and write it to disk
|
||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function _write_cache_file($cache_file,$results)
|
function _write_cache_file($cache_file,$results)
|
||||||
{
|
{
|
||||||
// put the templates involved with this cache in the first line
|
// put the templates involved with this cache in the first line
|
||||||
$cache_info = "SMARTY_CACHE_INFO_HEADER".serialize($this->_cache_info)."\n";
|
$cache_info = 'SMARTY_CACHE_INFO_HEADER'.serialize($this->_cache_info)."\n";
|
||||||
$this->_write_file($cache_file, $cache_info.$results, true);
|
$this->_write_file($cache_file, $cache_info.$results, true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*======================================================================*\
|
/*======================================================================*\
|
||||||
Function: _read_cache_file
|
Function: _read_cache_file
|
||||||
Purpose: See if any of the templates for this cache file
|
Purpose: See if any of the templates for this cache file
|
||||||
have changed or not since the cache was created.
|
have changed or not since the cache was created.
|
||||||
Remove the cache info from the cache results.
|
Remove the cache info from the cache results.
|
||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function _read_cache_file($cache_file,&$results)
|
function _read_cache_file($cache_file,&$results)
|
||||||
{
|
{
|
||||||
$results = $this->_read_file($cache_file);
|
$results = $this->_read_file($cache_file);
|
||||||
|
|
||||||
// get the templates involved with this cache from the first line
|
// get the templates involved with this cache from the first line
|
||||||
$contents = split("\n",$results,2);
|
$contents = explode("\n", $results, 2);
|
||||||
|
|
||||||
if(substr($contents[0],0,24) == 'SMARTY_CACHE_INFO_HEADER') {
|
if (substr($contents[0], 0, 24) == 'SMARTY_CACHE_INFO_HEADER') {
|
||||||
$cache_info = unserialize(substr($contents[0],24));
|
$cache_info = unserialize(substr($contents[0], 24));
|
||||||
$results = $contents[1];
|
$results = $contents[1];
|
||||||
|
|
||||||
if($this->compile_check) {
|
if ($this->compile_check) {
|
||||||
$cache_filemtime = filemtime($cache_file);
|
$cache_filemtime = filemtime($cache_file);
|
||||||
|
|
||||||
foreach($cache_info as $curr_cache_info) {
|
foreach ($cache_info as $curr_cache_info) {
|
||||||
switch ($curr_cache_info[0]) {
|
switch ($curr_cache_info[0]) {
|
||||||
case 'template':
|
case 'template':
|
||||||
$this->_fetch_template_info($curr_cache_info[1], $template_source, $template_timestamp, false);
|
$this->_fetch_template_info($curr_cache_info[1], $template_source, $template_timestamp, false);
|
||||||
if( $cache_filemtime < $template_timestamp) {
|
if($cache_filemtime < $template_timestamp) {
|
||||||
// template file has changed, regenerate cache
|
// template file has changed, regenerate cache
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'config':
|
|
||||||
if( $cache_filemtime < filemtime($this->config_dir.'/'.$curr_cache_info[1])) {
|
case 'config':
|
||||||
// config file file has changed, regenerate cache
|
if ($cache_filemtime < filemtime($this->config_dir.'/'.$curr_cache_info[1])) {
|
||||||
return false;
|
// config file file has changed, regenerate cache
|
||||||
}
|
return false;
|
||||||
break;
|
}
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1279,16 +1280,16 @@ function _run_mod_handler()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*======================================================================*\
|
/*======================================================================*\
|
||||||
Function: _get_microtime
|
Function: _get_microtime
|
||||||
Purpose: Get seconds and microseconds
|
Purpose: Get seconds and microseconds
|
||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function _get_microtime()
|
function _get_microtime()
|
||||||
{
|
{
|
||||||
$mtime = microtime();
|
$mtime = microtime();
|
||||||
$mtime = explode(" ", $mtime);
|
$mtime = explode(" ", $mtime);
|
||||||
$mtime = (double)($mtime[1]) + (double)($mtime[0]);
|
$mtime = (double)($mtime[1]) + (double)($mtime[0]);
|
||||||
return ($mtime);
|
return ($mtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -43,16 +43,16 @@
|
|||||||
// set SMARTY_DIR to absolute path to Smarty library files.
|
// set SMARTY_DIR to absolute path to Smarty library files.
|
||||||
// if not defined, include_path will be used.
|
// if not defined, include_path will be used.
|
||||||
|
|
||||||
if(!defined("SMARTY_DIR")) {
|
if (!defined('SMARTY_DIR')) {
|
||||||
define("SMARTY_DIR","");
|
define('SMARTY_DIR', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once SMARTY_DIR.'Smarty.addons.php';
|
require_once SMARTY_DIR.'Smarty.addons.php';
|
||||||
|
|
||||||
define("SMARTY_PHP_PASSTHRU",0);
|
define('SMARTY_PHP_PASSTHRU', 0);
|
||||||
define("SMARTY_PHP_QUOTE",1);
|
define('SMARTY_PHP_QUOTE', 1);
|
||||||
define("SMARTY_PHP_REMOVE",2);
|
define('SMARTY_PHP_REMOVE', 2);
|
||||||
define("SMARTY_PHP_ALLOW",3);
|
define('SMARTY_PHP_ALLOW', 3);
|
||||||
|
|
||||||
class Smarty
|
class Smarty
|
||||||
{
|
{
|
||||||
@@ -69,10 +69,10 @@ class Smarty
|
|||||||
|
|
||||||
var $debugging = false; // enable debugging console true/false
|
var $debugging = false; // enable debugging console true/false
|
||||||
var $debug_tpl = 'file:debug.tpl'; // path to debug console template
|
var $debug_tpl = 'file:debug.tpl'; // path to debug console template
|
||||||
var $debugging_ctrl = 'NONE'; // Possible values:
|
var $debugging_ctrl = 'NONE'; // Possible values:
|
||||||
// NONE - no debug control allowed
|
// NONE - no debug control allowed
|
||||||
// URL - enable debugging when keyword
|
// URL - enable debugging when keyword
|
||||||
// SMARTY_DEBUG is found in $QUERY_STRING
|
// SMARTY_DEBUG is found in $QUERY_STRING
|
||||||
|
|
||||||
var $global_assign = array( 'HTTP_SERVER_VARS' => array( 'SCRIPT_NAME' )
|
var $global_assign = array( 'HTTP_SERVER_VARS' => array( 'SCRIPT_NAME' )
|
||||||
); // variables from the GLOBALS array
|
); // variables from the GLOBALS array
|
||||||
@@ -141,8 +141,8 @@ class Smarty
|
|||||||
'fetch' => 'smarty_func_fetch',
|
'fetch' => 'smarty_func_fetch',
|
||||||
'counter' => 'smarty_func_counter',
|
'counter' => 'smarty_func_counter',
|
||||||
'assign' => 'smarty_func_assign',
|
'assign' => 'smarty_func_assign',
|
||||||
'popup_init' => 'smarty_func_overlib_init',
|
'popup_init' => 'smarty_func_overlib_init',
|
||||||
'popup' => 'smarty_func_overlib',
|
'popup' => 'smarty_func_overlib',
|
||||||
'assign_debug_info' => 'smarty_func_assign_debug_info'
|
'assign_debug_info' => 'smarty_func_assign_debug_info'
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -198,7 +198,7 @@ class Smarty
|
|||||||
var $_compile_id = null; // for different compiled templates
|
var $_compile_id = null; // for different compiled templates
|
||||||
var $_smarty_debug_id = 'SMARTY_DEBUG'; // text in URL to enable debug mode
|
var $_smarty_debug_id = 'SMARTY_DEBUG'; // text in URL to enable debug mode
|
||||||
var $_smarty_debug_info = array(); // debugging information for debug console
|
var $_smarty_debug_info = array(); // debugging information for debug console
|
||||||
var $_cache_info = array(); // info that makes up a cache file
|
var $_cache_info = array(); // info that makes up a cache file
|
||||||
|
|
||||||
|
|
||||||
/*======================================================================*\
|
/*======================================================================*\
|
||||||
@@ -496,53 +496,51 @@ class Smarty
|
|||||||
global $HTTP_SERVER_VARS, $QUERY_STRING, $HTTP_COOKIE_VARS;
|
global $HTTP_SERVER_VARS, $QUERY_STRING, $HTTP_COOKIE_VARS;
|
||||||
|
|
||||||
if ($this->debugging_ctrl == 'URL'
|
if ($this->debugging_ctrl == 'URL'
|
||||||
&& (!empty($QUERY_STRING)
|
&& (!empty($QUERY_STRING) && strstr($QUERY_STRING,$this->_smarty_debug_id))) {
|
||||||
&& strstr($QUERY_STRING,$this->_smarty_debug_id))) {
|
$this->debugging = true;
|
||||||
$this->debugging = true;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if($this->debugging)
|
if($this->debugging) {
|
||||||
{
|
// capture time for debugging info
|
||||||
// capture time for debugging info
|
$debug_start_time = $this->_get_microtime();
|
||||||
$debug_start_time = $this->_get_microtime();
|
$this->_smarty_debug_info[] = array('type' => 'template',
|
||||||
$this->_smarty_debug_info[] = array('type' => 'template',
|
'filename' => $tpl_file,
|
||||||
'filename' => $tpl_file,
|
'depth' => 0);
|
||||||
'depth' => 0);
|
$included_tpls_idx = count($this->_smarty_debug_info) - 1;
|
||||||
$included_tpls_idx = count($this->_smarty_debug_info) - 1;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$this->_compile_id = $compile_id;
|
$this->_compile_id = $compile_id;
|
||||||
$this->_inclusion_depth = 0;
|
$this->_inclusion_depth = 0;
|
||||||
|
|
||||||
|
|
||||||
if ($this->caching) {
|
if ($this->caching) {
|
||||||
|
|
||||||
$this->_cache_info[] = array('template',$tpl_file);
|
$this->_cache_info[] = array('template', $tpl_file);
|
||||||
|
|
||||||
$cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $compile_id . $cache_id);
|
$cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $compile_id . $cache_id);
|
||||||
|
|
||||||
if (file_exists($cache_file) &&
|
if (file_exists($cache_file) &&
|
||||||
($this->cache_lifetime == 0 ||
|
($this->cache_lifetime == 0 ||
|
||||||
(time() - filemtime($cache_file) <= $this->cache_lifetime))) {
|
(time() - filemtime($cache_file) <= $this->cache_lifetime))) {
|
||||||
|
|
||||||
if($this->_read_cache_file($cache_file,$results)) {
|
if($this->_read_cache_file($cache_file,$results)) {
|
||||||
if ($this->insert_tag_check) {
|
if ($this->insert_tag_check) {
|
||||||
$results = $this->_process_cached_inserts($results);
|
$results = $this->_process_cached_inserts($results);
|
||||||
}
|
}
|
||||||
if ($display) {
|
if ($display) {
|
||||||
echo $results;
|
echo $results;
|
||||||
if ($this->debugging)
|
if ($this->debugging)
|
||||||
{
|
{
|
||||||
// capture time for debugging info
|
// capture time for debugging info
|
||||||
$this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = $this->_get_microtime() - $debug_start_time;
|
$this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = $this->_get_microtime() - $debug_start_time;
|
||||||
|
|
||||||
echo $this->_generate_debug_output();
|
echo $this->_generate_debug_output();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -570,33 +568,33 @@ class Smarty
|
|||||||
|
|
||||||
$compile_path = $this->_get_compile_path($tpl_file);
|
$compile_path = $this->_get_compile_path($tpl_file);
|
||||||
|
|
||||||
// if we just need to display the results, don't perform output
|
// if we just need to display the results, don't perform output
|
||||||
// buffering - for speed
|
// buffering - for speed
|
||||||
if ($display && !$this->caching) {
|
if ($display && !$this->caching) {
|
||||||
echo $info_header;
|
echo $info_header;
|
||||||
if($this->_process_template($tpl_file, $compile_path))
|
if ($this->_process_template($tpl_file, $compile_path))
|
||||||
{
|
{
|
||||||
if ($this->show_info_include) {
|
if ($this->show_info_include) {
|
||||||
echo "\n<!-- SMARTY_BEGIN: ".$tpl_file." -->\n";
|
echo "\n<!-- SMARTY_BEGIN: ".$tpl_file." -->\n";
|
||||||
}
|
}
|
||||||
include($compile_path);
|
include($compile_path);
|
||||||
if ($this->show_info_include) {
|
if ($this->show_info_include) {
|
||||||
echo "\n<!-- SMARTY_END: ".$tpl_file." -->\n";
|
echo "\n<!-- SMARTY_END: ".$tpl_file." -->\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ob_start();
|
ob_start();
|
||||||
echo $info_header;
|
echo $info_header;
|
||||||
if($this->_process_template($tpl_file, $compile_path))
|
if ($this->_process_template($tpl_file, $compile_path))
|
||||||
{
|
{
|
||||||
if ($this->show_info_include) {
|
if ($this->show_info_include) {
|
||||||
echo "\n<!-- SMARTY_BEGIN: ".$tpl_file." -->\n";
|
echo "\n<!-- SMARTY_BEGIN: ".$tpl_file." -->\n";
|
||||||
}
|
}
|
||||||
include($compile_path);
|
include($compile_path);
|
||||||
if ($this->show_info_include) {
|
if ($this->show_info_include) {
|
||||||
echo "\n<!-- SMARTY_END: ".$tpl_file." -->\n";
|
echo "\n<!-- SMARTY_END: ".$tpl_file." -->\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$results = ob_get_contents();
|
$results = ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
}
|
}
|
||||||
@@ -609,12 +607,12 @@ class Smarty
|
|||||||
if ($display) {
|
if ($display) {
|
||||||
if (isset($results)) { echo $results; }
|
if (isset($results)) { echo $results; }
|
||||||
if ($this->debugging)
|
if ($this->debugging)
|
||||||
{
|
{
|
||||||
// capture time for debugging info
|
// capture time for debugging info
|
||||||
$this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = ($this->_get_microtime() - $debug_start_time);
|
$this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = ($this->_get_microtime() - $debug_start_time);
|
||||||
|
|
||||||
echo $this->_generate_debug_output();
|
echo $this->_generate_debug_output();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (isset($results)) { return $results; }
|
if (isset($results)) { return $results; }
|
||||||
@@ -653,7 +651,7 @@ class Smarty
|
|||||||
}
|
}
|
||||||
$smarty['request'] = array_merge($smarty['request'], $smarty['session']);
|
$smarty['request'] = array_merge($smarty['request'], $smarty['session']);
|
||||||
|
|
||||||
$smarty['now'] = time();
|
$smarty['now'] = time();
|
||||||
|
|
||||||
$this->assign('smarty', $smarty);
|
$this->assign('smarty', $smarty);
|
||||||
}
|
}
|
||||||
@@ -665,24 +663,24 @@ class Smarty
|
|||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
|
|
||||||
function _generate_debug_output() {
|
function _generate_debug_output() {
|
||||||
// we must force compile the debug template in case the environment
|
// we must force compile the debug template in case the environment
|
||||||
// changed between separate applications.
|
// changed between separate applications.
|
||||||
ob_start();
|
ob_start();
|
||||||
$force_compile_orig = $this->force_compile;
|
$force_compile_orig = $this->force_compile;
|
||||||
$this->force_compile = true;
|
$this->force_compile = true;
|
||||||
$compile_path = $this->_get_compile_path($tpl_file);
|
$compile_path = $this->_get_compile_path($tpl_file);
|
||||||
if($this->_process_template($this->debug_tpl, $compile_path))
|
if ($this->_process_template($this->debug_tpl, $compile_path))
|
||||||
{
|
{
|
||||||
if ($this->show_info_include) {
|
if ($this->show_info_include) {
|
||||||
echo "\n<!-- SMARTY_BEGIN: ".$this->debug_tpl." -->\n";
|
echo "\n<!-- SMARTY_BEGIN: ".$this->debug_tpl." -->\n";
|
||||||
}
|
}
|
||||||
include($compile_path);
|
include($compile_path);
|
||||||
if ($this->show_info_include) {
|
if ($this->show_info_include) {
|
||||||
echo "\n<!-- SMARTY_END: ".$this->debug_tpl." -->\n";
|
echo "\n<!-- SMARTY_END: ".$this->debug_tpl." -->\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$results = ob_get_contents();
|
$results = ob_get_contents();
|
||||||
$this->force_compile = $force_compile_orig;
|
$this->force_compile = $force_compile_orig;
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
@@ -700,9 +698,10 @@ function _generate_debug_output() {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
// get template source and timestamp
|
// get template source and timestamp
|
||||||
if(!$this->_fetch_template_info($tpl_file, $template_source, $template_timestamp)) {
|
if (!$this->_fetch_template_info($tpl_file, $template_source,
|
||||||
return false;
|
$template_timestamp)) {
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
if ($template_timestamp <= $this->_fetch_compiled_template_timestamp($compile_path)) {
|
if ($template_timestamp <= $this->_fetch_compiled_template_timestamp($compile_path)) {
|
||||||
// template not expired, no recompile
|
// template not expired, no recompile
|
||||||
return true;
|
return true;
|
||||||
@@ -715,9 +714,10 @@ function _generate_debug_output() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// compiled template does not exist, or forced compile
|
// compiled template does not exist, or forced compile
|
||||||
if(!$this->_fetch_template_info($tpl_file, $template_source, $template_timestamp)) {
|
if (!$this->_fetch_template_info($tpl_file, $template_source,
|
||||||
return false;
|
$template_timestamp)) {
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
$this->_compile_template($tpl_file, $template_source, $template_compiled);
|
$this->_compile_template($tpl_file, $template_source, $template_compiled);
|
||||||
$this->_write_compiled_template($compile_path, $template_compiled);
|
$this->_write_compiled_template($compile_path, $template_compiled);
|
||||||
return true;
|
return true;
|
||||||
@@ -730,7 +730,8 @@ function _generate_debug_output() {
|
|||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function _get_compile_path($tpl_file)
|
function _get_compile_path($tpl_file)
|
||||||
{
|
{
|
||||||
return $this->_get_auto_filename($this->compile_dir, $tpl_file, $this->_compile_id);
|
return $this->_get_auto_filename($this->compile_dir, $tpl_file,
|
||||||
|
$this->_compile_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -768,7 +769,7 @@ function _generate_debug_output() {
|
|||||||
/*======================================================================*\
|
/*======================================================================*\
|
||||||
Function: _fetch_template_info()
|
Function: _fetch_template_info()
|
||||||
Purpose: fetch the template info. Gets timestamp, and source
|
Purpose: fetch the template info. Gets timestamp, and source
|
||||||
if get_source is true
|
if get_source is true
|
||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function _fetch_template_info($tpl_path, &$template_source, &$template_timestamp, $get_source=true)
|
function _fetch_template_info($tpl_path, &$template_source, &$template_timestamp, $get_source=true)
|
||||||
{
|
{
|
||||||
@@ -791,9 +792,9 @@ function _generate_debug_output() {
|
|||||||
$resource_name = $this->template_dir.'/'.$resource_name;
|
$resource_name = $this->template_dir.'/'.$resource_name;
|
||||||
}
|
}
|
||||||
if (file_exists($resource_name) && is_readable($resource_name)) {
|
if (file_exists($resource_name) && is_readable($resource_name)) {
|
||||||
if($get_source) {
|
if($get_source) {
|
||||||
$template_source = $this->_read_file($resource_name);
|
$template_source = $this->_read_file($resource_name);
|
||||||
}
|
}
|
||||||
$template_timestamp = filemtime($resource_name);
|
$template_timestamp = filemtime($resource_name);
|
||||||
} else {
|
} else {
|
||||||
$this->_trigger_error_msg("unable to read template resource: \"$tpl_path\"");
|
$this->_trigger_error_msg("unable to read template resource: \"$tpl_path\"");
|
||||||
@@ -880,13 +881,13 @@ function _generate_debug_output() {
|
|||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function _smarty_include($_smarty_include_tpl_file, $_smarty_include_vars)
|
function _smarty_include($_smarty_include_tpl_file, $_smarty_include_vars)
|
||||||
{
|
{
|
||||||
if($this->debugging) {
|
if($this->debugging) {
|
||||||
$debug_start_time = $this->_get_microtime();
|
$debug_start_time = $this->_get_microtime();
|
||||||
$this->_smarty_debug_info[] = array('type' => 'template',
|
$this->_smarty_debug_info[] = array('type' => 'template',
|
||||||
'filename' => $_smarty_include_tpl_file,
|
'filename' => $_smarty_include_tpl_file,
|
||||||
'depth' => ++$this->_inclusion_depth);
|
'depth' => ++$this->_inclusion_depth);
|
||||||
$included_tpls_idx = count($this->_smarty_debug_info) - 1;
|
$included_tpls_idx = count($this->_smarty_debug_info) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_tpl_vars = array_merge($this->_tpl_vars, $_smarty_include_vars);
|
$this->_tpl_vars = array_merge($this->_tpl_vars, $_smarty_include_vars);
|
||||||
extract($this->_tpl_vars);
|
extract($this->_tpl_vars);
|
||||||
@@ -908,14 +909,14 @@ function _generate_debug_output() {
|
|||||||
array_shift($this->_config);
|
array_shift($this->_config);
|
||||||
$this->_inclusion_depth--;
|
$this->_inclusion_depth--;
|
||||||
|
|
||||||
if ($this->debugging) {
|
if ($this->debugging) {
|
||||||
// capture time for debugging info
|
// capture time for debugging info
|
||||||
$this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = $this->_get_microtime() - $debug_start_time;
|
$this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = $this->_get_microtime() - $debug_start_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->caching) {
|
if ($this->caching) {
|
||||||
$this->_cache_info[] = array('template',$_smarty_include_tpl_file);
|
$this->_cache_info[] = array('template', $_smarty_include_tpl_file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -925,14 +926,13 @@ function _generate_debug_output() {
|
|||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function _config_load($file, $section, $scope)
|
function _config_load($file, $section, $scope)
|
||||||
{
|
{
|
||||||
if($this->debugging) {
|
if($this->debugging) {
|
||||||
$debug_start_time = $this->_get_microtime();
|
$debug_start_time = $this->_get_microtime();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->caching) {
|
|
||||||
$this->_cache_info[] = array('config',$file);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if ($this->caching) {
|
||||||
|
$this->_cache_info[] = array('config', $file);
|
||||||
|
}
|
||||||
|
|
||||||
$this->_config[0] = array_merge($this->_config[0], $this->_conf_obj->get($file));
|
$this->_config[0] = array_merge($this->_config[0], $this->_conf_obj->get($file));
|
||||||
if ($scope == 'parent') {
|
if ($scope == 'parent') {
|
||||||
@@ -951,13 +951,13 @@ function _generate_debug_output() {
|
|||||||
for ($i = 1; $i < count($this->_config); $i++)
|
for ($i = 1; $i < count($this->_config); $i++)
|
||||||
$this->_config[$i] = array_merge($this->_config[$i], $this->_conf_obj->get($file, $section));
|
$this->_config[$i] = array_merge($this->_config[$i], $this->_conf_obj->get($file, $section));
|
||||||
}
|
}
|
||||||
if($this->debugging) {
|
if($this->debugging) {
|
||||||
$debug_start_time = $this->_get_microtime();
|
$debug_start_time = $this->_get_microtime();
|
||||||
$this->_smarty_debug_info[] = array('type' => 'config',
|
$this->_smarty_debug_info[] = array('type' => 'config',
|
||||||
'filename' => $file.' ['.$section.'] '.$scope,
|
'filename' => $file.' ['.$section.'] '.$scope,
|
||||||
'depth' => $this->_inclusion_depth,
|
'depth' => $this->_inclusion_depth,
|
||||||
'exec_time' => $this->_get_microtime() - $debug_start_time);
|
'exec_time' => $this->_get_microtime() - $debug_start_time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -967,9 +967,9 @@ function _generate_debug_output() {
|
|||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function _process_cached_inserts($results)
|
function _process_cached_inserts($results)
|
||||||
{
|
{
|
||||||
if($this->debugging) {
|
if($this->debugging) {
|
||||||
$debug_start_time = $this->_get_microtime();
|
$debug_start_time = $this->_get_microtime();
|
||||||
}
|
}
|
||||||
|
|
||||||
preg_match_all('!'.$this->_smarty_md5.'{insert_cache (.*)}'.$this->_smarty_md5.'!Uis',
|
preg_match_all('!'.$this->_smarty_md5.'{insert_cache (.*)}'.$this->_smarty_md5.'!Uis',
|
||||||
$results, $match);
|
$results, $match);
|
||||||
@@ -986,15 +986,14 @@ function _generate_debug_output() {
|
|||||||
$replace = $function_name($args, $this);
|
$replace = $function_name($args, $this);
|
||||||
|
|
||||||
$results = str_replace($cached_inserts[$i], $replace, $results);
|
$results = str_replace($cached_inserts[$i], $replace, $results);
|
||||||
if ($this->debugging) {
|
if ($this->debugging) {
|
||||||
$this->_smarty_debug_info[] = array('type' => 'insert',
|
$this->_smarty_debug_info[] = array('type' => 'insert',
|
||||||
'filename' => 'insert_'.$name,
|
'filename' => 'insert_'.$name,
|
||||||
'depth' => $this->_inclusion_depth,
|
'depth' => $this->_inclusion_depth,
|
||||||
'exec_time' => $this->_get_microtime() - $debug_start_time);
|
'exec_time' => $this->_get_microtime() - $debug_start_time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1005,9 +1004,9 @@ function _generate_debug_output() {
|
|||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function _run_insert_handler($args)
|
function _run_insert_handler($args)
|
||||||
{
|
{
|
||||||
if($this->debugging) {
|
if($this->debugging) {
|
||||||
$debug_start_time = $this->_get_microtime();
|
$debug_start_time = $this->_get_microtime();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->caching) {
|
if ($this->caching) {
|
||||||
$arg_string = serialize($args);
|
$arg_string = serialize($args);
|
||||||
@@ -1016,12 +1015,12 @@ function _run_insert_handler($args)
|
|||||||
$function_name = 'insert_'.$args['name'];
|
$function_name = 'insert_'.$args['name'];
|
||||||
$content = $function_name($args, $this);
|
$content = $function_name($args, $this);
|
||||||
if ($this->debugging) {
|
if ($this->debugging) {
|
||||||
$this->_smarty_debug_info[] = array('type' => 'insert',
|
$this->_smarty_debug_info[] = array('type' => 'insert',
|
||||||
'filename' => 'insert_'.$args['name'],
|
'filename' => 'insert_'.$args['name'],
|
||||||
'depth' => $this->_inclusion_depth,
|
'depth' => $this->_inclusion_depth,
|
||||||
'exec_time' => $this->_get_microtime() - $debug_start_time);
|
'exec_time' => $this->_get_microtime() - $debug_start_time);
|
||||||
}
|
}
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1205,57 +1204,59 @@ function _run_mod_handler()
|
|||||||
/*======================================================================*\
|
/*======================================================================*\
|
||||||
Function: _write_cache_file
|
Function: _write_cache_file
|
||||||
Purpose: Prepend the cache information to the cache file
|
Purpose: Prepend the cache information to the cache file
|
||||||
and write it to disk
|
and write it to disk
|
||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function _write_cache_file($cache_file,$results)
|
function _write_cache_file($cache_file,$results)
|
||||||
{
|
{
|
||||||
// put the templates involved with this cache in the first line
|
// put the templates involved with this cache in the first line
|
||||||
$cache_info = "SMARTY_CACHE_INFO_HEADER".serialize($this->_cache_info)."\n";
|
$cache_info = 'SMARTY_CACHE_INFO_HEADER'.serialize($this->_cache_info)."\n";
|
||||||
$this->_write_file($cache_file, $cache_info.$results, true);
|
$this->_write_file($cache_file, $cache_info.$results, true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*======================================================================*\
|
/*======================================================================*\
|
||||||
Function: _read_cache_file
|
Function: _read_cache_file
|
||||||
Purpose: See if any of the templates for this cache file
|
Purpose: See if any of the templates for this cache file
|
||||||
have changed or not since the cache was created.
|
have changed or not since the cache was created.
|
||||||
Remove the cache info from the cache results.
|
Remove the cache info from the cache results.
|
||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function _read_cache_file($cache_file,&$results)
|
function _read_cache_file($cache_file,&$results)
|
||||||
{
|
{
|
||||||
$results = $this->_read_file($cache_file);
|
$results = $this->_read_file($cache_file);
|
||||||
|
|
||||||
// get the templates involved with this cache from the first line
|
// get the templates involved with this cache from the first line
|
||||||
$contents = split("\n",$results,2);
|
$contents = explode("\n", $results, 2);
|
||||||
|
|
||||||
if(substr($contents[0],0,24) == 'SMARTY_CACHE_INFO_HEADER') {
|
if (substr($contents[0], 0, 24) == 'SMARTY_CACHE_INFO_HEADER') {
|
||||||
$cache_info = unserialize(substr($contents[0],24));
|
$cache_info = unserialize(substr($contents[0], 24));
|
||||||
$results = $contents[1];
|
$results = $contents[1];
|
||||||
|
|
||||||
if($this->compile_check) {
|
if ($this->compile_check) {
|
||||||
$cache_filemtime = filemtime($cache_file);
|
$cache_filemtime = filemtime($cache_file);
|
||||||
|
|
||||||
foreach($cache_info as $curr_cache_info) {
|
foreach ($cache_info as $curr_cache_info) {
|
||||||
switch ($curr_cache_info[0]) {
|
switch ($curr_cache_info[0]) {
|
||||||
case 'template':
|
case 'template':
|
||||||
$this->_fetch_template_info($curr_cache_info[1], $template_source, $template_timestamp, false);
|
$this->_fetch_template_info($curr_cache_info[1], $template_source, $template_timestamp, false);
|
||||||
if( $cache_filemtime < $template_timestamp) {
|
if($cache_filemtime < $template_timestamp) {
|
||||||
// template file has changed, regenerate cache
|
// template file has changed, regenerate cache
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'config':
|
|
||||||
if( $cache_filemtime < filemtime($this->config_dir.'/'.$curr_cache_info[1])) {
|
case 'config':
|
||||||
// config file file has changed, regenerate cache
|
if ($cache_filemtime < filemtime($this->config_dir.'/'.$curr_cache_info[1])) {
|
||||||
return false;
|
// config file file has changed, regenerate cache
|
||||||
}
|
return false;
|
||||||
break;
|
}
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1279,16 +1280,16 @@ function _run_mod_handler()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*======================================================================*\
|
/*======================================================================*\
|
||||||
Function: _get_microtime
|
Function: _get_microtime
|
||||||
Purpose: Get seconds and microseconds
|
Purpose: Get seconds and microseconds
|
||||||
\*======================================================================*/
|
\*======================================================================*/
|
||||||
function _get_microtime()
|
function _get_microtime()
|
||||||
{
|
{
|
||||||
$mtime = microtime();
|
$mtime = microtime();
|
||||||
$mtime = explode(" ", $mtime);
|
$mtime = explode(" ", $mtime);
|
||||||
$mtime = (double)($mtime[1]) + (double)($mtime[0]);
|
$mtime = (double)($mtime[1]) + (double)($mtime[0]);
|
||||||
return ($mtime);
|
return ($mtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user