本文整理匯總了PHP中Smarty_Internal_Config::compileConfigSource方法的典型用法代碼示例。如果您正苦於以下問題:PHP Smarty_Internal_Config::compileConfigSource方法的具體用法?PHP Smarty_Internal_Config::compileConfigSource怎麽用?PHP Smarty_Internal_Config::compileConfigSource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Smarty_Internal_Config
的用法示例。
在下文中一共展示了Smarty_Internal_Config::compileConfigSource方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: compileAllConfig
/**
* 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($extention, $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) {
if (substr($_fileinfo->getBasename(), 0, 1) == '.' || 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 '<br>', $_dir, '---', $_config_file;
flush();
$_start_time = microtime(true);
try {
$_config = new Smarty_Internal_Config($_config_file, $smarty);
if ($_config->mustCompile()) {
$_config->compileConfigSource();
echo ' compiled in ', microtime(true) - $_start_time, ' seconds';
flush();
} else {
echo ' is up to date';
flush();
}
} catch (Exception $e) {
echo 'Error: ', $e->getMessage(), "<br><br>";
$_error_count++;
}
if ($max_errors !== null && $_error_count == $max_errors) {
echo '<br><br>too many errors';
exit;
}
}
}
return $_count;
}