• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/userconsent/text.php
  • Класс: BitrixMainUserConsentText
  • Вызов: Text::replace
static function replace($template, array $data, $isCut = false)
{
	$from = array();
	$to = array();

	$dataTmp = array();
	foreach ($data as $key => $value)
	{
		$key = mb_strtolower($key);
		if (is_array($value))
		{
			$value = self::formatArrayToText($value);
		}
		else
		{
			$value = (string) $value;
		}

		$dataTmp[$key] = $value;
	}
	$data = $dataTmp;

	foreach ($data as $key => $value)
	{
		$from[] = '%' . $key . '%';
		$to[] = $value;
	}

	$template = str_replace($from, $to, $template);

	if ($isCut)
	{
		$template = self::cut($template, $data);
	}

	return $template;
}