cvs: smarty /libs Smarty.class.php Smarty_Compiler.class.php /libs/core core.write_cache_paths_file.php
"Monte Ohrt" <[email protected]>
| Newsgroups | gmane.comp.php.cvs.smarty |
|---|---|
| Message-ID | <cvsmohrt1056403893@cvsserver> |
mohrt Mon Jun 23 17:31:33 2003 EDT
Modified files:
/smarty/libs Smarty.class.php Smarty_Compiler.class.php
/smarty/libs/core core.write_cache_paths_file.php
Log:
make cache_path per resource, fix a couple directory path issues
--
Smarty CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
mohrt-20030623173133.txt
(text/plain, 8.7 KB)
Index: smarty/libs/Smarty.class.php
diff -u smarty/libs/Smarty.class.php:1.417 smarty/libs/Smarty.class.php:1.418
--- smarty/libs/Smarty.class.php:1.417 Sat Jun 21 13:35:15 2003
+++ smarty/libs/Smarty.class.php Mon Jun 23 17:31:32 2003
@@ -42,7 +42,7 @@
* @version 2.5.0-cvs
*/
-/* $Id: Smarty.class.php,v 1.417 2003/06/21 17:35:15 mohrt Exp $ */
+/* $Id: Smarty.class.php,v 1.418 2003/06/23 21:31:32 mohrt Exp $ */
/**
* DIR_SEP isn't used anymore, but third party apps might
@@ -92,7 +92,7 @@
/**
* The directory where config files are located.
*
-reques * @var string
+ * @var string
*/
var $config_dir = 'configs';
@@ -584,13 +584,6 @@
* @var array
*/
var $_cache_paths_file = null;
-
- /**
- * cached file paths
- *
- * @var array
- */
- var $_cache_paths_max = array('auto_file' => 500);
/**#@-*/
/**
@@ -601,7 +594,6 @@
*/
function Smarty()
{
- $this->_cache_paths_file = $this->compile_dir . '/_smarty_cached_paths.php';
foreach ($this->global_assign as $key => $var_name) {
if (is_array($var_name)) {
foreach ($var_name as $var) {
@@ -1173,6 +1165,13 @@
{
static $_cache_info = array();
+ $this->_cache_paths_file = $this->compile_dir
+ . DIRECTORY_SEPARATOR
+ . '_smarty_cached_paths'
+ . DIRECTORY_SEPARATOR
+ . urlencode($resource_name)
+ . '.php';
+
$_smarty_old_error_level = $this->debugging ? error_reporting() : error_reporting(error_reporting() & ~E_NOTICE);
if($this->security && !in_array($this->template_dir, $this->secure_dir)) {
@@ -1413,20 +1412,20 @@
function _get_plugin_filepath($type, $name)
{
$_cache_paths_key = $type . '/' . $name;
- if(!$this->force_compile
+ if (isset($this->_cache_paths['plugins'][$_cache_paths_key])) {
+ return $this->_cache_paths['plugins'][$_cache_paths_key];
+ }
+ if (!$this->force_compile
&& !isset($this->_cache_paths)
&& file_exists($this->_cache_paths_file)) {
include_once($this->_cache_paths_file);
}
- if (isset($this->_cache_paths['plugins'][$_cache_paths_key])) {
- return $this->_cache_paths['plugins'][$_cache_paths_key];
- }
$_params = array('type' => $type, 'name' => $name);
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.assemble_plugin_filepath.php');
$_return = smarty_core_assemble_plugin_filepath($_params, $this);
- if($_return !== false) {
+ if ($_return !== false) {
$this->_cache_paths['plugins'][$_cache_paths_key] = $_return;
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_cache_paths_file.php');
smarty_core_write_cache_paths_file(null, $this);
@@ -1683,13 +1682,13 @@
function _get_auto_filename($auto_base, $auto_source = null, $auto_id = null)
{
$_cache_paths_key = $auto_base . '/' . $auto_source . '/' . $auto_id;
+ if (isset($this->_cache_paths['auto_file'][$_cache_paths_key])) {
+ return $this->_cache_paths['auto_file'][$_cache_paths_key];
+ }
if(!$this->force_compile
&& !isset($this->_cache_paths)
&& file_exists($this->_cache_paths_file)) {
include_once($this->_cache_paths_file);
- }
- if (isset($this->_cache_paths['auto_file'][$_cache_paths_key])) {
- return $this->_cache_paths['auto_file'][$_cache_paths_key];
}
$_params = array('auto_base' => $auto_base, 'auto_source' => $auto_source, 'auto_id' => $auto_id);
Index: smarty/libs/Smarty_Compiler.class.php
diff -u smarty/libs/Smarty_Compiler.class.php:1.251 smarty/libs/Smarty_Compiler.class.php:1.252
--- smarty/libs/Smarty_Compiler.class.php:1.251 Mon Jun 23 13:01:45 2003
+++ smarty/libs/Smarty_Compiler.class.php Mon Jun 23 17:31:32 2003
@@ -39,7 +39,7 @@
* @package Smarty
*/
-/* $Id: Smarty_Compiler.class.php,v 1.251 2003/06/23 17:01:45 messju Exp $ */
+/* $Id: Smarty_Compiler.class.php,v 1.252 2003/06/23 21:31:32 mohrt Exp $ */
/**
* Template compiling class
* @package Smarty
@@ -369,14 +369,14 @@
}
}
$_plugins_params .= '))';
- $plugins_code = "<?php require_once(SMARTY_DIR . 'core/core.load_plugins.php');\nsmarty_core_load_plugins($_plugins_params, \$this); ?>\n";
+ $plugins_code = "<?php require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.load_plugins.php');\nsmarty_core_load_plugins($_plugins_params, \$this); ?>\n";
$template_header .= $plugins_code;
$this->_plugin_info = array();
$this->_plugins_code = $plugins_code;
}
if ($this->_init_smarty_vars) {
- $template_header .= "<?php require_once(SMARTY_DIR . 'core/core.assign_smarty_interface.php');\nsmarty_core_assign_smarty_interface(null, \$this); ?>\n";
+ $template_header .= "<?php require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.assign_smarty_interface.php');\nsmarty_core_assign_smarty_interface(null, \$this); ?>\n";
$this->_init_smarty_vars = false;
}
@@ -837,7 +837,7 @@
$_params = "array('args' => array(".implode(', ', (array)$arg_list)."))";
- return "<?php require_once(SMARTY_DIR . 'core/core.run_insert_handler.php');\necho smarty_core_run_insert_handler($_params, \$this); ?>\n";
+ return "<?php require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.run_insert_handler.php');\necho smarty_core_run_insert_handler($_params, \$this); ?>\n";
}
/**
@@ -880,7 +880,7 @@
$_params = "array('smarty_include_tpl_file' => " . $include_file . ", 'smarty_include_vars' => array(".implode(',', (array)$arg_list)."))";
- $output .= "require_once(SMARTY_DIR . 'core/core.smarty_include.php');\nsmarty_core_smarty_include($_params, \$this);\n" .
+ $output .= "require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.smarty_include.php');\nsmarty_core_smarty_include($_params, \$this);\n" .
"\$this->_tpl_vars = \$_smarty_tpl_vars;\n" .
"unset(\$_smarty_tpl_vars);\n";
@@ -921,7 +921,7 @@
$_params = "array('smarty_file' => " . $attrs['file'] . ", 'smarty_assign' => '$assign_var', 'smarty_once' => $once_var, 'smarty_include_vars' => array(".implode(',', (array)$arg_list)."))";
- return "<?php require_once(SMARTY_DIR . 'core/core.smarty_include_php.php');\nsmarty_core_smarty_include_php($_params, \$this); ?>\n";
+ return "<?php require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.smarty_include_php.php');\nsmarty_core_smarty_include_php($_params, \$this); ?>\n";
}
@@ -1953,7 +1953,7 @@
if ($prefilter === false) {
unset($this->_plugins['prefilter'][$filter_name]);
$_params = array('plugins' => array(array('prefilter', $filter_name, null, null, false)));
- require_once(SMARTY_DIR . 'core/core.load_plugins.php');
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.load_plugins.php');
smarty_core_load_plugins($_params, $this);
}
}
@@ -1963,7 +1963,7 @@
if ($postfilter === false) {
unset($this->_plugins['postfilter'][$filter_name]);
$_params = array('plugins' => array(array('postfilter', $filter_name, null, null, false)));
- require_once(SMARTY_DIR . 'core/core.load_plugins.php');
+ require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.load_plugins.php');
smarty_core_load_plugins($_params, $this);
}
}
Index: smarty/libs/core/core.write_cache_paths_file.php
diff -u smarty/libs/core/core.write_cache_paths_file.php:1.4 smarty/libs/core/core.write_cache_paths_file.php:1.5
--- smarty/libs/core/core.write_cache_paths_file.php:1.4 Sun Jun 22 18:10:10 2003
+++ smarty/libs/core/core.write_cache_paths_file.php Mon Jun 23 17:31:32 2003
@@ -14,21 +14,11 @@
function smarty_core_write_cache_paths_file($params, &$smarty)
{
- // see if there is an pruning to do
- foreach($smarty->_cache_paths_max as $_max_key => $_max_val) {
- if(isset($smarty->_cache_paths[$_max_key])
- && count($smarty->_cache_paths[$_max_key]) > $_max_val) {
- // remove the oldest (first) value
- array_unshift($smarty->_cache_paths[$_max_key]);
- }
- }
-
$_compiled_content = function_exists('var_export') ? var_export($smarty->_cache_paths, true) : "unserialize('" . serialize($smarty->_cache_paths) . "')";
$_compiled_content = '<?php $smarty->_cache_paths = ' . $_compiled_content . '; ?>';
$_params = array('compile_path' => $smarty->_cache_paths_file, 'compiled_content' => $_compiled_content, 'resource_timestamp' => time());
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_compiled_resource.php');
return smarty_core_write_compiled_resource($_params, $smarty);
- return $_return;
}
/* vim: set expandtab: */