• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/lib/componenthelper.php
  • Класс: BitrixSocialnetworkComponentHelper
  • Вызов: ComponentHelper::convertMailDiskFileBBCode
static function convertMailDiskFileBBCode($text = '', $attachmentList = [])
{
	if (preg_match_all('|[MAILsDISKsFILEsID=([n]*d+)]|', $text, $matches))
	{
		foreach($matches[1] as $inlineFileId)
		{
			$attachmentId = false;
			if (mb_strpos($inlineFileId, 'n') === 0)
			{
				$found = false;
				foreach($attachmentList as $attachmentId => $attachment)
				{
					if (
						isset($attachment["OBJECT_ID"])
						&& (int)$attachment["OBJECT_ID"] === (int)mb_substr($inlineFileId, 1)
					)
					{
						$found = true;
						break;
					}
				}
				if (!$found)
				{
					$attachmentId = false;
				}
			}
			else
			{
				$attachmentId = $inlineFileId;
			}

			if ((int)$attachmentId > 0)
			{
				$text = preg_replace(
					'|[MAILsDISKsFILEsID='.$inlineFileId.']|',
					'[URL='.$attachmentList[$attachmentId]["URL"].']['.$attachmentList[$attachmentId]["NAME"].'][/URL]',
					$text
				);
			}
		}

		$p = new CTextParser();
		$p->allow = [ 'HTML' => 'Y', 'ANCHOR' => 'Y' ];
		$text = $p->convertText($text);
	}

	return $text;
}