- Модуль: socialnetwork
- Путь к файлу: ~/bitrix/modules/socialnetwork/lib/ui/preview/post.php
- Класс: BitrixSocialnetworkUiPreviewPost
- Вызов: Post::getImRich
static function getImRich(array $params)
{
if (!Loader::includeModule('im'))
{
return false;
}
if (!Loader::includeModule('blog'))
{
return false;
}
if (!class_exists('BitrixImV2EntityUrlRichData'))
{
return false;
}
$cursor = CBlogPost::getList(
[],
['ID' => $params['postId']],
false,
false,
['TITLE', 'MICRO', 'DETAIL_TEXT']
);
$post = $cursor->fetch();
if(!$post)
{
return false;
}
// For some reason, blog stores specialchared text.
$post['DETAIL_TEXT'] = htmlspecialcharsback($post['DETAIL_TEXT']);
if ($post['MICRO'] === 'Y')
{
$post['TITLE'] = null;
}
$parser = new blogTextParser();
$post['PREVIEW_TEXT'] = TruncateText($parser->killAllTags($post['DETAIL_TEXT']), 200);
$rich = new BitrixImV2EntityUrlRichData();
return $rich
->setName($post['TITLE'])
->setDescription($post['PREVIEW_TEXT'])
->setType(BitrixImV2EntityUrlRichData::POST_TYPE)
;
}