- Модуль: socialnetwork
- Путь к файлу: ~/bitrix/modules/socialnetwork/lib/commentaux/createentity.php
- Класс: BitrixSocialnetworkCommentAuxCreateEntity
- Вызов: CreateEntity::getText
public function getText(): string
{
static $userPage = null;
static $parser = null;
$result = '';
$params = $this->params;
$options = $this->options;
$siteId = (!empty($options['siteId']) ? $options['siteId'] : SITE_ID);
if (
!isset($params['sourceType'], $params['sourceId'], $params['entityId'], $params['entityType'])
|| (int)$params['sourceId'] <= 0
|| (int)$params['entityId'] <= 0
|| !in_array($params['sourceType'], $this->getSourceTypeList(), true)
|| !in_array($params['entityType'], $this->getEntityTypeList(), true)
)
{
return $result;
}
if ($provider = $this->getLivefeedProvider())
{
$options['suffix'] = $provider->getSuffix($options['suffix'] ?? null);
$this->setOptions($options);
}
if ($userPage === null)
{
$userPage = Option::get(
'socialnetwork',
'user_page',
SITE_DIR.'company/personal/',
$siteId
).'user/#user_id#/';
}
if (in_array($params['sourceType'], $this->getCommentTypeList(), true))
{
$sourceData = $this->getSourceCommentData([
'userPage' => $userPage,
]);
$result = Loc::getMessage('SONET_COMMENTAUX_CREATEENTITY_COMMENT_' . $params['sourceType'] . (!empty($sourceData['suffix']) ? '_' . $sourceData['suffix'] : ''), [
'#ENTITY_CREATED#' => $this->getEntityCreatedMessage(),
'#ENTITY_NAME#' => $this->getEntityName(),
'#A_BEGIN#' => (!empty($sourceData['path']) ? '[URL=' . $sourceData['path'] . ']' : ''),
'#A_END#' => (!empty($sourceData['path']) ? '[/URL]' : '')
]);
}
elseif (in_array($params['sourceType'], $this->getPostTypeList(), true))
{
$suffix = ($options['suffix'] ?? ($params['sourceType'] === static::SOURCE_TYPE_BLOG_POST ? '2' : ''));
$result = Loc::getMessage('SONET_COMMENTAUX_CREATEENTITY_POST_' . $params['sourceType'] . (!empty($suffix) ? '_' . $suffix : ''), [
'#ENTITY_CREATED#' => $this->getEntityCreatedMessage(),
'#ENTITY_NAME#' => $this->getEntityName(),
]);
}
if (!empty($result))
{
if ($parser === null)
{
$parser = new CTextParser();
$parser->allow = [ 'HTML' => 'N', 'ANCHOR' => 'Y' ];
}
$result = $parser->convertText($result);
}
return (string)$result;
}