1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
plaintemplate.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Im\Integration\Bizproc\Message;
4
5
use Bitrix\Bizproc\FieldType;
6
use Bitrix\Main\Error;
7
use Bitrix\Main\Localization\Loc;
8
9
Loc::loadMessages(__FILE__);
10
11
class
PlainTemplate
extends
Template
12
{
13
protected
string
$messageText
=
''
;
14
15
public
function
buildMessage
(
array
$messageFields
):
array
16
{
17
$messageFields
[
'MESSAGE'
] = $this->
buildMessageText
();
18
19
return
$messageFields;
20
}
21
22
protected
function
buildMessageText
(): string
23
{
24
$text
=
$this->messageText
;
25
26
if
($this->asRobotMessage)
27
{
28
$text
.= PHP_EOL . $this->
buildRobotText
();
29
}
30
31
return
$text
;
32
}
33
34
protected
function
buildDescriptionText
(): string
35
{
36
$text
= mb_substr(\
CTextParser::clearAllTags
($this->
getTextContents
()), 0, 200);
37
if
(mb_strlen(
$text
) === 200)
38
{
39
$text
.=
'...'
;
40
}
41
42
return
$text
;
43
}
44
45
protected
function
getTextContents
(): string
46
{
47
return
$this->messageText
;
48
}
49
54
protected
function
buildRobotText
()
55
{
56
return
'[size=10][i]'
. Loc::getMessage(
'IM_BIZPROC_MESSAGE_PLAIN_TEMPLATE_SENT_BY_ROBOT'
) .
'[/i][/size]'
;
57
}
58
59
protected
function
validate
(): void
60
{
61
if
($this->messageText ===
''
)
62
{
63
$fieldsMap = static::getFieldsMap();
64
65
$this->errors->setError(
66
new
Error
(
67
Loc::getMessage(
68
'IM_BIZPROC_MESSAGE_PLAIN_TEMPLATE_ERROR_EMPTY_FIELD'
,
69
[
'#FIELD_NAME#'
=> $fieldsMap[
'MessageText'
][
'Name'
]]
70
),
71
)
72
);
73
}
74
}
75
76
public
function
setFields
(
array
$fields
): self
77
{
78
if
(!empty(
$fields
[
'MessageText'
]))
79
{
80
$this->messageText = trim(\CBPHelper::stringify(
$fields
[
'MessageText'
]));
81
}
82
83
return
$this;
84
}
85
86
public
static
function
getFieldsMap
():
array
87
{
88
return
[
89
'MessageText'
=> [
90
'Name'
=> Loc::getMessage(
'IM_BIZPROC_MESSAGE_PLAIN_TEMPLATE_FIELD_NAME_MESSAGE_TEXT'
),
91
'FieldName'
=>
'template_message_text'
,
92
'Type'
=> FieldType::TEXT,
93
'Required'
=>
true
,
94
'Multiple'
=>
false
,
95
],
96
];
97
}
98
}
$messageFields
$messageFields
Определения
callback_ednaru.php:22
Bitrix\Im\Integration\Bizproc\Message\PlainTemplate
Определения
plaintemplate.php:12
Bitrix\Im\Integration\Bizproc\Message\PlainTemplate\validate
validate()
Определения
plaintemplate.php:59
Bitrix\Im\Integration\Bizproc\Message\PlainTemplate\buildMessageText
buildMessageText()
Определения
plaintemplate.php:22
Bitrix\Im\Integration\Bizproc\Message\PlainTemplate\buildRobotText
buildRobotText()
Определения
plaintemplate.php:54
Bitrix\Im\Integration\Bizproc\Message\PlainTemplate\getFieldsMap
static getFieldsMap()
Определения
plaintemplate.php:86
Bitrix\Im\Integration\Bizproc\Message\PlainTemplate\buildMessage
buildMessage(array $messageFields)
Определения
plaintemplate.php:15
Bitrix\Im\Integration\Bizproc\Message\PlainTemplate\$messageText
string $messageText
Определения
plaintemplate.php:13
Bitrix\Im\Integration\Bizproc\Message\PlainTemplate\buildDescriptionText
buildDescriptionText()
Определения
plaintemplate.php:34
Bitrix\Im\Integration\Bizproc\Message\PlainTemplate\setFields
setFields(array $fields)
Определения
plaintemplate.php:76
Bitrix\Im\Integration\Bizproc\Message\PlainTemplate\getTextContents
getTextContents()
Определения
plaintemplate.php:45
Bitrix\Im\Integration\Bizproc\Message\Template
Определения
template.php:9
Bitrix\Main\Error
Определения
error.php:15
CTextParser\clearAllTags
static clearAllTags($text)
Определения
textparser.php:2358
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$text
$text
Определения
template_pdf.php:79
$fields
$fields
Определения
yandex_run.php:501
bitrix
modules
im
lib
integration
bizproc
message
plaintemplate.php
Создано системой
1.14.0