CCrmUrlUtil::ToAbsoluteUrl

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmUrlUtil
  4. ToAbsoluteUrl
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_url_util.php
  • Класс: \CCrmUrlUtil
  • Вызов: CCrmUrlUtil::ToAbsoluteUrl
static function ToAbsoluteUrl($url)
{
	$url = trim(strval($url));

	if($url === '')
	{
		return '';
	}
	elseif(self::GetUrlScheme($url) !== '')
	{
		return $url;
	}

	$scheme = (CMain::IsHTTPS() ? 'https' : 'http');

	$host = '';
	if(defined('SITE_SERVER_NAME') && is_string(SITE_SERVER_NAME))
	{
		$host = SITE_SERVER_NAME;
	}

	if($host === '')
	{
		$host = COption::GetOptionString('main', 'server_name', '');
	}

	if($host === '')
	{
		$host = $_SERVER['SERVER_NAME'];
	}

	$port = intval($_SERVER['SERVER_PORT']);

	if(preg_match('/^\//', $url))
	{
		$url = mb_substr($url, 1);
	}

	return $scheme.'://'.$host.(($port !== 80 && $port !== 443) ? ':'.$port : '').'/'.$url;
}

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