static function getBlogPostData($postId, $languageId)
{
global $USER_FIELD_MANAGER;
if (isset(self::$postsCache[$postId]))
{
$result = self::$postsCache[$postId];
}
else
{
if (!Loader::includeModule('blog'))
{
throw new MainSystemException("Could not load 'blog' module.");
}
$res = CBlogPost::getList(
[],
[
"ID" => $postId
],
false,
false,
[ 'ID', 'BLOG_GROUP_ID', 'BLOG_GROUP_SITE_ID', 'BLOG_ID', 'PUBLISH_STATUS', 'TITLE', 'AUTHOR_ID', 'ENABLE_COMMENTS', 'NUM_COMMENTS', 'VIEWS', 'CODE', 'MICRO', 'DETAIL_TEXT', 'DATE_PUBLISH', 'CATEGORY_ID', 'HAS_SOCNET_ALL', 'HAS_TAGS', 'HAS_IMAGES', 'HAS_PROPS', 'HAS_COMMENT_IMAGES' ]
);
if ($result = $res->fetch())
{
if (!empty($result['DETAIL_TEXT']))
{
$result['DETAIL_TEXT'] = BitrixMainTextEmoji::decode($result['DETAIL_TEXT']);
}
$result["ATTACHMENTS"] = [];
if($result["HAS_PROPS"] !== "N")
{
$userFields = $USER_FIELD_MANAGER->getUserFields("BLOG_POST", $postId, $languageId);
$postUf = [ 'UF_BLOG_POST_FILE' ];
foreach ($userFields as $fieldName => $userField)
{
if (!in_array($fieldName, $postUf))
{
unset($userFields[$fieldName]);
}
}
if (
!empty($userFields["UF_BLOG_POST_FILE"])
&& !empty($userFields["UF_BLOG_POST_FILE"]["VALUE"])
)
{
$result["ATTACHMENTS"] = self::getAttachmentsData($userFields["UF_BLOG_POST_FILE"]["VALUE"], $result["BLOG_GROUP_SITE_ID"]);
}
}
$result["DETAIL_TEXT"] = self::convertDiskFileBBCode(
$result["DETAIL_TEXT"],
'BLOG_POST',
$postId,
$result["AUTHOR_ID"],
$result["ATTACHMENTS"]
);
$result["DETAIL_TEXT_FORMATTED"] = preg_replace(
[
'|[DISKsFILEsID=[n]*d+]|',
'|[DOCUMENTsID=[n]*d+]|'
],
'',
$result["DETAIL_TEXT"]
);
$result['DETAIL_TEXT_FORMATTED'] = Mention::clear($result['DETAIL_TEXT_FORMATTED']);
$p = new blogTextParser();
$p->arUserfields = [];
$images = [];
$allow = [ 'IMAGE' => 'Y' ];
$parserParameters = [];
$result["DETAIL_TEXT_FORMATTED"] = $p->convert($result["DETAIL_TEXT_FORMATTED"], false, $images, $allow, $parserParameters);
$title = (
$result["MICRO"] === "Y"
? blogTextParser::killAllTags($result["DETAIL_TEXT_FORMATTED"])
: htmlspecialcharsEx($result["TITLE"])
);
$title = preg_replace(
'|[MAILsDISKsFILEsID=[n]*d+]|',
'',
$title
);
$title = str_replace([ "rn", "n", "r" ], " ", $title);
$result["TITLE_FORMATTED"] = TruncateText($title, 100);
$result["DATE_PUBLISH_FORMATTED"] = self::formatDateTimeToGMT($result['DATE_PUBLISH'], $result['AUTHOR_ID']);
}
self::$postsCache[$postId] = $result;
}
return $result;
}