mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 10:24:26 +02:00
- optimization replace internal Smarty::$ds property by DIRECTORY_SEPARATOR
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
* @author Uwe Tews
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class does contain all necessary methods for the HTML cache on file system
|
||||
* Implements the file system as resource for the HTML cache Version ussing nocache inserts.
|
||||
@@ -29,12 +28,13 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
||||
{
|
||||
$source = &$_template->source;
|
||||
$smarty = &$_template->smarty;
|
||||
$_compile_dir_sep = $smarty->use_sub_dirs ? $smarty->ds : '^';
|
||||
$_compile_dir_sep = $smarty->use_sub_dirs ? DIRECTORY_SEPARATOR : '^';
|
||||
$_filepath = sha1($source->uid . $smarty->_joined_template_dir);
|
||||
$cached->filepath = $smarty->getCacheDir();
|
||||
if (isset($_template->cache_id)) {
|
||||
$cached->filepath .= preg_replace(array('![^\w|]+!',
|
||||
'![|]+!'), array('_',
|
||||
'![|]+!'),
|
||||
array('_',
|
||||
$_compile_dir_sep),
|
||||
$_template->cache_id) . $_compile_dir_sep;
|
||||
}
|
||||
@@ -43,9 +43,10 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
||||
}
|
||||
// if use_sub_dirs, break file into directories
|
||||
if ($smarty->use_sub_dirs) {
|
||||
$cached->filepath .= $_filepath[ 0 ] . $_filepath[ 1 ] . $smarty->ds . $_filepath[ 2 ] . $_filepath[ 3 ] .
|
||||
$smarty->ds .
|
||||
$_filepath[ 4 ] . $_filepath[ 5 ] . $smarty->ds;
|
||||
$cached->filepath .= $_filepath[ 0 ] . $_filepath[ 1 ] . DIRECTORY_SEPARATOR . $_filepath[ 2 ] .
|
||||
$_filepath[ 3 ] .
|
||||
DIRECTORY_SEPARATOR .
|
||||
$_filepath[ 4 ] . $_filepath[ 5 ] . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
$cached->filepath .= $_filepath;
|
||||
$basename = $source->handler->getBasename($source);
|
||||
@@ -86,7 +87,8 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
||||
*
|
||||
* @return boolean true or false if the cached content does not exist
|
||||
*/
|
||||
public function process(Smarty_Internal_Template $_smarty_tpl, Smarty_Template_Cached $cached = null,
|
||||
public function process(Smarty_Internal_Template $_smarty_tpl,
|
||||
Smarty_Template_Cached $cached = null,
|
||||
$update = false)
|
||||
{
|
||||
$_smarty_tpl->cached->valid = false;
|
||||
@@ -108,7 +110,8 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
||||
*/
|
||||
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
|
||||
{
|
||||
if ($_template->smarty->ext->_writeFile->writeFile($_template->cached->filepath, $content,
|
||||
if ($_template->smarty->ext->_writeFile->writeFile($_template->cached->filepath,
|
||||
$content,
|
||||
$_template->smarty) === true
|
||||
) {
|
||||
if (function_exists('opcache_invalidate') &&
|
||||
|
@@ -7,7 +7,6 @@
|
||||
* @subpackage Compiler
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Compile Include Class
|
||||
*
|
||||
|
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty Method CompileAllTemplates
|
||||
*
|
||||
@@ -31,7 +30,10 @@ class Smarty_Internal_Method_CompileAllTemplates
|
||||
*
|
||||
* @return integer number of template files recompiled
|
||||
*/
|
||||
public function compileAllTemplates(Smarty $smarty, $extension = '.tpl', $force_compile = false, $time_limit = 0,
|
||||
public function compileAllTemplates(Smarty $smarty,
|
||||
$extension = '.tpl',
|
||||
$force_compile = false,
|
||||
$time_limit = 0,
|
||||
$max_errors = null)
|
||||
{
|
||||
return $this->compileAll($smarty, $extension, $force_compile, $time_limit, $max_errors);
|
||||
@@ -49,7 +51,11 @@ class Smarty_Internal_Method_CompileAllTemplates
|
||||
*
|
||||
* @return int number of template files compiled
|
||||
*/
|
||||
protected function compileAll(Smarty $smarty, $extension, $force_compile, $time_limit, $max_errors,
|
||||
protected function compileAll(Smarty $smarty,
|
||||
$extension,
|
||||
$force_compile,
|
||||
$time_limit,
|
||||
$max_errors,
|
||||
$isConfig = false)
|
||||
{
|
||||
// switch off time limit
|
||||
@@ -73,7 +79,7 @@ class Smarty_Internal_Method_CompileAllTemplates
|
||||
continue;
|
||||
}
|
||||
if ($_fileinfo->getPath() !== substr($_dir, 0, -1)) {
|
||||
$_file = substr($_fileinfo->getPath(), strlen($_dir)) . $smarty->ds . $_file;
|
||||
$_file = substr($_fileinfo->getPath(), strlen($_dir)) . DIRECTORY_SEPARATOR . $_file;
|
||||
}
|
||||
echo "\n<br>", $_dir, '---', $_file;
|
||||
flush();
|
||||
|
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty cache resource file clear method
|
||||
*
|
||||
@@ -7,7 +6,6 @@
|
||||
* @subpackage PluginsInternal
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Runtime Cache Resource File Class
|
||||
*
|
||||
@@ -43,7 +41,7 @@ class Smarty_Internal_Runtime_CacheResourceFile
|
||||
$_cache_id_parts_count = count($_cache_id_parts);
|
||||
if ($smarty->use_sub_dirs) {
|
||||
foreach ($_cache_id_parts as $id_part) {
|
||||
$_dir .= $id_part . $smarty->ds;
|
||||
$_dir .= $id_part . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,10 +50,8 @@ class Smarty_Internal_Runtime_CacheResourceFile
|
||||
$smarty->caching = true;
|
||||
$tpl = new $smarty->template_class($resource_name, $smarty);
|
||||
$smarty->caching = $_save_stat;
|
||||
|
||||
// remove from template cache
|
||||
$tpl->source; // have the template registered before unset()
|
||||
|
||||
if ($tpl->source->exists) {
|
||||
$_resourcename_parts = basename(str_replace('^', '/', $tpl->cached->filepath));
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user