- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/classes/general/textparser.php
- Класс: CTextParser
- Вызов: CTextParser::convert_video
protected function convert_video($arParams)
{
global $APPLICATION;
if (
!is_array($arParams)
|| $arParams["PATH"] == ''
)
{
return false;
}
$trustedProviders = [
'YOUTUBE',
'RUTUBE',
'VIMEO',
'VK',
'FACEBOOK',
'INSTAGRAM',
];
ob_start();
if ($this->type == 'mail')
{
$pathEncoded = htmlspecialcharsbx($arParams['PATH']);
?>=$pathEncoded?>
}
elseif (in_array($arParams['TYPE'], $trustedProviders))
{
// add missing protocol to get host
if (mb_substr($arParams['PATH'], 0, 2) == '//')
{
$arParams['PATH'] = 'http:' . $arParams['PATH'];
}
$uri = new Uri($arParams['PATH']);
if (UrlPreview::isHostTrusted($uri) || $uri->getHost() == Application::getInstance()->getContext()->getServer()->getServerName())
{
// Replace http://someurl, https://someurl by //someurl
$arParams['PATH'] = preg_replace("/https?:\/\//i", '//', $arParams['PATH']);
$pathEncoded = htmlspecialcharsbx($arParams['PATH']);
if ($this->bMobile)
{
?>
}
else
{
?>
}
}
}
else
{
$playerParams = $arParams;
$playerParams['TYPE'] = $arParams['MIME_TYPE'];
$playerComponent = 'bitrix:player';
if ($this->bMobile)
{
$playerComponent = 'bitrix:mobile.player';
}
$APPLICATION->IncludeComponent(
$playerComponent, '', $playerParams,
null,
[
'HIDE_ICONS' => 'Y',
]
);
}
return ob_get_clean();
}