mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 02:14:26 +02:00
Cleaning up code, formatting mostly.
This commit is contained in:
@@ -43,16 +43,16 @@
|
||||
// set SMARTY_DIR to absolute path to Smarty library files.
|
||||
// if not defined, include_path will be used.
|
||||
|
||||
if(!defined("SMARTY_DIR")) {
|
||||
define("SMARTY_DIR","");
|
||||
if (!defined('SMARTY_DIR')) {
|
||||
define('SMARTY_DIR', '');
|
||||
}
|
||||
|
||||
require_once SMARTY_DIR.'Smarty.addons.php';
|
||||
|
||||
define("SMARTY_PHP_PASSTHRU",0);
|
||||
define("SMARTY_PHP_QUOTE",1);
|
||||
define("SMARTY_PHP_REMOVE",2);
|
||||
define("SMARTY_PHP_ALLOW",3);
|
||||
define('SMARTY_PHP_PASSTHRU', 0);
|
||||
define('SMARTY_PHP_QUOTE', 1);
|
||||
define('SMARTY_PHP_REMOVE', 2);
|
||||
define('SMARTY_PHP_ALLOW', 3);
|
||||
|
||||
class Smarty
|
||||
{
|
||||
@@ -496,13 +496,11 @@ class Smarty
|
||||
global $HTTP_SERVER_VARS, $QUERY_STRING, $HTTP_COOKIE_VARS;
|
||||
|
||||
if ($this->debugging_ctrl == 'URL'
|
||||
&& (!empty($QUERY_STRING)
|
||||
&& strstr($QUERY_STRING,$this->_smarty_debug_id))) {
|
||||
&& (!empty($QUERY_STRING) && strstr($QUERY_STRING,$this->_smarty_debug_id))) {
|
||||
$this->debugging = true;
|
||||
}
|
||||
|
||||
if($this->debugging)
|
||||
{
|
||||
if($this->debugging) {
|
||||
// capture time for debugging info
|
||||
$debug_start_time = $this->_get_microtime();
|
||||
$this->_smarty_debug_info[] = array('type' => 'template',
|
||||
@@ -700,7 +698,8 @@ function _generate_debug_output() {
|
||||
return true;
|
||||
} else {
|
||||
// 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,
|
||||
$template_timestamp)) {
|
||||
return false;
|
||||
}
|
||||
if ($template_timestamp <= $this->_fetch_compiled_template_timestamp($compile_path)) {
|
||||
@@ -715,7 +714,8 @@ function _generate_debug_output() {
|
||||
}
|
||||
} else {
|
||||
// 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,
|
||||
$template_timestamp)) {
|
||||
return false;
|
||||
}
|
||||
$this->_compile_template($tpl_file, $template_source, $template_compiled);
|
||||
@@ -730,7 +730,8 @@ function _generate_debug_output() {
|
||||
\*======================================================================*/
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -933,7 +934,6 @@ function _generate_debug_output() {
|
||||
$this->_cache_info[] = array('config', $file);
|
||||
}
|
||||
|
||||
|
||||
$this->_config[0] = array_merge($this->_config[0], $this->_conf_obj->get($file));
|
||||
if ($scope == 'parent') {
|
||||
if (count($this->_config) > 0)
|
||||
@@ -994,7 +994,6 @@ function _generate_debug_output() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
@@ -1210,7 +1209,7 @@ function _run_mod_handler()
|
||||
function _write_cache_file($cache_file,$results)
|
||||
{
|
||||
// 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);
|
||||
|
||||
return true;
|
||||
@@ -1227,7 +1226,7 @@ function _run_mod_handler()
|
||||
$results = $this->_read_file($cache_file);
|
||||
|
||||
// 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') {
|
||||
$cache_info = unserialize(substr($contents[0], 24));
|
||||
@@ -1245,6 +1244,7 @@ function _run_mod_handler()
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'config':
|
||||
if ($cache_filemtime < filemtime($this->config_dir.'/'.$curr_cache_info[1])) {
|
||||
// config file file has changed, regenerate cache
|
||||
@@ -1255,6 +1255,7 @@ function _run_mod_handler()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -43,16 +43,16 @@
|
||||
// set SMARTY_DIR to absolute path to Smarty library files.
|
||||
// if not defined, include_path will be used.
|
||||
|
||||
if(!defined("SMARTY_DIR")) {
|
||||
define("SMARTY_DIR","");
|
||||
if (!defined('SMARTY_DIR')) {
|
||||
define('SMARTY_DIR', '');
|
||||
}
|
||||
|
||||
require_once SMARTY_DIR.'Smarty.addons.php';
|
||||
|
||||
define("SMARTY_PHP_PASSTHRU",0);
|
||||
define("SMARTY_PHP_QUOTE",1);
|
||||
define("SMARTY_PHP_REMOVE",2);
|
||||
define("SMARTY_PHP_ALLOW",3);
|
||||
define('SMARTY_PHP_PASSTHRU', 0);
|
||||
define('SMARTY_PHP_QUOTE', 1);
|
||||
define('SMARTY_PHP_REMOVE', 2);
|
||||
define('SMARTY_PHP_ALLOW', 3);
|
||||
|
||||
class Smarty
|
||||
{
|
||||
@@ -496,13 +496,11 @@ class Smarty
|
||||
global $HTTP_SERVER_VARS, $QUERY_STRING, $HTTP_COOKIE_VARS;
|
||||
|
||||
if ($this->debugging_ctrl == 'URL'
|
||||
&& (!empty($QUERY_STRING)
|
||||
&& strstr($QUERY_STRING,$this->_smarty_debug_id))) {
|
||||
&& (!empty($QUERY_STRING) && strstr($QUERY_STRING,$this->_smarty_debug_id))) {
|
||||
$this->debugging = true;
|
||||
}
|
||||
|
||||
if($this->debugging)
|
||||
{
|
||||
if($this->debugging) {
|
||||
// capture time for debugging info
|
||||
$debug_start_time = $this->_get_microtime();
|
||||
$this->_smarty_debug_info[] = array('type' => 'template',
|
||||
@@ -700,7 +698,8 @@ function _generate_debug_output() {
|
||||
return true;
|
||||
} else {
|
||||
// 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,
|
||||
$template_timestamp)) {
|
||||
return false;
|
||||
}
|
||||
if ($template_timestamp <= $this->_fetch_compiled_template_timestamp($compile_path)) {
|
||||
@@ -715,7 +714,8 @@ function _generate_debug_output() {
|
||||
}
|
||||
} else {
|
||||
// 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,
|
||||
$template_timestamp)) {
|
||||
return false;
|
||||
}
|
||||
$this->_compile_template($tpl_file, $template_source, $template_compiled);
|
||||
@@ -730,7 +730,8 @@ function _generate_debug_output() {
|
||||
\*======================================================================*/
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -933,7 +934,6 @@ function _generate_debug_output() {
|
||||
$this->_cache_info[] = array('config', $file);
|
||||
}
|
||||
|
||||
|
||||
$this->_config[0] = array_merge($this->_config[0], $this->_conf_obj->get($file));
|
||||
if ($scope == 'parent') {
|
||||
if (count($this->_config) > 0)
|
||||
@@ -994,7 +994,6 @@ function _generate_debug_output() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
@@ -1210,7 +1209,7 @@ function _run_mod_handler()
|
||||
function _write_cache_file($cache_file,$results)
|
||||
{
|
||||
// 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);
|
||||
|
||||
return true;
|
||||
@@ -1227,7 +1226,7 @@ function _run_mod_handler()
|
||||
$results = $this->_read_file($cache_file);
|
||||
|
||||
// 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') {
|
||||
$cache_info = unserialize(substr($contents[0], 24));
|
||||
@@ -1245,6 +1244,7 @@ function _run_mod_handler()
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'config':
|
||||
if ($cache_filemtime < filemtime($this->config_dir.'/'.$curr_cache_info[1])) {
|
||||
// config file file has changed, regenerate cache
|
||||
@@ -1255,6 +1255,7 @@ function _run_mod_handler()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user