• Модуль: intranet
  • Путь к файлу: ~/bitrix/modules/intranet/lib/component/userprofile/profilepost.php
  • Класс: BitrixIntranetComponentUserProfileProfilePost
  • Вызов: ProfilePost::getProfileBlogPostUFRendered
private function getProfileBlogPostUFRendered($params = [])
{
	global $APPLICATION;

	$postId = (!empty($params['postId']) ? intval($params['postId']) : 0);
	$ufList = (!empty($params['ufList']) && is_array($params['ufList']) ? $params['ufList'] : []);
	$detailText = (isset($params['detailText']) ? trim($params['detailText']) : '');

	$inlineAttachmentsList = [];
	if (
		$postId > 0
		&& !empty($ufList)
		&& $detailText <> ''
		&& preg_match_all('/[DISKsFILEsID=([n]*)(d+)]/', $detailText, $matches)
	)
	{
		foreach($matches[2] as $key => $value)
		{
			$inlineAttachmentsList[] = [
				'ID' => $value,
				'KEY' => ($matches[1][$key] === 'n' ? 'OBJECT_ID' : 'ID')
			];
		}

		if (!empty($inlineAttachmentsList))
		{
			$attachedImagesList = [];

			$userFieldManager = BitrixDiskDriver::getInstance()->getUserFieldManager();

			$res = BitrixDiskAttachedObject::getList(array(
				'filter' => array(
					'=ENTITY_TYPE' => BitrixDiskUfBlogPostConnector::className(),
					'ENTITY_ID' => $postId
				),
				'select' => array('ID', 'OBJECT_ID', 'OBJECT.NAME')
			));
			foreach ($res as $attachedObjectFields)
			{
				if (BitrixDiskTypeFile::isImage($userFieldManager->getAttachedObjectById($attachedObjectFields['ID'])->getFile()))
				{
					$attachedImagesList[$attachedObjectFields['ID']] = $attachedObjectFields;
				}
			}

			if (!empty($attachedImagesList))
			{
				foreach($ufList as $fieldName => $fieldData)
				{
					if (
						$fieldData['USER_TYPE_ID'] == 'disk_file'
						&& !empty($fieldData['VALUE'])
						&& is_array($fieldData['VALUE'])
					)
					{
						foreach($fieldData['VALUE'] as $key => $attachedObjectId)
						{
							if (isset($attachedImagesList[$attachedObjectId])) // is image
							{
								$foundInline = false;
								foreach($inlineAttachmentsList as $inlineAttachment)
								{
									if($attachedImagesList[$attachedObjectId][$inlineAttachment['KEY']] == $inlineAttachment['ID'])
									{
										$foundInline = true;
										break;
									}

								}

								if ($foundInline)
								{
									unset($ufList[$fieldName]['VALUE'][$key]);
								}
							}
						}
					}
				}
			}
		}
	}

	$result = [
		'CONTENT' => '',
		'CSS' => [],
		'JS' => [],
	];

	ob_start();

	foreach ($ufList as $uf)
	{
		if(!empty($uf["VALUE"]))
		{
			$APPLICATION->includeComponent(
				"bitrix:system.field.view",
				$uf["USER_TYPE"]["USER_TYPE_ID"],
				[
					"arUserField" => $uf,
					"TEMPLATE" => '',
					"LAZYLOAD" => 'N',
				],
				null,
				["HIDE_ICONS" => 'Y']
			);
		}
	}

	$result['CONTENT'] .= ob_get_clean();

	return $result;
}