Log::onIndexGetContent

  1. Bitrix24 API (v. 23.675.0)
  2. blog
  3. Log
  4. onIndexGetContent
  • Модуль: blog
  • Путь к файлу: ~/bitrix/modules/blog/lib/integration/socialnetwork/log.php
  • Класс: BitrixBlogIntegrationSocialnetworkLog
  • Вызов: Log::onIndexGetContent
static function onIndexGetContent(Event $event)
{
	global $USER_FIELD_MANAGER;

	$result = new EventResult(
		EventResult::UNDEFINED,
		array(),
		'blog'
	);

	$eventId = $event->getParameter('eventId');
	$sourceId = $event->getParameter('sourceId');

	if (!in_array($eventId, self::getEventIdList()))
	{
		return $result;
	}

	$content = "";
	$post = false;

	if (intval($sourceId) > 0)
	{
		$post = Post::getById($sourceId);
	}

	if ($post)
	{
		$postFieldList = $post->getFields();

		$content .= LogIndex::getUserName($postFieldList["AUTHOR_ID"])." ";
		if (
			$postFieldList["MICRO"] != "Y"
			&& isset($postFieldList["TITLE"])
			&& $postFieldList["TITLE"] <> ''
		)
		{
			$content .= blogTextParser::killAllTags($postFieldList["TITLE"])." ";
		}
		$content .= blogTextParser::killAllTags($postFieldList["DETAIL_TEXT"]);

		$destinationsList = array();
		$res = CBlogPost::getSocNetPerms($sourceId);
		foreach($res as $group => $list)
		{
			foreach($list as $key => $valuesList)
			{
				$destinationsList = array_merge($destinationsList, $valuesList);
			}
		}

		if (!empty($destinationsList))
		{
			$content .= ' '.join(' ', LogIndex::getEntitiesName($destinationsList));
		}

		if (!empty($postFieldList['UF_BLOG_POST_FILE']))
		{
			$fileNameList = LogIndex::getDiskUFFileNameList($postFieldList['UF_BLOG_POST_FILE']);
			if (!empty($fileNameList))
			{
				$content .= ' '.join(' ', $fileNameList);
			}
		}

		if (!empty($postFieldList['UF_BLOG_POST_URL_PRV']))
		{
			$metadata = BitrixMainUrlPreviewUrlMetadataTable::getRowById($postFieldList['UF_BLOG_POST_URL_PRV']);
			if (
				$metadata
				&& isset($metadata['TITLE'])
				&& $metadata['TITLE'] <> ''
			)
			{
				$content .= ' '.$metadata['TITLE'];
			}
		}

		if (
			!empty($postFieldList['UF_BLOG_POST_VOTE'])
			&& intval($postFieldList['UF_BLOG_POST_VOTE']) > 0
			&& Loader::includeModule('vote')
		)
		{
			$postUFList = $USER_FIELD_MANAGER->getUserFields("BLOG_POST", $sourceId, LANGUAGE_ID);

			if (!empty($postUFList['UF_BLOG_POST_VOTE']))
			{
				if (
					($userFieldManager = Manager::getInstance($postUFList['UF_BLOG_POST_VOTE']))
					&& ($attach = $userFieldManager->loadFromAttachId(intval($postFieldList['UF_BLOG_POST_VOTE'])))
				)
				{
					foreach ($attach["QUESTIONS"] as $question)
					{
						$content .= ' '.$question["QUESTION"];
						foreach ($question["ANSWERS"] as $answer)
						{
							$content .= ' '.$answer["MESSAGE"];
						}
					}
				}
			}
		}

		if (!empty($postFieldList['CATEGORY_ID']))
		{
			$categoryList = explode(",", $postFieldList["CATEGORY_ID"]);
			$tagList = array();
			foreach($categoryList as $value)
			{
				$category = CBlogCategory::getByID($value);
				$tagList[] = $category["NAME"];
				$tagList[] = '#'.$category["NAME"];
			}
			if (!empty($tagList))
			{
				$content .= ' '.implode(' ', $tagList);
			}
		}
	}

	$result = new EventResult(
		EventResult::SUCCESS,
		array(
			'content' => $content,
		),
		'blog'
	);

	return $result;
}

Добавить комментарий