function compile_template($template) { if (!class_exists('compiler')) { require_once dirname(__FILE__) . '/' . $this->compiler_file; } $compiled_code = ''; $compiler = new Compiler(); if ($compiler->compile_file($this->template_dir . "/{$template}", $compiled_code)) { $this->write_template($this->compile_dir . "/{$template}", $compiled_code); } else { trigger_error($compiler->get_error_string(), E_USER_ERROR); } }
function txScriptTemplateSave() { global $DB, $C; VerifyAdministrator(); CheckAccessList(); $_REQUEST['code'] = trim($_REQUEST['code']); // Compile global templates first, if this is not one if (!preg_match('~global-~', $_REQUEST['loaded_template'])) { $t = new Template(); foreach (glob("{$GLOBALS['BASE_DIR']}/templates/*global-*.tpl") as $global_template) { $t->compile_template(basename($global_template)); } } $compiled_code = ''; $compiler = new Compiler(); if ($compiler->compile($_REQUEST['code'], $compiled_code)) { $template_file = SafeFilename("{$GLOBALS['BASE_DIR']}/templates/{$_REQUEST['loaded_template']}"); FileWrite($template_file, $_REQUEST['code']); $compiled_file = SafeFilename("{$GLOBALS['BASE_DIR']}/templates/compiled/{$_REQUEST['loaded_template']}", FALSE); FileWrite($compiled_file, $compiled_code); $GLOBALS['message'] = 'Template has been successully saved'; } else { $GLOBALS['errstr'] = "Template could not be saved:<br />" . nl2br($compiler->get_error_string()); } $GLOBALS['warnstr'] = CheckTemplateCode($_REQUEST['code']); // Recompile all templates if a global template was updated if (preg_match('~global-~', $_REQUEST['loaded_template'])) { RecompileTemplates(); } txShScriptTemplates(); }
function lxEditRejection() { global $DB, $C; VerifyAdministrator(); $validator = new Validator(); $validator->Register($_REQUEST['identifier'], V_EMPTY, 'The Identifier field must be filled in'); $validator->Register($_REQUEST['subject'], V_EMPTY, 'The Subject field must be filled in'); if (!$validator->Validate()) { $GLOBALS['errstr'] = join('<br />', $validator->GetErrors()); lxEditRejection(); return; } $_REQUEST['plain'] = trim($_REQUEST['plain']); $_REQUEST['html'] = trim($_REQUEST['html']); $ini_data = IniWrite(null, $_REQUEST, array('subject', 'plain', 'html')); $compiled_code = ''; $compiler = new Compiler(); if ($compiler->compile($ini_data, $compiled_code)) { $DB->Update('UPDATE lx_rejections SET ' . 'identifier=?, ' . 'plain=?, ' . 'compiled=? ' . 'WHERE email_id=?', array($_REQUEST['identifier'], $ini_data, $compiled_code, $_REQUEST['email_id'])); $GLOBALS['message'] = 'Rejection e-mail has been successfully updated'; $GLOBALS['added'] = true; } else { $GLOBALS['errstr'] = "Rejection e-mail could not be saved:<br />" . nl2br($compiler->get_error_string()); } lxShEditRejection(); }
function tlxRejectionTemplateEdit() { global $DB, $C; VerifyAdministrator(); $v = new Validator(); $v->Register($_REQUEST['identifier'], V_EMPTY, 'The Identifier field must be filled in'); $v->Register($_REQUEST['subject'], V_EMPTY, 'The Subject field must be filled in'); if (!$v->Validate()) { return $v->ValidationError('tlxShRejectionTemplateEdit'); } $_REQUEST['plain'] = trim($_REQUEST['plain']); $_REQUEST['html'] = trim($_REQUEST['html']); $ini_data = IniWrite(null, $_REQUEST, array('subject', 'plain', 'html')); $compiled_code = ''; $compiler = new Compiler(); if ($compiler->compile($ini_data, $compiled_code)) { $DB->Update('UPDATE `tlx_rejections` SET ' . '`identifier`=?, ' . '`plain`=?, ' . '`compiled`=? ' . 'WHERE `email_id`=?', array($_REQUEST['identifier'], $ini_data, $compiled_code, $_REQUEST['email_id'])); $GLOBALS['message'] = 'Rejection e-mail has been successfully updated'; $GLOBALS['added'] = true; } else { $GLOBALS['errstr'] = "Rejection e-mail could not be saved:<br />" . nl2br($compiler->get_error_string()); } tlxShRejectionTemplateEdit(); }