• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/lib/componenthelper.php
  • Класс: BitrixSocialnetworkComponentHelper
  • Вызов: ComponentHelper::getBlogCommentListData
static function getBlogCommentListData($postId, $params, $languageId, &$authorIdList = []): array
{
	if (isset(self::$commentListsCache[$postId]))
	{
		$result = self::$commentListsCache[$postId];
	}
	else
	{
		$result = [];

		if (!Loader::includeModule('blog'))
		{
			throw new MainSystemException("Could not load 'blog' module.");
		}

		$p = new blogTextParser();

		$selectedFields = [ 'ID', 'BLOG_GROUP_ID', 'BLOG_GROUP_SITE_ID', 'BLOG_ID', 'POST_ID', 'AUTHOR_ID', 'AUTHOR_NAME', 'AUTHOR_EMAIL', 'POST_TEXT', 'DATE_CREATE', 'PUBLISH_STATUS', 'HAS_PROPS', 'SHARE_DEST' ];

		$connection = Application::getConnection();
		if ($connection instanceof BitrixMainDBMysqlCommonConnection)
		{
			$selectedFields[] = "DATE_CREATE_TS";
		}

		$res = CBlogComment::getList(
			[ 'ID' => 'DESC' ],
			[
				"PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_PUBLISH,
				"POST_ID" => $postId
			],
			false,
			[
				"nTopCount" => $params["COMMENTS_COUNT"]
			],
			$selectedFields
		);

		while ($comment = $res->fetch())
		{
			self::processCommentData($comment, $languageId, $p, [ "MAIL" => (isset($params["MAIL"]) && $params["MAIL"] === "Y" ? "Y" : "N") ]);

			$result[] = $comment;

			if (!in_array((int)$comment["AUTHOR_ID"], $authorIdList, true))
			{
				$authorIdList[] = (int)$comment["AUTHOR_ID"];
			}
		}

		if (!empty($result))
		{
			$result = array_reverse($result);
		}

		self::$commentListsCache[$postId] = $result;
	}

	return $result;
}