/** * @param $error_msg */ function check_smarty_syntax(&$error_msg) { global $tikidomain, $prefs, $smarty; $tikidomain = ''; // Initialize $prefs with some variables needed by the tra() function and smarty autosave plugin $prefs = array('lang_use_db' => 'n', 'language' => 'en', 'site_language' => 'en', 'feature_ajax' => 'n'); // Load Tiki Smarty $prefs['smarty_compilation'] = 'always'; $prefs['smarty_security'] = 'y'; $prefs['maxRecords'] = 25; $prefs['log_tpl'] = 'y'; $prefs['feature_sefurl_filter'] = 'y'; $prefs['site_layout'] = 'basic'; require_once 'vendor/smarty/smarty/libs/Smarty.class.php'; require_once 'lib/init/smarty.php'; // needed in Smarty_Tiki define('TIKI_PATH', getcwd()); require_once 'lib/core/TikiAddons.php'; require_once 'lib/smarty_tiki/prefilter.tr.php'; require_once 'lib/smarty_tiki/prefilter.jq.php'; require_once 'lib/smarty_tiki/prefilter.log_tpl.php'; $smarty = new Smarty_Tiki(); set_error_handler('check_smarty_syntax_error_handler'); $templates_dir = TIKI_PATH . '/templates'; $errors_found = false; $entries = array(); get_files_list($templates_dir, $entries, '/\\.tpl$/'); $nbEntries = count($entries); for ($i = 0; $i < $nbEntries; $i++) { display_progress_percentage($i, $nbEntries, '%d%% of files passed the Smarty syntax check'); if (strpos($entries[$i], 'tiki-mods.tpl') === false) { $template_file = substr($entries[$i], strlen($templates_dir) + 1); try { $_tpl = $smarty->createTemplate($template_file, null, null, null, false); $_tpl->compileTemplateSource(); } catch (Exception $e) { echo color("\nError: " . $e->getMessage(), 'red') . "\n"; $errors_found = true; } } } restore_error_handler(); echo "\n"; if ($errors_found) { die('Fix the Smarty errors and try again please.'); } }