Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
messengerchat.php
1<?php
2
4
6{
7 private static function checkUrl($url) : bool
8 {
9 return
10 is_string($url) &&
11 preg_match('/^((https:\/\/)|(http:\/\/)){1}[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}$/i',$url);
12 }
13 private static function checkDomains($value)
14 {
15 if (array_key_exists('domains', $value) && is_array($value['domains']) && !empty($value['domains']))
16 {
17 foreach ($value['domains'] as $url)
18 {
19 if(!static::checkUrl($url))
20 {
21 return false;
22 }
23 }
24 return true;
25 }
26 return false;
27
28 }
29
30 static function prepareValue($value)
31 {
32 if(is_array($value) && array_key_exists('domains', $value) && is_array($value['domains']))
33 {
34 $value['domains'] = array_values(array_filter($value['domains']));
35 }
36 return parent::prepareValue($value);
37 }
38
39 protected static function checkValueFields($value): bool
40 {
41 return static::checkDomains($value);
42 }
43
47 static function available(): bool
48 {
49 return true;
50 }
51
55 static function required(): bool
56 {
57 return false;
58 }
59
60 protected static function getFields() : array
61 {
62 return array_merge(parent::getFields(),['domains']);
63 }
64}