• Модуль: sender
  • Путь к файлу: ~/bitrix/modules/sender/lib/preset/templates/mail.php
  • Класс: BitrixSenderPresetTemplatesMail
  • Вызов: Mail::getTemplates
static function getTemplates($templateId = null)
{
	$fileContent = self::getTemplateHtml();
	if (!$fileContent)
	{
		return [];
	}

	$result = [
		[
			'ID' => 'empty',
			'TYPE' => Type::getCode(Type::BASE),
			'MESSAGE_CODE' => MessageiBase::CODE_MAIL,
			'VERSION' => 2,
			'HOT' => false,
			'ICON' => '',

			'NAME' => Loc::getMessage('SENDER_PRESET_TEMPLATE_MAIL_HTML_NAME'),
			'DESC' => Loc::getMessage('SENDER_PRESET_TEMPLATE_MAIL_HTML_DESC'),
			'FIELDS' => array(
				'SUBJECT' => array(
					'CODE' => 'SUBJECT',
					'VALUE' => Loc::getMessage('SENDER_PRESET_TEMPLATE_MAIL_HTML_SUBJECT'),
				),
				'MESSAGE' => array(
					'CODE' => 'MESSAGE',
					'VALUE' => '',
					'ON_DEMAND' => false
				),
			),
		]
	];

	$result = array_merge(
		$result,
		IntegrationEventHandler::onTemplateList(MessageiBase::CODE_MAIL)
	);

	foreach (Texts::getListByType(MessageiBase::CODE_MAIL) as $item)
	{
		$code = mb_strtolower("mail_".$item['CODE']);
		if($templateId && $code !== $templateId)
		{
			continue;
		}

		$fileContent = self::replaceTemplateHtml(
			$fileContent,
			[
				'TEXT' => "

{$item['TEXT_HEAD']}


{$item['TEXT_BODY']}

" ] ); $result[] = array( 'ID' => $code, 'TYPE' => Type::getCode(Type::BASE), 'MESSAGE_CODE' => MessageiBase::CODE_MAIL, 'VERSION' => 2, 'HOT' => $item['HOT'], 'ICON' => $item['ICON'], 'NAME' => $item['NAME'], 'DESC' => $item['DESC'], 'FIELDS' => array( 'SUBJECT' => array( 'CODE' => 'SUBJECT', 'VALUE' => $item['SUBJECT'], ), 'MESSAGE' => array( 'CODE' => 'MESSAGE', 'VALUE' => $fileContent, 'ON_DEMAND' => true ), ), ); } return $result; }