diff --git a/change_log.txt b/change_log.txt
index fa31ce34..3227a5eb 100644
--- a/change_log.txt
+++ b/change_log.txt
@@ -1,6 +1,7 @@
===== 3.1.28-dev===== (xx.xx.2015)
06.08.2015
- avoid possible circular object referances caused by parser/lexer objects
+ - rewrite compileAll... utility methods
03.08.2015
- rework clear cache methods
diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php
index bde9cd1a..e50f877c 100644
--- a/libs/Smarty.class.php
+++ b/libs/Smarty.class.php
@@ -111,7 +111,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
- const SMARTY_VERSION = '3.1.28-dev/40';
+ const SMARTY_VERSION = '3.1.28-dev/41';
/**
* define variable scopes
diff --git a/libs/sysplugins/smarty_internal_extension_compileall.php b/libs/sysplugins/smarty_internal_extension_compileall.php
new file mode 100644
index 00000000..40f2a7f5
--- /dev/null
+++ b/libs/sysplugins/smarty_internal_extension_compileall.php
@@ -0,0 +1,85 @@
+clearCompiledTemplate() method
+ *
+ * @package Smarty
+ * @subpackage PluginsInternal
+ * @author Uwe Tews
+ */
+class Smarty_Internal_Extension_CompileAll
+{
+ /**
+ * Compile all template or config files
+ *
+ * @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 Smarty $smarty Smarty instance
+ * @param bool $isConfig flag true if called for config files
+ *
+ * @return int number of template files compiled
+ */
+ public static function compileAll($extension, $force_compile, $time_limit, $max_errors, Smarty $smarty, $isConfig = false)
+ {
+ // switch off time limit
+ if (function_exists('set_time_limit')) {
+ @set_time_limit($time_limit);
+ }
+ $_count = 0;
+ $_error_count = 0;
+ $sourceDir = $isConfig ? $smarty->getConfigDir() : $smarty->getTemplateDir();
+ // loop over array of source directories
+ foreach ($sourceDir as $_dir) {
+ $_dir_1 = new RecursiveDirectoryIterator($_dir);
+ $_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) {
+ continue;
+ }
+ if (!substr_compare($_file, $extension, - strlen($extension)) == 0) {
+ continue;
+ }
+ if ($_fileinfo->getPath() == !substr($_dir, 0, - 1)) {
+ $_file = substr($_fileinfo->getPath(), strlen($_dir)) . DS . $_file;
+ }
+ echo "\n
", $_dir, '---', $_file;
+ flush();
+ $_start_time = microtime(true);
+ $_smarty = clone $smarty;
+ $_smarty->force_compile = $force_compile;
+ try {
+ $_tpl = new $smarty->template_class($_file, $_smarty);
+ $_tpl->caching = Smarty::CACHING_OFF;
+ $_tpl->source = $isConfig ? Smarty_Template_Config::load($_tpl) : Smarty_Template_Source::load($_tpl);
+ if ($_tpl->mustCompile()) {
+ $_tpl->compileTemplateSource();
+ $_count ++;
+ echo ' compiled in ', microtime(true) - $_start_time, ' seconds';
+ flush();
+ } else {
+ echo ' is up to date';
+ flush();
+ }
+ }
+ catch (Exception $e) {
+ echo "\n
------>Error: ", $e->getMessage(), "
\n";
+ $_error_count ++;
+ }
+ // free memory
+ unset($_tpl);
+ $_smarty->template_objects = array();
+ if ($max_errors !== null && $_error_count == $max_errors) {
+ echo "\n
too many errors\n";
+ exit();
+ }
+ }
+ }
+ echo "\n
";
+ return $_count;
+ }
+}
diff --git a/libs/sysplugins/smarty_internal_utility.php b/libs/sysplugins/smarty_internal_utility.php
index 5679198e..1ddd0f37 100644
--- a/libs/sysplugins/smarty_internal_utility.php
+++ b/libs/sysplugins/smarty_internal_utility.php
@@ -43,144 +43,6 @@ class Smarty_Internal_Utility
// intentionally left blank
}
- /**
- * Compile all template files
- *
- * @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 Smarty $smarty Smarty instance
- *
- * @return integer number of template files compiled
- */
- public static function compileAllTemplates($extension, $force_compile, $time_limit, $max_errors, Smarty $smarty)
- {
- // switch off time limit
- if (function_exists('set_time_limit')) {
- @set_time_limit($time_limit);
- }
- $smarty->force_compile = $force_compile;
- $_count = 0;
- $_error_count = 0;
- // loop over array of template directories
- foreach ($smarty->getTemplateDir() as $_dir) {
- $_compileDirs = new RecursiveDirectoryIterator($_dir);
- $_compile = new RecursiveIteratorIterator($_compileDirs);
- foreach ($_compile as $_fileinfo) {
- $_file = $_fileinfo->getFilename();
- if (substr(basename($_fileinfo->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) {
- continue;
- }
- if (!substr_compare($_file, $extension, - strlen($extension)) == 0) {
- continue;
- }
- if ($_fileinfo->getPath() == substr($_dir, 0, - 1)) {
- $_template_file = $_file;
- } else {
- $_template_file = substr($_fileinfo->getPath(), strlen($_dir)) . DS . $_file;
- }
- echo '
', $_dir, '---', $_template_file;
- flush();
- $_start_time = microtime(true);
- try {
- $_tpl = $smarty->createTemplate($_template_file, null, null, null, false);
- if ($_tpl->mustCompile()) {
- $_tpl->compileTemplateSource();
- $_count ++;
- echo ' compiled in ', microtime(true) - $_start_time, ' seconds';
- flush();
- } else {
- echo ' is up to date';
- flush();
- }
- }
- catch (Exception $e) {
- echo 'Error: ', $e->getMessage(), "
";
- $_error_count ++;
- }
- // free memory
- $smarty->template_objects = array();
- $_tpl->smarty->template_objects = array();
- $_tpl = null;
- if ($max_errors !== null && $_error_count == $max_errors) {
- echo '
too many errors';
- exit();
- }
- }
- }
-
- return $_count;
- }
-
- /**
- * Compile all config files
- *
- * @param string $extension config 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 Smarty $smarty Smarty instance
- *
- * @return integer number of config files compiled
- */
- public static function compileAllConfig($extension, $force_compile, $time_limit, $max_errors, Smarty $smarty)
- {
- // switch off time limit
- if (function_exists('set_time_limit')) {
- @set_time_limit($time_limit);
- }
- $smarty->force_compile = $force_compile;
- $_count = 0;
- $_error_count = 0;
- // loop over array of template directories
- foreach ($smarty->getConfigDir() as $_dir) {
- $_compileDirs = new RecursiveDirectoryIterator($_dir);
- $_compile = new RecursiveIteratorIterator($_compileDirs);
- foreach ($_compile as $_fileinfo) {
- $_file = $_fileinfo->getFilename();
- if (substr(basename($_fileinfo->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) {
- continue;
- }
- if (!substr_compare($_file, $extension, - strlen($extension)) == 0) {
- continue;
- }
- if ($_fileinfo->getPath() == substr($_dir, 0, - 1)) {
- $_config_file = $_file;
- } else {
- $_config_file = substr($_fileinfo->getPath(), strlen($_dir)) . DS . $_file;
- }
- echo '
', $_dir, '---', $_config_file;
- flush();
- $_start_time = microtime(true);
- try {
- $confObj = new $smarty->template_class($_config_file, $smarty);
- $confObj->caching = Smarty::CACHING_OFF;
- $confObj->source = Smarty_Template_Config::load($confObj);
- if ($confObj->mustCompile()) {
- $confObj->compileTemplateSource();
- $_count ++;
- echo ' compiled in ', microtime(true) - $_start_time, ' seconds';
- flush();
- } else {
- echo ' is up to date';
- flush();
- }
- }
- catch (Exception $e) {
- echo 'Error: ', $e->getMessage(), "
";
- $_error_count ++;
- }
- if ($max_errors !== null && $_error_count == $max_errors) {
- echo '
too many errors';
- exit();
- }
- }
- }
-
- return $_count;
- }
-
/**
* Return array of tag/attributes of all tags used by an template
*