- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/lib/search/mapbuilder.php
- Класс: BitrixMainSearchMapBuilder
- Вызов: MapBuilder::addPhone
public function addPhone($phone)
{
$phone = (string)$phone;
$value = preg_replace("/[^0-9#*]/i", "", $phone);
if($value == '')
return $this;
$altPhone = str_replace(' ', '', $phone);
$this->tokens[$altPhone] = true;
$convertedPhone = PhoneNumberParser::getInstance()
->parse($altPhone)
->format(PhoneNumberFormat::E164);
if ($convertedPhone != $altPhone)
{
$this->tokens[$convertedPhone] = true;
}
$length = mb_strlen($value);
if($length >= 10 && mb_substr($value, 0, 1) === '7')
{
$altPhone = '8'.mb_substr($value, 1);
$this->tokens[$altPhone] = true;
}
//Right bound. We will stop when 3 digits are left.
$bound = $length - 2;
if($bound > 0)
{
for($i = 0; $i < $bound; $i++)
{
$key = mb_substr($value, $i);
$this->tokens[$key] = true;
}
}
return $this;
}