当前位置: 首页>>代码示例>>PHP>>正文


PHP Sugar_Smarty::template_exists方法代码示例

本文整理汇总了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.
}
开发者ID:santara12,项目名称:OpenQuotesAndContracts,代码行数:39,代码来源:Common.php


注:本文中的Sugar_Smarty::template_exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。