26 const LOCAL_DIR =
'/modules/sender/preset/template_v2/';
38 if($templateType && $templateType !==
'BASE')
42 if($messageCode && $messageCode !==
Message\iBase::CODE_MAIL)
47 return self::getTemplates($templateId);
50 private static function getFileContent($fileName)
53 if ($path && File::isFileExists($path))
55 return File::getFileContents($path);
69 $content = str_replace(
78 '/bitrix/images/sender/preset/template_v2/banner.png?1',
81 'SENDER_PRESET_TEMPLATE_MAIL_UNSUBSCRIBE',
83 '%btn_start%' =>
'<a style="color: #0054a5;" href="#' .
'UNSUBSCRIBE_LINK' .
'#">',
84 '%btn_end%' =>
'</a>',
91 return Texts::replace($content);
101 $fileTheme = self::getFileContent(
'theme');
102 $fileSimple = self::getFileContent(
'image_text_button');
104 if (!$fileTheme || !$fileSimple)
109 $fileSocial = self::getFileContent(
'social');
110 $fileSocialRu = self::getFileContent(
'social_ru');
112 if (Integration\Bitrix24\Service::isCloud() && !Integration\Bitrix24\Service::isCloudRegionRussian())
115 $fileSocialEn = self::getFileContent(
'social_en');
118 $fileSocial = str_replace(
119 [
'%SOCIAL_RU%',
'%SOCIAL_EN%'],
120 [$fileSocialRu, $fileSocialEn],
123 $fileContent = str_replace(
124 [
'%TEMPLATE_CONTENT%',
'%TEMPLATE_SOCIAL%'],
125 [$fileSimple, $fileSocial],
132 private static function getTemplates($templateId =
null)
134 $fileContent = self::getTemplateHtml();
144 'MESSAGE_CODE' => Message\iBase::CODE_MAIL,
154 'VALUE' =>
Loc::getMessage(
'SENDER_PRESET_TEMPLATE_MAIL_HTML_SUBJECT'),
158 'VALUE' =>
'<html><body></body></html>',
165 $result = array_merge(
167 Integration\EventHandler::onTemplateList(
Message\iBase::CODE_MAIL)
170 foreach (Texts::getListByType(
Message\iBase::CODE_MAIL) as $item)
172 $code = mb_strtolower(
"mail_".$item[
'CODE']);
173 if($templateId && $code !== $templateId)
178 $fileContent = self::replaceTemplateHtml(
181 'TEXT' =>
"<br><h2>{$item['TEXT_HEAD']}</h2><br>{$item['TEXT_BODY']}<br><br>"
188 'MESSAGE_CODE' =>
Message\iBase::CODE_MAIL,
190 'HOT' => $item[
'HOT'],
191 'ICON' => $item[
'ICON'],
193 'NAME' => $item[
'NAME'],
194 'DESC' => $item[
'DESC'],
198 'VALUE' => $item[
'SUBJECT'],
202 'VALUE' => $fileContent,
static getLocal($path, $root=null)
static loadMessages($file)
static getMessage($code, $replace=null, $language=null)