• Модуль: sender
  • Путь к файлу: ~/bitrix/modules/sender/lib/preset/templatebase.php
  • Класс: BitrixSenderPresetTemplateBase
  • Вызов: TemplateBase::getById
static function getById($templateName)
{
	$result = null;

	$localPathOfIcon = static::LOCAL_DIR_IMG . bx_basename($templateName) . '.png';
	$fullPathOfIcon = Loader::getLocal($localPathOfIcon);

	$fullPathOfFile = Loader::getLocal(static::LOCAL_DIR_TMPL . bx_basename($templateName) . '.php');
	if ($fullPathOfFile && File::isFileExists($fullPathOfFile))
	{
		$fileContent = File::getFileContents($fullPathOfFile);
	}
	else
	{
		$fileContent = '';
	}

	if (!empty($fileContent) || $templateName == 'empty')
	{
		Loader::includeModule('fileman');
		if(BlockEditor::isContentSupported($fileContent))
		{
			$fileContent = static::replaceTemplateByDefaultData($fileContent);
		}

		$fileContent = str_replace(
			array('%TEXT_UNSUB_TEXT%', '%TEXT_UNSUB_LINK%'),
			array(
				Loc::getMessage('PRESET_MAILBLOCK_unsub_TEXT_UNSUB_TEXT'),
				Loc::getMessage('PRESET_MAILBLOCK_unsub_TEXT_UNSUB_LINK')
			),
			$fileContent
		);

		$result = array(
			'TYPE' => 'BASE',
			'ID' => $templateName,
			'NAME' => Loc::getMessage('PRESET_TEMPLATE_' . $templateName),
			'HTML' => $fileContent,
		);
	}

	return $result;
}