CCrmCallToUrl::PrepareLinkAttributes

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmCallToUrl
  4. PrepareLinkAttributes
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_url_util.php
  • Класс: \CCrmCallToUrl
  • Вызов: CCrmCallToUrl::PrepareLinkAttributes
static function PrepareLinkAttributes($value, $params = array())
{
	$value = self::NormalizeNumberIfRequired($value);
	$format = self::GetFormat(self::Bitrix);

	if($format === self::Bitrix)
	{
		$paramsString = '';
		if (is_array($params) && count($params) > 0)
		{
			$paramsString = ', '.\Bitrix\Main\Web\Json::encode($params);
		}
		return array(
			'HREF' => "callto://{$value}",
			'ONCLICK' => "if(typeof(top.BXIM) !== 'undefined') { top.BXIM.phoneTo('{$value}'".$paramsString."); return BX.PreventDefault(event); }"
		);
	}

	if($format !== self::Custom )
	{
		return array(
			'HREF' => $format === self::Slashless ? "callto:{$value}" : "callto://{$value}",
			'ONCLICK' => ''
		);
	}

	if(!self::$URL_TEMPLATE || !self::$CLICK_HANDLER)
	{
		$settings =  self::GetCustomSettings();

		self::$URL_TEMPLATE = new CCrmUrlTemplate();
		self::$URL_TEMPLATE->SetTemplate(isset($settings['URL_TEMPLATE']) ? $settings['URL_TEMPLATE'] : 'callto:[phone]');

		self::$CLICK_HANDLER = new CCrmUrlTemplate();
		self::$CLICK_HANDLER->SetTemplate(isset($settings['CLICK_HANDLER']) ? $settings['CLICK_HANDLER'] : '');
	}

	$templateParams = array('PHONE' => $value);
	return array(
		'HREF' => self::$URL_TEMPLATE->Build($templateParams),
		'ONCLICK' => self::$CLICK_HANDLER->Build($templateParams)
	);
}

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