- Модуль: sender
- Путь к файлу: ~/bitrix/modules/sender/lib/preset/templates/texts.php
- Класс: BitrixSenderPresetTemplatesTexts
- Вызов: Texts::getByCode
static function getByCode($code)
{
$dictionary = array(
MessageiBase::CODE_MAIL => array(
'SUBJECT',
'TEXT_HEAD',
'TEXT_BODY'
),
MessageiBase::CODE_SMS => array(
'TEXT'
),
MessageiBase::CODE_IM => array(
'TEXT'
),
MessageiBase::CODE_AUDIO_CALL => array(
'AUDIO_FILE'
),
);
$isHot = mb_strpos($code, 'hot_') === 0;
$iconPath = $isHot? mb_substr($code, 4) : $code;
$iconPath = BX_ROOT . self::IMAGE_DIR . $iconPath . '.png';
$code = mb_strtoupper($code);
$result = array(
'CODE' => $code,
'NAME' => Loc::getMessage('SENDER_PRESET_TEMPLATE_' . $code . '_NAME'),
'DESC' => Loc::getMessage('SENDER_PRESET_TEMPLATE_' . $code . '_DESC'),
'HOT' => $isHot,
'ICON' => $iconPath,
'TYPES' => array(),
);
foreach ($dictionary as $type => $keys)
{
if (isset($result['TYPES'][$type])
&& !is_array($result['TYPES'][$type]))
{
$result['TYPES'][$type] = array();
}
foreach ($keys as $key)
{
$msgId = 'SENDER_PRESET_' . $type . '_' . $code . '_' . $key;
$result['TYPES'][$type][$key] = self::getMessage(mb_strtoupper($msgId));
}
}
return (mb_strlen($result['NAME']) && !empty($result['TYPES'])) ? $result : null;
}