Cleaning up code, formatting mostly.

This commit is contained in:
andrey
2001-10-26 14:12:23 +00:00
parent 0554b2b0af
commit e5f8cb1e5a
2 changed files with 570 additions and 568 deletions

View File

@@ -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',
@@ -517,7 +515,7 @@ class Smarty
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);
@@ -574,7 +572,7 @@ class Smarty
// buffering - for speed
if ($display && !$this->caching) {
echo $info_header;
if($this->_process_template($tpl_file, $compile_path))
if ($this->_process_template($tpl_file, $compile_path))
{
if ($this->show_info_include) {
echo "\n<!-- SMARTY_BEGIN: ".$tpl_file." -->\n";
@@ -587,7 +585,7 @@ class Smarty
} else {
ob_start();
echo $info_header;
if($this->_process_template($tpl_file, $compile_path))
if ($this->_process_template($tpl_file, $compile_path))
{
if ($this->show_info_include) {
echo "\n<!-- SMARTY_BEGIN: ".$tpl_file." -->\n";
@@ -671,7 +669,7 @@ function _generate_debug_output() {
$force_compile_orig = $this->force_compile;
$this->force_compile = true;
$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) {
echo "\n<!-- SMARTY_BEGIN: ".$this->debug_tpl." -->\n";
@@ -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);
}
@@ -914,7 +915,7 @@ function _generate_debug_output() {
}
if ($this->caching) {
$this->_cache_info[] = array('template',$_smarty_include_tpl_file);
$this->_cache_info[] = array('template', $_smarty_include_tpl_file);
}
}
@@ -930,10 +931,9 @@ function _generate_debug_output() {
}
if ($this->caching) {
$this->_cache_info[] = array('config',$file);
$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,26 +1226,27 @@ 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));
if (substr($contents[0], 0, 24) == 'SMARTY_CACHE_INFO_HEADER') {
$cache_info = unserialize(substr($contents[0], 24));
$results = $contents[1];
if($this->compile_check) {
if ($this->compile_check) {
$cache_filemtime = filemtime($cache_file);
foreach($cache_info as $curr_cache_info) {
foreach ($cache_info as $curr_cache_info) {
switch ($curr_cache_info[0]) {
case 'template':
$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
return false;
}
break;
case 'config':
if( $cache_filemtime < filemtime($this->config_dir.'/'.$curr_cache_info[1])) {
if ($cache_filemtime < filemtime($this->config_dir.'/'.$curr_cache_info[1])) {
// config file file has changed, regenerate cache
return false;
}
@@ -1255,6 +1255,7 @@ function _run_mod_handler()
}
}
}
return true;
}

View File

@@ -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',
@@ -517,7 +515,7 @@ class Smarty
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);
@@ -574,7 +572,7 @@ class Smarty
// buffering - for speed
if ($display && !$this->caching) {
echo $info_header;
if($this->_process_template($tpl_file, $compile_path))
if ($this->_process_template($tpl_file, $compile_path))
{
if ($this->show_info_include) {
echo "\n<!-- SMARTY_BEGIN: ".$tpl_file." -->\n";
@@ -587,7 +585,7 @@ class Smarty
} else {
ob_start();
echo $info_header;
if($this->_process_template($tpl_file, $compile_path))
if ($this->_process_template($tpl_file, $compile_path))
{
if ($this->show_info_include) {
echo "\n<!-- SMARTY_BEGIN: ".$tpl_file." -->\n";
@@ -671,7 +669,7 @@ function _generate_debug_output() {
$force_compile_orig = $this->force_compile;
$this->force_compile = true;
$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) {
echo "\n<!-- SMARTY_BEGIN: ".$this->debug_tpl." -->\n";
@@ -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);
}
@@ -914,7 +915,7 @@ function _generate_debug_output() {
}
if ($this->caching) {
$this->_cache_info[] = array('template',$_smarty_include_tpl_file);
$this->_cache_info[] = array('template', $_smarty_include_tpl_file);
}
}
@@ -930,10 +931,9 @@ function _generate_debug_output() {
}
if ($this->caching) {
$this->_cache_info[] = array('config',$file);
$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,26 +1226,27 @@ 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));
if (substr($contents[0], 0, 24) == 'SMARTY_CACHE_INFO_HEADER') {
$cache_info = unserialize(substr($contents[0], 24));
$results = $contents[1];
if($this->compile_check) {
if ($this->compile_check) {
$cache_filemtime = filemtime($cache_file);
foreach($cache_info as $curr_cache_info) {
foreach ($cache_info as $curr_cache_info) {
switch ($curr_cache_info[0]) {
case 'template':
$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
return false;
}
break;
case 'config':
if( $cache_filemtime < filemtime($this->config_dir.'/'.$curr_cache_info[1])) {
if ($cache_filemtime < filemtime($this->config_dir.'/'.$curr_cache_info[1])) {
// config file file has changed, regenerate cache
return false;
}
@@ -1255,6 +1255,7 @@ function _run_mod_handler()
}
}
}
return true;
}