1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
mention.php
См. документацию.
1<?php
2
9namespace Bitrix\Socialnetwork\Helper;
10
12{
13 protected const PATTERN_USER = '/\[user\s*=\s*([^\]]*)\](.+?)\[\/user\]/isu';
14 protected const PATTERN_PROJECT = '/\[project\s*=\s*([^\]]*)\](.+?)\[\/project\]/isu';
15 protected const PATTERN_DEPARTMENT = '/\[department\s*=\s*([^\]]*)\](.+?)\[\/department\]/isu';
16
17 protected static function getPatternsList(): array
18 {
19 return [
20 self::PATTERN_USER,
21 self::PATTERN_PROJECT,
22 self::PATTERN_DEPARTMENT,
23 ];
24 }
25
32 public static function getUserIds(string $text = ''): array
33 {
34 $usersData = self::getUsers($text);
35 return array_map(function($item) { return $item['ID']; }, $usersData);
36 }
37
44 public static function getUsers(string $text = ''): array
45 {
46 return self::getEntitiesList($text, self::PATTERN_USER);
47 }
48
49 public static function getProjectIds(string $text = ''): array
50 {
51 $projectsData = self::getProjects($text);
52 return array_map(function($item) { return $item['ID']; }, $projectsData);
53 }
54
55 public static function getProjects(string $text = ''): array
56 {
57 return self::getEntitiesList($text, self::PATTERN_PROJECT);
58 }
59
60 public static function getDepartmentIds(string $text = ''): array
61 {
62 $departmentsData = self::getDepartments($text);
63 return array_map(function($item) { return $item['ID']; }, $departmentsData);
64 }
65
66 public static function getDepartments(string $text = ''): array
67 {
68 return self::getEntitiesList($text, self::PATTERN_DEPARTMENT);
69 }
70
71 protected static function getEntitiesList(string $text = '', string $pattern = ''): array
72 {
73 $result = [];
74 preg_match_all($pattern, $text, $matches);
75
76 if (empty($matches))
77 {
78 return $result;
79 }
80
81 foreach($matches[1] as $key => $userId)
82 {
83 $result[] = [
84 'ID' => (int)$userId,
85 'NAME' => $matches[2][$key],
86 ];
87 }
88
89 return $result;
90 }
91
98 public static function clear(string $text = ''): string
99 {
100 $result = $text;
101
102 foreach (self::getPatternsList() as $pattern)
103 {
104 $result = preg_replace(
105 $pattern,
106 '\\2',
107 $result
108 );
109 }
110
111 return $result;
112 }
113}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static getUsers(string $text='')
Определения mention.php:44
static getDepartmentIds(string $text='')
Определения mention.php:60
static getUserIds(string $text='')
Определения mention.php:32
const PATTERN_PROJECT
Определения mention.php:14
static clear(string $text='')
Определения mention.php:98
const PATTERN_DEPARTMENT
Определения mention.php:15
static getDepartments(string $text='')
Определения mention.php:66
static getProjects(string $text='')
Определения mention.php:55
static getPatternsList()
Определения mention.php:17
static getProjectIds(string $text='')
Определения mention.php:49
static getEntitiesList(string $text='', string $pattern='')
Определения mention.php:71
</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
if(empty($signedUserToken)) $key
Определения quickway.php:257
$text
Определения template_pdf.php:79
if(!Loader::includeModule('sale')) $pattern
Определения index.php:20
$matches
Определения index.php:22