1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
MessageContent.php
См. документацию.
1<?php
2
3declare(strict_types=1);
4
5namespace Bitrix\Im\V2\Analytics;
6
7use Bitrix\Im\Text;
8use Bitrix\Im\V2\Message;
9use Bitrix\Im\V2\Message\Params;
10use CSmileGallery;
11
13{
14 public function __construct(private readonly Message $message)
15 {
16 }
17
18 public function isSystemMessage(): bool
19 {
20 return $this->message->getAuthorId() === 0;
21 }
22
23 public function hasText(): bool
24 {
25 $text = $this->message->getMessage();
26
27 return (null !== $text) && (0 !== strlen($text));
28 }
29
30 public function hasAttach(): bool
31 {
32 return $this->message->getAttach()->count() > 0;
33 }
34
35 public function hasFiles(): bool
36 {
37 return $this->message->hasFiles();
38 }
39
40 public function isEmptyMessage(): bool
41 {
42 return !$this->hasText() && !$this->hasFiles() && !$this->hasAttach();
43 }
44
45 public function isDeletedMessage(): bool
46 {
47 return $this->message->isDeleted() || $this->isEmptyMessage();
48 }
49
50 public function isForward(): bool
51 {
52 return $this->message->isForward();
53 }
54
55 public function hasOnlyText(): bool
56 {
57 if (!$this->hasText())
58 {
59 return false;
60 }
61
62 return !$this->hasFiles() && !$this->hasAttach();
63 }
64
65 protected function getAllSmiles(): array
66 {
67 $result = [];
68 $smiles = CSmileGallery::getSmilesWithSets(
69 CSmileGallery::GALLERY_DEFAULT,
70 ['FULL_TYPINGS' => 'Y']
71 )['SMILE'] ?? [];
72
73 foreach ($smiles as $smile)
74 {
75 $typings = explode(' ', $smile['TYPING']);
76
77 foreach ($typings as $typing)
78 {
79 $result[] = $typing;
80 }
81 }
82
83 return $result;
84 }
85
86 private function isFitForSmilesOnly(): bool
87 {
88 $replyIds = $this->message->getAdditionalMessageIds();
89
90 if (count($replyIds) > 0)
91 {
92 foreach ($replyIds as $replyId)
93 {
94 if ($replyId > 0)
95 {
96 return false;
97 }
98 }
99 }
100
101 if ($this->isForward())
102 {
103 return false;
104 }
105
106 if (!$this->hasOnlyText())
107 {
108 return false;
109 }
110
111 return true;
112 }
113
114 public function hasSmilesOnly(): bool
115 {
116 if (!$this->isFitForSmilesOnly())
117 {
118 return false;
119 }
120
121 $smiles = $this->getAllSmiles();
122 $message = $this->message->getMessage();
123 $count = 0;
124
125 return (trim(str_replace($smiles, '', $message, $count)) === '') && ($count < 4);
126 }
127
128 public function isEmojiOnly(): bool
129 {
130 if (!$this->isFitForSmilesOnly())
131 {
132 return false;
133 }
134
135 return Text::isOnlyEmoji($this->message->getMessage());
136 }
137
138 public function isServerComponent(): bool
139 {
140 return $this->message->getParams()->isSet(Params::COMPONENT_ID);
141 }
142
143 public function getComponentName(): string
144 {
145 if ($this->isDeletedMessage())
146 {
147 return 'DeletedMessage';
148 }
149
150 if ($this->isServerComponent())
151 {
152 return $this->message->getParams()->get(Params::COMPONENT_ID)->getValue();
153 }
154
155 if ($this->isSystemMessage())
156 {
157 return 'SystemMessage';
158 }
159
160 if ($this->hasFiles())
161 {
162 return 'FileMessage';
163 }
164
165 if ($this->isEmojiOnly() || $this->hasSmilesOnly())
166 {
167 return 'SmileMessage';
168 }
169
170 return 'DefaultMessage';
171 }
172}
$count
Определения admin_tab.php:4
static isOnlyEmoji($text)
Определения text.php:233
__construct(private readonly Message $message)
Определения MessageContent.php:14
</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
Определения Uuid.php:3
$message
Определения payment.php:8
$text
Определения template_pdf.php:79
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936