本文整理汇总了PHP中Bitrix\Main\Localization\Loc::setCurrentLang方法的典型用法代码示例。如果您正苦于以下问题:PHP Loc::setCurrentLang方法的具体用法?PHP Loc::setCurrentLang怎么用?PHP Loc::setCurrentLang使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bitrix\Main\Localization\Loc
的用法示例。
在下文中一共展示了Loc::setCurrentLang方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setMailBody
/**
* @param
*/
protected function setMailBody()
{
$isHtml = $this->eventMessageFields["BODY_TYPE"] == "html";
// replace placeholders in body
$message = $this->eventMessageFields["MESSAGE_PHP"];
if (empty($message) && !empty($this->eventMessageFields["MESSAGE"])) {
$message = MailInternal\EventMessageTable::replaceTemplateToPhp($this->eventMessageFields["MESSAGE"]);
if ($this->eventMessageFields["ID"] > 0) {
MailInternal\EventMessageTable::update($this->eventMessageFields["ID"], array('MESSAGE_PHP' => $message));
}
}
if (!empty($this->eventMessageFields['SITE_TEMPLATE_ID'])) {
$siteTemplateId = $this->eventMessageFields['SITE_TEMPLATE_ID'];
} else {
$siteTemplateId = null;
}
$themeCompiler = EventMessageThemeCompiler::createInstance($siteTemplateId, $message, $isHtml);
if (empty($siteTemplateId)) {
$siteTemplateId = ".default";
}
// set context variables for components
$themeCompiler->setSiteTemplateId($siteTemplateId);
$themeCompiler->setSiteId($this->siteId);
$themeCompiler->setLanguageId($this->languageId);
Loc::setCurrentLang($themeCompiler->getLanguageId());
// set values of $arParams, used by components
$eventSiteFields = $this->eventSiteFields;
if ($isHtml) {
foreach ($eventSiteFields as $fieldKey => $fieldValue) {
if (strpos($fieldValue, "<") === false) {
$eventSiteFields[$fieldKey] = nl2br($fieldValue);
}
}
}
$themeCompiler->setParams($eventSiteFields);
// eval site template and body
$themeCompiler->execute();
// get eval result of site template and body
$message = $themeCompiler->getResult();
$this->mailBody = $message;
Loc::setCurrentLang(null);
EventMessageThemeCompiler::unsetInstance();
}