From eab8a101e7a3fcbb41e01a574985e06c5a3775de Mon Sep 17 00:00:00 2001 From: emkael Date: Thu, 18 Oct 2018 02:40:38 +0200 Subject: Updating Smarty --- .../smarty_internal_method_compilealltemplates.php | 69 +++++++++++++--------- 1 file changed, 40 insertions(+), 29 deletions(-) (limited to 'lib/smarty3/sysplugins/smarty_internal_method_compilealltemplates.php') diff --git a/lib/smarty3/sysplugins/smarty_internal_method_compilealltemplates.php b/lib/smarty3/sysplugins/smarty_internal_method_compilealltemplates.php index b38544e..5c046da 100644 --- a/lib/smarty3/sysplugins/smarty_internal_method_compilealltemplates.php +++ b/lib/smarty3/sysplugins/smarty_internal_method_compilealltemplates.php @@ -21,19 +21,23 @@ class Smarty_Internal_Method_CompileAllTemplates /** * Compile all template files * - * @api Smarty::compileAllTemplates() + * @api Smarty::compileAllTemplates() * * @param \Smarty $smarty passed smarty object - * @param string $extension file extension - * @param bool $force_compile force all to recompile - * @param int $time_limit - * @param int $max_errors + * @param string $extension file extension + * @param bool $force_compile force all to recompile + * @param int $time_limit + * @param int $max_errors * * @return integer number of template files recompiled */ - public function compileAllTemplates(Smarty $smarty, $extension = '.tpl', $force_compile = false, $time_limit = 0, - $max_errors = null) - { + 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); } @@ -41,17 +45,22 @@ class Smarty_Internal_Method_CompileAllTemplates * Compile all template or config files * * @param \Smarty $smarty - * @param string $extension template file name extension - * @param bool $force_compile force all to recompile - * @param int $time_limit set maximum execution time - * @param int $max_errors set maximum allowed errors + * @param string $extension template file name extension + * @param bool $force_compile force all to recompile + * @param int $time_limit set maximum execution time + * @param int $max_errors set maximum allowed errors * @param bool $isConfig flag true if called for config files * * @return int number of template files compiled */ - protected function compileAll(Smarty $smarty, $extension, $force_compile, $time_limit, $max_errors, - $isConfig = false) - { + protected function compileAll( + Smarty $smarty, + $extension, + $force_compile, + $time_limit, + $max_errors, + $isConfig = false + ) { // switch off time limit if (function_exists('set_time_limit')) { @set_time_limit($time_limit); @@ -61,25 +70,28 @@ class Smarty_Internal_Method_CompileAllTemplates $sourceDir = $isConfig ? $smarty->getConfigDir() : $smarty->getTemplateDir(); // loop over array of source directories foreach ($sourceDir as $_dir) { - $_dir_1 = new RecursiveDirectoryIterator($_dir, defined('FilesystemIterator::FOLLOW_SYMLINKS') ? - FilesystemIterator::FOLLOW_SYMLINKS : 0); + $_dir_1 = new RecursiveDirectoryIterator( + $_dir, + defined('FilesystemIterator::FOLLOW_SYMLINKS') ? + FilesystemIterator::FOLLOW_SYMLINKS : 0 + ); $_dir_2 = new RecursiveIteratorIterator($_dir_1); foreach ($_dir_2 as $_fileinfo) { $_file = $_fileinfo->getFilename(); - if (substr(basename($_fileinfo->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) { + if (substr(basename($_fileinfo->getPathname()), 0, 1) === '.' || strpos($_file, '.svn') !== false) { continue; } - if (!substr_compare($_file, $extension, - strlen($extension)) == 0) { + if (substr_compare($_file, $extension, -strlen($extension)) !== 0) { continue; } - if ($_fileinfo->getPath() !== substr($_dir, 0, - 1)) { - $_file = substr($_fileinfo->getPath(), strlen($_dir)) . DS . $_file; + if ($_fileinfo->getPath() !== substr($_dir, 0, -1)) { + $_file = substr($_fileinfo->getPath(), strlen($_dir)) . DIRECTORY_SEPARATOR . $_file; } echo "\n
", $_dir, '---', $_file; flush(); $_start_time = microtime(true); $_smarty = clone $smarty; - // + // $_smarty->_cache = array(); $_smarty->ext = new Smarty_Internal_Extension_Handler(); $_smarty->ext->objType = $_smarty->_objType; @@ -92,28 +104,27 @@ class Smarty_Internal_Method_CompileAllTemplates $isConfig ? Smarty_Template_Config::load($_tpl) : Smarty_Template_Source::load($_tpl); if ($_tpl->mustCompile()) { $_tpl->compileTemplateSource(); - $_count ++; + $_count++; echo ' compiled in ', microtime(true) - $_start_time, ' seconds'; flush(); } else { echo ' is up to date'; flush(); } - } - catch (Exception $e) { + } catch (Exception $e) { echo "\n
------>Error: ", $e->getMessage(), "

\n"; - $_error_count ++; + $_error_count++; } // free memory unset($_tpl); $_smarty->_clearTemplateCache(); - if ($max_errors !== null && $_error_count == $max_errors) { + if ($max_errors !== null && $_error_count === $max_errors) { echo "\n

too many errors\n"; - exit(); + exit(1); } } } echo "\n
"; return $_count; } -} \ No newline at end of file +} -- cgit v1.2.3