diff --git a/change_log.txt b/change_log.txt
index d2177267..0d72c3fd 100644
--- a/change_log.txt
+++ b/change_log.txt
@@ -1,6 +1,7 @@
25/03/2010
- change of utility->compileAllTemplates() log messages
- bugfix on nocache code in {function} tags
+- new methode utility->compileAllConfig() to compile all config files
24/03/2010
- bugfix on register->modifier() error messages
diff --git a/libs/sysplugins/smarty_internal_utility.php b/libs/sysplugins/smarty_internal_utility.php
index 996a564d..631006f7 100644
--- a/libs/sysplugins/smarty_internal_utility.php
+++ b/libs/sysplugins/smarty_internal_utility.php
@@ -104,6 +104,64 @@ class Smarty_Internal_Utility {
return $_count;
}
+ /**
+ * Compile all config files
+ *
+ * @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
+ */
+ function compileAllConfig($extention = '.conf', $force_compile = false, $time_limit = 0, $max_errors = null)
+ {
+ // switch off time limit
+ if (function_exists('set_time_limit')) {
+ @set_time_limit($time_limit);
+ }
+ $this->smarty->force_compile = $force_compile;
+ $_count = 0;
+ $_error_count = 0;
+ // loop over array of template directories
+ foreach((array)$this->smarty->config_dir as $_dir) {
+ $_compileDirs = new RecursiveDirectoryIterator($_dir);
+ $_compile = new RecursiveIteratorIterator($_compileDirs);
+ foreach ($_compile as $_fileinfo) {
+ if (strpos($_fileinfo, '.svn') !== false) continue;
+ $_file = $_fileinfo->getFilename();
+ if (!substr_compare($_file, $extention, - strlen($extention)) == 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 = _get_time();
+ try {
+ $_config = new Smarty_Internal_Config($_config_file, $this->smarty);
+ if ($_config->mustCompile()) {
+ $_config->compileConfigSource();
+ echo ' compiled in ', _get_time() - $_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;
+ }
+
/**
* Delete compiled template file
*