mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
removed auto-filenames from path-cache. merged assemble_auto_filename
back into Smarty::_get_auto_filename()
This commit is contained in:
@@ -1853,26 +1853,39 @@ class Smarty
|
|||||||
* @return string
|
* @return string
|
||||||
* @staticvar string|null
|
* @staticvar string|null
|
||||||
* @staticvar string|null
|
* @staticvar string|null
|
||||||
*/
|
*/
|
||||||
function _get_auto_filename($auto_base, $auto_source = null, $auto_id = null)
|
function _get_auto_filename($auto_base, $auto_source = null, $auto_id = null)
|
||||||
{
|
{
|
||||||
$_cache_paths_key = $auto_base . '/' . $auto_source . '/' . $auto_id;
|
$_compile_dir_sep = $smarty->use_sub_dirs ? DIRECTORY_SEPARATOR : '^';
|
||||||
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);
|
if(@is_dir($auto_base)) {
|
||||||
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.assemble_auto_filename.php');
|
$_return = $auto_base . DIRECTORY_SEPARATOR;
|
||||||
$_return = smarty_core_assemble_auto_filename($_params, $this);
|
} else {
|
||||||
|
// auto_base not found, try include_path
|
||||||
|
$_params = array('file_path' => $auto_base);
|
||||||
|
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php');
|
||||||
|
smarty_core_get_include_path($_params, $smarty);
|
||||||
|
$_return = isset($_params['new_file_path']) ? $_params['new_file_path'] . DIRECTORY_SEPARATOR : null;
|
||||||
|
}
|
||||||
|
|
||||||
if($_return !== false) {
|
if(isset($auto_id)) {
|
||||||
$this->_cache_paths['auto_file'][$_cache_paths_key] = $_return;
|
// make auto_id safe for directory names
|
||||||
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_cache_paths_file.php');
|
$auto_id = str_replace('%7C',$_compile_dir_sep,(urlencode($auto_id)));
|
||||||
smarty_core_write_cache_paths_file(null, $this);
|
// split into separate directories
|
||||||
return $_return;
|
$_return .= $auto_id . $_compile_dir_sep;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
if(isset($auto_source)) {
|
||||||
|
// make source name safe for filename
|
||||||
|
$_filename = urlencode(basename($auto_source));
|
||||||
|
$_crc32 = crc32($auto_source) . $_compile_dir_sep;
|
||||||
|
// prepend %% to avoid name conflicts with
|
||||||
|
// with $params['auto_id'] names
|
||||||
|
$_crc32 = '%%' . substr($_crc32,0,3) . $_compile_dir_sep . '%%' . $_crc32;
|
||||||
|
$_return .= $_crc32 . $_filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,56 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage plugins
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get a concrete filename for automagically created content
|
|
||||||
*
|
|
||||||
* @param string $auto_base
|
|
||||||
* @param string $auto_source
|
|
||||||
* @param string $auto_id
|
|
||||||
* @return string
|
|
||||||
* @staticvar string|null
|
|
||||||
* @staticvar string|null
|
|
||||||
*/
|
|
||||||
function smarty_core_assemble_auto_filename($params, &$smarty)
|
|
||||||
{
|
|
||||||
|
|
||||||
$_compile_dir_sep = $smarty->use_sub_dirs ? DIRECTORY_SEPARATOR : '^';
|
|
||||||
|
|
||||||
if(@is_dir($params['auto_base'])) {
|
|
||||||
$_return = $params['auto_base'] . DIRECTORY_SEPARATOR;
|
|
||||||
} else {
|
|
||||||
// auto_base not found, try include_path
|
|
||||||
$_params = array('file_path' => $params['auto_base']);
|
|
||||||
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php');
|
|
||||||
smarty_core_get_include_path($_params, $smarty);
|
|
||||||
$_return = isset($_params['new_file_path']) ? $_params['new_file_path'] . DIRECTORY_SEPARATOR : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($params['auto_id'])) {
|
|
||||||
// make auto_id safe for directory names
|
|
||||||
$params['auto_id'] = str_replace('%7C','|',(urlencode($params['auto_id'])));
|
|
||||||
// split into separate directories
|
|
||||||
$params['auto_id'] = str_replace('|', $_compile_dir_sep, $params['auto_id']);
|
|
||||||
$_return .= $params['auto_id'] . $_compile_dir_sep;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($params['auto_source'])) {
|
|
||||||
// make source name safe for filename
|
|
||||||
$_filename = urlencode(basename($params['auto_source']));
|
|
||||||
$_crc32 = crc32($params['auto_source']) . $_compile_dir_sep;
|
|
||||||
// prepend %% to avoid name conflicts with
|
|
||||||
// with $params['auto_id'] names
|
|
||||||
$_crc32 = '%%' . substr($_crc32,0,3) . $_compile_dir_sep . '%%' . $_crc32;
|
|
||||||
$_return .= $_crc32 . $_filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $_return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
|
||||||
|
|
||||||
?>
|
|
Reference in New Issue
Block a user