cvs: smarty /libs Smarty.class.php Smarty_Compiler.class.php /libs/core core.display_debug_console.php core.fetch_file_info.php
core.parse_file_path.php core.write_compiled_template.php /libs/plugins function.config_load.php
| From: | Monte Ohrt | Date: | Tue, 17 Jun 2003 14:11:57 +0000 |
| Subject: | cvs: smarty /libs Smarty.class.php Smarty_Compiler.class.php /libs/core core.display_debug_console.php core.fetch_file_info.php core.parse_file_path.php core.write_compiled_template.php /libs/plugins function.config_load.php |
||
| Groups: | php.smarty.cvs | ||
| Request: | Send a blank email to php-smarty-cvs+get-652@lists.php.net to get a copy of this message | ||
mohrt Tue Jun 17 10:11:57 2003 EDT
Modified files:
/smarty/libs Smarty.class.php Smarty_Compiler.class.php
/smarty/libs/core core.display_debug_console.php
core.fetch_file_info.php core.parse_file_path.php
core.write_compiled_template.php
/smarty/libs/plugins function.config_load.php
Log:
fix path problems, rename some varibles from "template" to "file"
Index: smarty/libs/Smarty.class.php diff -u smarty/libs/Smarty.class.php:1.404 smarty/libs/Smarty.class.php:1.405 --- smarty/libs/Smarty.class.php:1.404 Mon Jun 16 15:45:10 2003 +++ smarty/libs/Smarty.class.php Tue Jun 17 10:11:56 2003 @@ -42,7 +42,7 @@ * @version 2.5.0 */ -/* $Id: Smarty.class.php,v 1.404 2003/06/16 19:45:10 mohrt Exp $ */ +/* $Id: Smarty.class.php,v 1.405 2003/06/17 14:11:56 mohrt Exp $ */ /** * DIR_SEP isn't used anymore, but third party apps might @@ -1245,20 +1245,19 @@ } } - $_template_file_path = $this->template_dir . '/' . $tpl_file; - $_smarty_compile_path = $this->_get_compile_path($_template_file_path); + $_smarty_compile_path = $this->_get_compile_path($tpl_file); // if we just need to display the results, don't perform output // buffering - for speed if ($display && !$this->caching && count($this->_plugins['outputfilter']) == 0) { - if (!$this->_file_needs_compiling($_template_file_path, $_smarty_compile_path) + if (!$this->_is_compiled($tpl_file, $_smarty_compile_path) || $this->_compile_template($tpl_file, $_smarty_compile_path)) { include($_smarty_compile_path); } } else { ob_start(); - if (!$this->_file_needs_compiling($_template_file_path, $_smarty_compile_path) + if (!$this->_is_compiled($tpl_file, $_smarty_compile_path) || $this->_compile_template($tpl_file, $_smarty_compile_path)) { include($_smarty_compile_path); @@ -1410,7 +1409,7 @@ * @param string $compile_path * @return boolean */ - function _file_needs_compiling($file_path, $compile_path) + function _is_compiled($file_path, $compile_path) { if (!$this->force_compile && file_exists($compile_path)) { if (!$this->compile_check) { @@ -1425,7 +1424,7 @@ } $_file_source = $_params['file_source']; $_file_timestamp = $_params['file_timestamp']; - if ($_template_timestamp <= filemtime($compile_path)) { + if ($_file_timestamp <= filemtime($compile_path)) { // template not expired, no recompile return false; } else { @@ -1448,8 +1447,9 @@ */ function _compile_template($tpl_file, $compile_path) { + // compiled template does not exist, or forced compile - $_params = array('file_path' => $this->template_dir . '/' . $tpl_file); + $_params = array('file_path' => $tpl_file); require_once(SMARTY_DIR . 'core/core.fetch_file_info.php'); if (!smarty_core_fetch_file_info($_params, $this)) { return false; @@ -1491,7 +1491,7 @@ $smarty_compiler->request_use_auto_globals = $this->request_use_auto_globals; if ($smarty_compiler->_compile_file($tpl_file, $_file_source, $_file_compiled)) { - $_params = array('compile_path' => $compile_path, 'template_compiled' => $_file_compiled, 'template_timestamp' => $_file_timestamp); + $_params = array('compile_path' => $compile_path, 'file_compiled' => $_file_compiled, 'file_timestamp' => $_file_timestamp); require_once(SMARTY_DIR . 'core/core.write_compiled_template.php'); smarty_core_write_compiled_template($_params, $this); return true; Index: smarty/libs/Smarty_Compiler.class.php diff -u smarty/libs/Smarty_Compiler.class.php:1.240 smarty/libs/Smarty_Compiler.class.php:1.241 --- smarty/libs/Smarty_Compiler.class.php:1.240 Mon Jun 16 15:45:10 2003 +++ smarty/libs/Smarty_Compiler.class.php Tue Jun 17 10:11:57 2003 @@ -39,7 +39,7 @@ * @package Smarty */ -/* $Id: Smarty_Compiler.class.php,v 1.240 2003/06/16 19:45:10 mohrt Exp $ */ +/* $Id: Smarty_Compiler.class.php,v 1.241 2003/06/17 14:11:57 mohrt Exp $ */ /** * Template compiling class * @package Smarty @@ -206,13 +206,13 @@ /** * compile a template file * - * sets $template_compiled to the compiled source + * sets $file_compiled to the compiled source * @param string $tpl_file - * @param string $template_source - * @param string $template_compiled + * @param string $file_source + * @param string $file_compiled * @return true */ - function _compile_file($tpl_file, $template_source, &$template_compiled) + function _compile_file($tpl_file, $file_source, &$file_compiled) { if ($this->security) { @@ -235,8 +235,8 @@ foreach ($this->_plugins['prefilter'] as $filter_name => $prefilter) { if ($prefilter === false) continue; if ($prefilter[3] || $this->_plugin_implementation_exists($prefilter[0])) { - $template_source = call_user_func_array($prefilter[0], - array($template_source, &$this)); + $file_source = call_user_func_array($prefilter[0], + array($file_source, &$this)); $this->_plugins['prefilter'][$filter_name][3] = true; } else { $this->_trigger_fatal_error("[plugin] prefilter '$filter_name' is not implemented"); @@ -245,27 +245,27 @@ } /* Annihilate the comments. */ - $template_source = preg_replace("!({$ldq})\*(.*?)\*({$rdq})!se", + $file_source = preg_replace("!({$ldq})\*(.*?)\*({$rdq})!se", "'\\1*'.str_repeat(\"\n\", substr_count('\\2', \"\n\")) .'*\\3'", - $template_source); + $file_source); /* Pull out the literal blocks. */ - preg_match_all("!{$ldq}\s*literal\s*{$rdq}(.*?){$ldq}\s*/literal\s*{$rdq}!s", $template_source, $_match); + preg_match_all("!{$ldq}\s*literal\s*{$rdq}(.*?){$ldq}\s*/literal\s*{$rdq}!s", $file_source, $_match); $this->_literal_blocks = $_match[1]; - $template_source = preg_replace("!{$ldq}\s*literal\s*{$rdq}(.*?){$ldq}\s*/literal\s*{$rdq}!s", - $this->quote_replace($this->left_delimiter.'literal'.$this->right_delimiter), $template_source); + $file_source = preg_replace("!{$ldq}\s*literal\s*{$rdq}(.*?){$ldq}\s*/literal\s*{$rdq}!s", + $this->quote_replace($this->left_delimiter.'literal'.$this->right_delimiter), $file_source); /* Pull out the php code blocks. */ - preg_match_all("!{$ldq}php{$rdq}(.*?){$ldq}/php{$rdq}!s", $template_source, $_match); + preg_match_all("!{$ldq}php{$rdq}(.*?){$ldq}/php{$rdq}!s", $file_source, $_match); $this->_php_blocks = $_match[1]; - $template_source = preg_replace("!{$ldq}php{$rdq}(.*?){$ldq}/php{$rdq}!s", - $this->quote_replace($this->left_delimiter.'php'.$this->right_delimiter), $template_source); + $file_source = preg_replace("!{$ldq}php{$rdq}(.*?){$ldq}/php{$rdq}!s", + $this->quote_replace($this->left_delimiter.'php'.$this->right_delimiter), $file_source); /* Gather all template tags. */ - preg_match_all("!{$ldq}\s*(.*?)\s*{$rdq}!s", $template_source, $_match); + preg_match_all("!{$ldq}\s*(.*?)\s*{$rdq}!s", $file_source, $_match); $template_tags = $_match[1]; /* Split content by template tags to obtain non-template content. */ - $text_blocks = preg_split("!{$ldq}.*?{$rdq}!s", $template_source); + $text_blocks = preg_split("!{$ldq}.*?{$rdq}!s", $file_source); /* loop through text blocks */ for ($curr_tb = 0, $for_max = count($text_blocks); $curr_tb < $for_max; $curr_tb++) { @@ -305,7 +305,7 @@ $this->_current_line_no += substr_count($template_tags[$i], "\n"); } - $template_compiled = ''; + $file_compiled = ''; /* Interleave the compiled contents and text blocks to get the final result. */ for ($i = 0, $for_max = count($compiled_tags); $i < $for_max; $i++) { @@ -313,25 +313,25 @@ // tag result empty, remove first newline from following text block $text_blocks[$i+1] = preg_replace('!^(\r\n|\r|\n)!', '', $text_blocks[$i+1]); } - $template_compiled .= $text_blocks[$i].$compiled_tags[$i]; + $file_compiled .= $text_blocks[$i].$compiled_tags[$i]; } - $template_compiled .= $text_blocks[$i]; + $file_compiled .= $text_blocks[$i]; // remove \n from the end of the file, if any - if ($template_compiled{strlen($template_compiled) - 1} == "\n" ) { - $template_compiled = substr($template_compiled, 0, -1); + if ($file_compiled{strlen($file_compiled) - 1} == "\n" ) { + $file_compiled = substr($file_compiled, 0, -1); } // remove unnecessary close/open tags - $template_compiled = preg_replace('!\?>\n?<\?php!', '', $template_compiled); + $file_compiled = preg_replace('!\?>\n?<\?php!', '', $file_compiled); // run compiled template through postfilter functions if (count($this->_plugins['postfilter']) > 0) { foreach ($this->_plugins['postfilter'] as $filter_name => $postfilter) { if ($postfilter === false) continue; if ($postfilter[3] || $this->_plugin_implementation_exists($postfilter[0])) { - $template_compiled = call_user_func_array($postfilter[0], - array($template_compiled, &$this)); + $file_compiled = call_user_func_array($postfilter[0], + array($file_compiled, &$this)); $this->_plugins['postfilter'][$filter_name][3] = true; } else { $this->_trigger_fatal_error("Smarty plugin error: postfilter '$filter_name' is not implemented"); @@ -363,7 +363,7 @@ $this->_init_smarty_vars = false; } - $template_compiled = $template_header . $template_compiled; + $file_compiled = $template_header . $file_compiled; return true; } Index: smarty/libs/core/core.display_debug_console.php diff -u smarty/libs/core/core.display_debug_console.php:1.1 smarty/libs/core/core.display_debug_console.php:1.2 --- smarty/libs/core/core.display_debug_console.php:1.1 Mon Jun 16 11:18:38 2003 +++ smarty/libs/core/core.display_debug_console.php Tue Jun 17 10:11:57 2003 @@ -33,13 +33,11 @@ $this->left_delimiter = '{'; $this->right_delimiter = '}'; - $_force_compile_orig = $this->force_compile; - $this->force_compile = true; $_compile_id_orig = $this->_compile_id; $this->_compile_id = null; $_compile_path = $this->_get_compile_path($this->debug_tpl); - if ($this->_process_template($this->debug_tpl, $_compile_path)) + if ($this->_compile_template($this->debug_tpl, $_compile_path)) { ob_start(); include($_compile_path); @@ -49,7 +47,6 @@ $_results = ''; } - $this->force_compile = $_force_compile_orig; $this->_compile_id = $_compile_id_orig; $this->left_delimiter = $_ldelim_orig; Index: smarty/libs/core/core.fetch_file_info.php diff -u smarty/libs/core/core.fetch_file_info.php:1.1 smarty/libs/core/core.fetch_file_info.php:1.2 --- smarty/libs/core/core.fetch_file_info.php:1.1 Mon Jun 16 17:43:07 2003 +++ smarty/libs/core/core.fetch_file_info.php Tue Jun 17 10:11:57 2003 @@ -19,11 +19,9 @@ * @return boolean */ -// $tpl_path, &$template_source, &$template_timestamp, $get_source = true, $quiet = false - function smarty_core_fetch_file_info(&$params, &$this) { - + if(!isset($params['get_source'])) { $params['get_source'] = true; } if(!isset($params['quiet'])) { $params['quiet'] = false; } @@ -60,7 +58,7 @@ break; } } - + if (!$_return) { // see if we can get a template with the default template handler if (!empty($this->default_template_handler_func)) { @@ -77,7 +75,7 @@ require_once(SMARTY_DIR . 'core/core.is_secure.php'); if (!$_return) { if (!$params['quiet']) { - $this->trigger_error('unable to read template resource: "' . $params['file_path'] . '"'); + $this->trigger_error('unable to read file resource: "' . $params['file_path'] . '"'); } } else if ($_return && $this->security && !smarty_core_is_secure($_params, $this)) { if (!$params['quiet']) Index: smarty/libs/core/core.parse_file_path.php diff -u smarty/libs/core/core.parse_file_path.php:1.2 smarty/libs/core/core.parse_file_path.php:1.3 --- smarty/libs/core/core.parse_file_path.php:1.2 Mon Jun 16 15:45:11 2003 +++ smarty/libs/core/core.parse_file_path.php Tue Jun 17 10:11:57 2003 @@ -42,7 +42,7 @@ if (!preg_match("/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/", $params['resource_name'])) { // relative pathname to $params['file_base_path'] // use the first directory where the file is found - $_file_base_path = isset($params['file_base_path']) ? $params['file_base_path'] : array('.'); + $_file_base_path = isset($params['file_base_path']) ? $params['file_base_path'] : array($this->template_dir, '.'); settype($_file_base_path, 'array'); foreach ($_file_base_path as $_curr_path) { $_fullpath = $_curr_path . DIRECTORY_SEPARATOR . $params['resource_name']; Index: smarty/libs/core/core.write_compiled_template.php diff -u smarty/libs/core/core.write_compiled_template.php:1.1 smarty/libs/core/core.write_compiled_template.php:1.2 --- smarty/libs/core/core.write_compiled_template.php:1.1 Mon Jun 16 11:18:38 2003 +++ smarty/libs/core/core.write_compiled_template.php Tue Jun 17 10:11:57 2003 @@ -9,12 +9,12 @@ * write the compiled template * * @param string $compile_path - * @param string $template_compiled - * @param integer $template_timestamp + * @param string $file_compiled + * @param integer $file_timestamp * @return true */ function smarty_core_write_compiled_template($params, &$this) -{ +{ if(!@is_writable($this->compile_dir)) { // compile_dir not writable, see if it exists if(!@is_dir($this->compile_dir)) { @@ -25,10 +25,10 @@ return false; } - $_params = array('filename' => $params['compile_path'], 'contents' => $params['template_compiled'], 'create_dirs' => true); + $_params = array('filename' => $params['compile_path'], 'contents' => $params['file_compiled'], 'create_dirs' => true); require_once(SMARTY_DIR . 'core/core.write_file.php'); smarty_core_write_file($_params, $this); - touch($params['compile_path'], $params['template_timestamp']); + touch($params['compile_path'], $params['file_timestamp']); return true; } Index: smarty/libs/plugins/function.config_load.php diff -u smarty/libs/plugins/function.config_load.php:1.8 smarty/libs/plugins/function.config_load.php:1.9 --- smarty/libs/plugins/function.config_load.php:1.8 Mon Jun 16 15:45:11 2003 +++ smarty/libs/plugins/function.config_load.php Tue Jun 17 10:11:57 2003 @@ -63,12 +63,13 @@ $_config_dir = $_params['new_file_path']; } - $_compile_file = $smarty->_get_compile_path($_config_dir . '/' . $_file); + $_file_path = $_config_dir . '/' . $_file; + $_compile_file = $smarty->_get_compile_path($_file_path); if($smarty->force_compile || !file_exists($_compile_file) || ($smarty->compile_check - && $smarty->_file_needs_compiling($_config_dir . '/' . $_file, $_compile_file))) { + && $smarty->_is_compiled($_file_path, $_compile_file))) { // compile config file if(!is_object($smarty->_conf_obj)) { require_once SMARTY_DIR . $smarty->config_class . '.class.php'; @@ -86,7 +87,7 @@ } else { $_output = '<?php $_config_vars = unserialize(' . serialize($_config_vars) . '); ?>'; } - $_params = (array('compile_path' => $_compile_file, 'template_compiled' => $_output)); + $_params = (array('compile_path' => $_compile_file, 'file_compiled' => $_output, 'file_timestamp' => filemtime($_file_path))); require_once(SMARTY_DIR . 'core/core.write_compiled_template.php'); smarty_core_write_compiled_template($_params, $smarty); } else {
Index: smarty/libs/Smarty.class.php diff -u smarty/libs/Smarty.class.php:1.404 smarty/libs/Smarty.class.php:1.405 --- smarty/libs/Smarty.class.php:1.404 Mon Jun 16 15:45:10 2003 +++ smarty/libs/Smarty.class.php Tue Jun 17 10:11:56 2003 @@ -42,7 +42,7 @@ * @version 2.5.0 */ -/* $Id: Smarty.class.php,v 1.404 2003/06/16 19:45:10 mohrt Exp $ */ +/* $Id: Smarty.class.php,v 1.405 2003/06/17 14:11:56 mohrt Exp $ */ /** * DIR_SEP isn't used anymore, but third party apps might @@ -1245,20 +1245,19 @@ } } - $_template_file_path = $this->template_dir . '/' . $tpl_file; - $_smarty_compile_path = $this->_get_compile_path($_template_file_path); + $_smarty_compile_path = $this->_get_compile_path($tpl_file); // if we just need to display the results, don't perform output // buffering - for speed if ($display && !$this->caching && count($this->_plugins['outputfilter']) == 0) { - if (!$this->_file_needs_compiling($_template_file_path, $_smarty_compile_path) + if (!$this->_is_compiled($tpl_file, $_smarty_compile_path) || $this->_compile_template($tpl_file, $_smarty_compile_path)) { include($_smarty_compile_path); } } else { ob_start(); - if (!$this->_file_needs_compiling($_template_file_path, $_smarty_compile_path) + if (!$this->_is_compiled($tpl_file, $_smarty_compile_path) || $this->_compile_template($tpl_file, $_smarty_compile_path)) { include($_smarty_compile_path); @@ -1410,7 +1409,7 @@ * @param string $compile_path * @return boolean */ - function _file_needs_compiling($file_path, $compile_path) + function _is_compiled($file_path, $compile_path) { if (!$this->force_compile && file_exists($compile_path)) { if (!$this->compile_check) { @@ -1425,7 +1424,7 @@ } $_file_source = $_params['file_source']; $_file_timestamp = $_params['file_timestamp']; - if ($_template_timestamp <= filemtime($compile_path)) { + if ($_file_timestamp <= filemtime($compile_path)) { // template not expired, no recompile return false; } else { @@ -1448,8 +1447,9 @@ */ function _compile_template($tpl_file, $compile_path) { + // compiled template does not exist, or forced compile - $_params = array('file_path' => $this->template_dir . '/' . $tpl_file); + $_params = array('file_path' => $tpl_file); require_once(SMARTY_DIR . 'core/core.fetch_file_info.php'); if (!smarty_core_fetch_file_info($_params, $this)) { return false; @@ -1491,7 +1491,7 @@ $smarty_compiler->request_use_auto_globals = $this->request_use_auto_globals; if ($smarty_compiler->_compile_file($tpl_file, $_file_source, $_file_compiled)) { - $_params = array('compile_path' => $compile_path, 'template_compiled' => $_file_compiled, 'template_timestamp' => $_file_timestamp); + $_params = array('compile_path' => $compile_path, 'file_compiled' => $_file_compiled, 'file_timestamp' => $_file_timestamp); require_once(SMARTY_DIR . 'core/core.write_compiled_template.php'); smarty_core_write_compiled_template($_params, $this); return true; Index: smarty/libs/Smarty_Compiler.class.php diff -u smarty/libs/Smarty_Compiler.class.php:1.240 smarty/libs/Smarty_Compiler.class.php:1.241 --- smarty/libs/Smarty_Compiler.class.php:1.240 Mon Jun 16 15:45:10 2003 +++ smarty/libs/Smarty_Compiler.class.php Tue Jun 17 10:11:57 2003 @@ -39,7 +39,7 @@ * @package Smarty */ -/* $Id: Smarty_Compiler.class.php,v 1.240 2003/06/16 19:45:10 mohrt Exp $ */ +/* $Id: Smarty_Compiler.class.php,v 1.241 2003/06/17 14:11:57 mohrt Exp $ */ /** * Template compiling class * @package Smarty @@ -206,13 +206,13 @@ /** * compile a template file * - * sets $template_compiled to the compiled source + * sets $file_compiled to the compiled source * @param string $tpl_file - * @param string $template_source - * @param string $template_compiled + * @param string $file_source + * @param string $file_compiled * @return true */ - function _compile_file($tpl_file, $template_source, &$template_compiled) + function _compile_file($tpl_file, $file_source, &$file_compiled) { if ($this->security) { @@ -235,8 +235,8 @@ foreach ($this->_plugins['prefilter'] as $filter_name => $prefilter) { if ($prefilter === false) continue; if ($prefilter[3] || $this->_plugin_implementation_exists($prefilter[0])) { - $template_source = call_user_func_array($prefilter[0], - array($template_source, &$this)); + $file_source = call_user_func_array($prefilter[0], + array($file_source, &$this)); $this->_plugins['prefilter'][$filter_name][3] = true; } else { $this->_trigger_fatal_error("[plugin] prefilter '$filter_name' is not implemented"); @@ -245,27 +245,27 @@ } /* Annihilate the comments. */ - $template_source = preg_replace("!({$ldq})\*(.*?)\*({$rdq})!se", + $file_source = preg_replace("!({$ldq})\*(.*?)\*({$rdq})!se", "'\\1*'.str_repeat(\"\n\", substr_count('\\2', \"\n\")) .'*\\3'", - $template_source); + $file_source); /* Pull out the literal blocks. */ - preg_match_all("!{$ldq}\s*literal\s*{$rdq}(.*?){$ldq}\s*/literal\s*{$rdq}!s", $template_source, $_match); + preg_match_all("!{$ldq}\s*literal\s*{$rdq}(.*?){$ldq}\s*/literal\s*{$rdq}!s", $file_source, $_match); $this->_literal_blocks = $_match[1]; - $template_source = preg_replace("!{$ldq}\s*literal\s*{$rdq}(.*?){$ldq}\s*/literal\s*{$rdq}!s", - $this->quote_replace($this->left_delimiter.'literal'.$this->right_delimiter), $template_source); + $file_source = preg_replace("!{$ldq}\s*literal\s*{$rdq}(.*?){$ldq}\s*/literal\s*{$rdq}!s", + $this->quote_replace($this->left_delimiter.'literal'.$this->right_delimiter), $file_source); /* Pull out the php code blocks. */ - preg_match_all("!{$ldq}php{$rdq}(.*?){$ldq}/php{$rdq}!s", $template_source, $_match); + preg_match_all("!{$ldq}php{$rdq}(.*?){$ldq}/php{$rdq}!s", $file_source, $_match); $this->_php_blocks = $_match[1]; - $template_source = preg_replace("!{$ldq}php{$rdq}(.*?){$ldq}/php{$rdq}!s", - $this->quote_replace($this->left_delimiter.'php'.$this->right_delimiter), $template_source); + $file_source = preg_replace("!{$ldq}php{$rdq}(.*?){$ldq}/php{$rdq}!s", + $this->quote_replace($this->left_delimiter.'php'.$this->right_delimiter), $file_source); /* Gather all template tags. */ - preg_match_all("!{$ldq}\s*(.*?)\s*{$rdq}!s", $template_source, $_match); + preg_match_all("!{$ldq}\s*(.*?)\s*{$rdq}!s", $file_source, $_match); $template_tags = $_match[1]; /* Split content by template tags to obtain non-template content. */ - $text_blocks = preg_split("!{$ldq}.*?{$rdq}!s", $template_source); + $text_blocks = preg_split("!{$ldq}.*?{$rdq}!s", $file_source); /* loop through text blocks */ for ($curr_tb = 0, $for_max = count($text_blocks); $curr_tb < $for_max; $curr_tb++) { @@ -305,7 +305,7 @@ $this->_current_line_no += substr_count($template_tags[$i], "\n"); } - $template_compiled = ''; + $file_compiled = ''; /* Interleave the compiled contents and text blocks to get the final result. */ for ($i = 0, $for_max = count($compiled_tags); $i < $for_max; $i++) { @@ -313,25 +313,25 @@ // tag result empty, remove first newline from following text block $text_blocks[$i+1] = preg_replace('!^(\r\n|\r|\n)!', '', $text_blocks[$i+1]); } - $template_compiled .= $text_blocks[$i].$compiled_tags[$i]; + $file_compiled .= $text_blocks[$i].$compiled_tags[$i]; } - $template_compiled .= $text_blocks[$i]; + $file_compiled .= $text_blocks[$i]; // remove \n from the end of the file, if any - if ($template_compiled{strlen($template_compiled) - 1} == "\n" ) { - $template_compiled = substr($template_compiled, 0, -1); + if ($file_compiled{strlen($file_compiled) - 1} == "\n" ) { + $file_compiled = substr($file_compiled, 0, -1); } // remove unnecessary close/open tags - $template_compiled = preg_replace('!\?>\n?<\?php!', '', $template_compiled); + $file_compiled = preg_replace('!\?>\n?<\?php!', '', $file_compiled); // run compiled template through postfilter functions if (count($this->_plugins['postfilter']) > 0) { foreach ($this->_plugins['postfilter'] as $filter_name => $postfilter) { if ($postfilter === false) continue; if ($postfilter[3] || $this->_plugin_implementation_exists($postfilter[0])) { - $template_compiled = call_user_func_array($postfilter[0], - array($template_compiled, &$this)); + $file_compiled = call_user_func_array($postfilter[0], + array($file_compiled, &$this)); $this->_plugins['postfilter'][$filter_name][3] = true; } else { $this->_trigger_fatal_error("Smarty plugin error: postfilter '$filter_name' is not implemented"); @@ -363,7 +363,7 @@ $this->_init_smarty_vars = false; } - $template_compiled = $template_header . $template_compiled; + $file_compiled = $template_header . $file_compiled; return true; } Index: smarty/libs/core/core.display_debug_console.php diff -u smarty/libs/core/core.display_debug_console.php:1.1 smarty/libs/core/core.display_debug_console.php:1.2 --- smarty/libs/core/core.display_debug_console.php:1.1 Mon Jun 16 11:18:38 2003 +++ smarty/libs/core/core.display_debug_console.php Tue Jun 17 10:11:57 2003 @@ -33,13 +33,11 @@ $this->left_delimiter = '{'; $this->right_delimiter = '}'; - $_force_compile_orig = $this->force_compile; - $this->force_compile = true; $_compile_id_orig = $this->_compile_id; $this->_compile_id = null; $_compile_path = $this->_get_compile_path($this->debug_tpl); - if ($this->_process_template($this->debug_tpl, $_compile_path)) + if ($this->_compile_template($this->debug_tpl, $_compile_path)) { ob_start(); include($_compile_path); @@ -49,7 +47,6 @@ $_results = ''; } - $this->force_compile = $_force_compile_orig; $this->_compile_id = $_compile_id_orig; $this->left_delimiter = $_ldelim_orig; Index: smarty/libs/core/core.fetch_file_info.php diff -u smarty/libs/core/core.fetch_file_info.php:1.1 smarty/libs/core/core.fetch_file_info.php:1.2 --- smarty/libs/core/core.fetch_file_info.php:1.1 Mon Jun 16 17:43:07 2003 +++ smarty/libs/core/core.fetch_file_info.php Tue Jun 17 10:11:57 2003 @@ -19,11 +19,9 @@ * @return boolean */ -// $tpl_path, &$template_source, &$template_timestamp, $get_source = true, $quiet = false - function smarty_core_fetch_file_info(&$params, &$this) { - + if(!isset($params['get_source'])) { $params['get_source'] = true; } if(!isset($params['quiet'])) { $params['quiet'] = false; } @@ -60,7 +58,7 @@ break; } } - + if (!$_return) { // see if we can get a template with the default template handler if (!empty($this->default_template_handler_func)) { @@ -77,7 +75,7 @@ require_once(SMARTY_DIR . 'core/core.is_secure.php'); if (!$_return) { if (!$params['quiet']) { - $this->trigger_error('unable to read template resource: "' . $params['file_path'] . '"'); + $this->trigger_error('unable to read file resource: "' . $params['file_path'] . '"'); } } else if ($_return && $this->security && !smarty_core_is_secure($_params, $this)) { if (!$params['quiet']) Index: smarty/libs/core/core.parse_file_path.php diff -u smarty/libs/core/core.parse_file_path.php:1.2 smarty/libs/core/core.parse_file_path.php:1.3 --- smarty/libs/core/core.parse_file_path.php:1.2 Mon Jun 16 15:45:11 2003 +++ smarty/libs/core/core.parse_file_path.php Tue Jun 17 10:11:57 2003 @@ -42,7 +42,7 @@ if (!preg_match("/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/", $params['resource_name'])) { // relative pathname to $params['file_base_path'] // use the first directory where the file is found - $_file_base_path = isset($params['file_base_path']) ? $params['file_base_path'] : array('.'); + $_file_base_path = isset($params['file_base_path']) ? $params['file_base_path'] : array($this->template_dir, '.'); settype($_file_base_path, 'array'); foreach ($_file_base_path as $_curr_path) { $_fullpath = $_curr_path . DIRECTORY_SEPARATOR . $params['resource_name']; Index: smarty/libs/core/core.write_compiled_template.php diff -u smarty/libs/core/core.write_compiled_template.php:1.1 smarty/libs/core/core.write_compiled_template.php:1.2 --- smarty/libs/core/core.write_compiled_template.php:1.1 Mon Jun 16 11:18:38 2003 +++ smarty/libs/core/core.write_compiled_template.php Tue Jun 17 10:11:57 2003 @@ -9,12 +9,12 @@ * write the compiled template * * @param string $compile_path - * @param string $template_compiled - * @param integer $template_timestamp + * @param string $file_compiled + * @param integer $file_timestamp * @return true */ function smarty_core_write_compiled_template($params, &$this) -{ +{ if(!@is_writable($this->compile_dir)) { // compile_dir not writable, see if it exists if(!@is_dir($this->compile_dir)) { @@ -25,10 +25,10 @@ return false; } - $_params = array('filename' => $params['compile_path'], 'contents' => $params['template_compiled'], 'create_dirs' => true); + $_params = array('filename' => $params['compile_path'], 'contents' => $params['file_compiled'], 'create_dirs' => true); require_once(SMARTY_DIR . 'core/core.write_file.php'); smarty_core_write_file($_params, $this); - touch($params['compile_path'], $params['template_timestamp']); + touch($params['compile_path'], $params['file_timestamp']); return true; } Index: smarty/libs/plugins/function.config_load.php diff -u smarty/libs/plugins/function.config_load.php:1.8 smarty/libs/plugins/function.config_load.php:1.9 --- smarty/libs/plugins/function.config_load.php:1.8 Mon Jun 16 15:45:11 2003 +++ smarty/libs/plugins/function.config_load.php Tue Jun 17 10:11:57 2003 @@ -63,12 +63,13 @@ $_config_dir = $_params['new_file_path']; } - $_compile_file = $smarty->_get_compile_path($_config_dir . '/' . $_file); + $_file_path = $_config_dir . '/' . $_file; + $_compile_file = $smarty->_get_compile_path($_file_path); if($smarty->force_compile || !file_exists($_compile_file) || ($smarty->compile_check - && $smarty->_file_needs_compiling($_config_dir . '/' . $_file, $_compile_file))) { + && $smarty->_is_compiled($_file_path, $_compile_file))) { // compile config file if(!is_object($smarty->_conf_obj)) { require_once SMARTY_DIR . $smarty->config_class . '.class.php'; @@ -86,7 +87,7 @@ } else { $_output = '<?php $_config_vars = unserialize(' . serialize($_config_vars) . '); ?>'; } - $_params = (array('compile_path' => $_compile_file, 'template_compiled' => $_output)); + $_params = (array('compile_path' => $_compile_file, 'file_compiled' => $_output, 'file_timestamp' => filemtime($_file_path))); require_once(SMARTY_DIR . 'core/core.write_compiled_template.php'); smarty_core_write_compiled_template($_params, $smarty); } else {