1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
mapbuilder.php
См. документацию.
1<?php
2
3namespace Bitrix\Main\Search;
4
5use Bitrix\Main\ORM\Query\Filter;
6use Bitrix\Main\PhoneNumber;
7
9{
11 protected $tokens = array();
12
16 public function __construct()
17 {
18
19 }
20
25 public static function create()
26 {
27 return new static();
28 }
29
35 public function addText($token)
36 {
37 $token = (string)$token;
38 if($token == '')
39 return $this;
40
41 $value = Content::prepareStringToken($token);
42 $this->tokens[$value] = true;
43 return $this;
44 }
45
51 public function addInteger($token)
52 {
53 if (!Content::isIntegerToken($token))
54 return $this;
55
56 $token = Content::prepareIntegerToken($token);
57
58 $this->tokens[$token] = true;
59 return $this;
60 }
61
67 public function addPhone($phone)
68 {
69 $phone = (string)$phone;
70 $value = preg_replace("/[^0-9\#\*]/i", "", $phone);
71 if($value == '')
72 return $this;
73
74 $altPhone = str_replace(' ', '', $phone);
75 $this->tokens[$altPhone] = true;
76
77 $convertedPhone = PhoneNumber\Parser::getInstance()
78 ->parse($altPhone)
79 ->format(PhoneNumber\Format::E164);
80 if ($convertedPhone != $altPhone)
81 {
82 $this->tokens[$convertedPhone] = true;
83 }
84
85 $length = mb_strlen($value);
86 if($length >= 10 && str_starts_with($value, '7'))
87 {
88 $altPhone = '8'.substr($value, 1);
89 $this->tokens[$altPhone] = true;
90 }
91
92 //Right bound. We will stop when 3 digits are left.
93 $bound = $length - 2;
94 if($bound > 0)
95 {
96 for($i = 0; $i < $bound; $i++)
97 {
98 $key = mb_substr($value, $i);
99 $this->tokens[$key] = true;
100 }
101 }
102
103 return $this;
104 }
105
111 public function addEmail($email)
112 {
113 if($email === '')
114 {
115 return $this;
116 }
117
118 $keys = preg_split('/\W+/', $email, -1, PREG_SPLIT_NO_EMPTY);
119 foreach($keys as $key)
120 {
122 if(!isset($this->tokens[$key]))
123 {
124 $this->tokens[$key] = true;
125 }
126 }
127
129 $this->tokens[$key] = true;
130
131 return $this;
132 }
133
139 public function addUser($userId)
140 {
141 if(empty($userId))
142 {
143 return $this;
144 }
145
147 'select' => array('ID', 'LOGIN', 'NAME', 'LAST_NAME', 'SECOND_NAME', 'TITLE', 'EMAIL', 'PERSONAL_MOBILE'),
148 'filter' => array('=ID' => $userId)
149 ));
150
151 while($user = $orm->fetch())
152 {
153 $value = \CUser::FormatName(
154 \CSite::GetNameFormat(),
155 $user,
156 true,
157 false
158 );
159
160 $value = Content::prepareStringToken($value);
161 if($value != '')
162 {
163 $this->tokens[$value] = true;
164 }
165
166 self::addPhone($user['PERSONAL_MOBILE']);
167 self::addEmail($user['EMAIL']);
168 }
169
170 return $this;
171 }
172
177 public function build()
178 {
179 $tokens = array();
180
181 $minTokenSize = Filter\Helper::getMinTokenSize();
182
183 foreach ($this->tokens as $token => $result)
184 {
185 if (mb_strlen($token) >= $minTokenSize)
186 {
187 $tokens[$token] = $result;
188 }
189 }
190
191 return implode(" ", array_keys($tokens));
192 }
193}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static getList(array $parameters=array())
Определения datamanager.php:431
const E164
Определения format.php:7
static getInstance()
Определения parser.php:78
static prepareIntegerToken($token)
Определения content.php:28
static isIntegerToken($token)
Определения content.php:39
static prepareStringToken($token)
Определения content.php:18
addUser($userId)
Определения mapbuilder.php:139
static create()
Определения mapbuilder.php:25
addEmail($email)
Определения mapbuilder.php:111
addInteger($token)
Определения mapbuilder.php:51
addText($token)
Определения mapbuilder.php:35
addPhone($phone)
Определения mapbuilder.php:67
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$user
Определения mysql_to_pgsql.php:33
$email
Определения payment.php:49
if(empty($signedUserToken)) $key
Определения quickway.php:257
$i
Определения factura.php:643