本文整理匯總了PHP中Sugar_Smarty::template_exists方法的典型用法代碼示例。如果您正苦於以下問題:PHP Sugar_Smarty::template_exists方法的具體用法?PHP Sugar_Smarty::template_exists怎麽用?PHP Sugar_Smarty::template_exists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Sugar_Smarty
的用法示例。
在下文中一共展示了Sugar_Smarty::template_exists方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: templateToLatex
function templateToLatex($templateFilename, $variables)
{
$smarty = new Sugar_Smarty();
$smarty->left_delimiter = '<';
$smarty->right_delimiter = '>';
if (!$smarty->template_exists($templateFilename)) {
$GLOBALS['log']->error('Failed to open smarty template ' . $templateFilename);
return null;
}
// insert some translated labels into the variables array to make sure we can use translation in the latex templates
if (!array_key_exists('language', $variables)) {
global $app_list_strings;
$variables['language'] = $app_list_strings['oqc'];
// insert sugarcrm default langauge as well because we have to do some language specific includes in the latex templates
global $sugar_config;
$variables['default_language'] = $sugar_config['default_language'];
}
require_once 'include/oqc/common/Configuration.php';
$conf = Configuration::getInstance();
// add some company-specific data that might be useful in all latex templates
$variables['pdfCompanyName'] = $conf->get('pdfCompanyName');
$variables['pdfCompanyAddress'] = $conf->get('pdfCompanyAddress');
$variables['pdfCompanyContactPhone'] = $conf->get('pdfCompanyContactPhone');
$variables['pdfCompanyContactFax'] = $conf->get('pdfCompanyContactFax');
$variables['pdfCompanyContactMail'] = $conf->get('pdfCompanyContactMail');
$variables['pdfCompanyContactInternet'] = $conf->get('pdfCompanyContactInternet');
$variables['pdfCopyrightNotice'] = $conf->get('pdfCopyrightNotice');
//$GLOBALS['log']->error('Smarty variables: '. var_export($variables,true));
$smarty->assign($variables);
$latex = $smarty->fetch($templateFilename);
$latexFilename = tempnam(TMP_DIR, TEMPLATE_TMP_PREFIX);
//$GLOBALS['log']->error('OQC: Temp directory name: '.TMP_DIR);
// TODO: open_basedir restriction??
if (!file_put_contents($latexFilename, $latex)) {
return null;
}
return str_replace("\\", "/", $latexFilename);
//make sure only / will be ever used.
}