Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
newstemplate.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
NewsTemplate
extends
PlainTemplate
12
{
13
protected
const
DEFAULT_BORDER_COLOR
=
'#468EE5'
;
14
15
protected
string
$title
=
''
;
16
17
public
function
buildMessage
(array $messageFields): array
18
{
19
$attach = new \CIMMessageParamAttach(0, static::DEFAULT_BORDER_COLOR);
20
21
$attach->SetDescription($this->
buildDescriptionText
());
22
23
$attach->AddGrid([
24
[
25
'DISPLAY'
=>
'LINE'
,
26
'NAME'
=> $this->title,
27
'VALUE'
=> $this->
buildMessageText
(),
28
]
29
]);
30
31
$messageFields[
'ATTACH'
] = $attach;
32
33
return
$messageFields;
34
}
35
36
protected
function
buildDescriptionText
(): string
37
{
38
$text = mb_substr(\CBPHelper::convertBBtoText($this->title .
' '
. $this->messageText), 0, 200);
39
if
(mb_strlen($text) === 200)
40
{
41
$text .=
'...'
;
42
}
43
44
return
$text;
45
}
46
47
protected
function
validate
(): void
48
{
49
parent::validate();
50
51
if
($this->title ===
''
)
52
{
53
$this->errors->setError(
new
Error
(
54
Loc::getMessage
(
'IM_BIZPROC_MESSAGE_NEWS_TEMPLATE_FIELD_NAME_MESSAGE_TITLE_ERROR'
)
55
));
56
}
57
}
58
59
public
function
setFields
(array $fields): self
60
{
61
parent::setFields($fields);
62
63
if
(!empty($fields[
'MessageTitle'
]))
64
{
65
$this->title = trim(\CBPHelper::stringify($fields[
'MessageTitle'
]));
66
}
67
68
return
$this;
69
}
70
71
public
static
function
getFieldsMap
(): array
72
{
73
return
array_merge(
74
[
75
'MessageTitle'
=> [
76
'Name'
=>
Loc::getMessage
(
'IM_BIZPROC_MESSAGE_NEWS_TEMPLATE_FIELD_NAME_MESSAGE_TITLE'
),
77
'FieldName'
=>
'title'
,
78
'Type'
=> FieldType::STRING,
79
'Required'
=>
true
,
80
'Multiple'
=>
false
,
81
],
82
],
83
parent::getFieldsMap(),
84
);
85
}
86
}
Bitrix\Bizproc\FieldType
Definition
fieldtype.php:12
Bitrix\Im\Integration\Bizproc\Message\NewsTemplate
Definition
newstemplate.php:12
Bitrix\Im\Integration\Bizproc\Message\NewsTemplate\DEFAULT_BORDER_COLOR
const DEFAULT_BORDER_COLOR
Definition
newstemplate.php:13
Bitrix\Im\Integration\Bizproc\Message\NewsTemplate\validate
validate()
Definition
newstemplate.php:47
Bitrix\Im\Integration\Bizproc\Message\NewsTemplate\getFieldsMap
static getFieldsMap()
Definition
newstemplate.php:71
Bitrix\Im\Integration\Bizproc\Message\NewsTemplate\$title
string $title
Definition
newstemplate.php:15
Bitrix\Im\Integration\Bizproc\Message\NewsTemplate\buildMessage
buildMessage(array $messageFields)
Definition
newstemplate.php:17
Bitrix\Im\Integration\Bizproc\Message\NewsTemplate\buildDescriptionText
buildDescriptionText()
Definition
newstemplate.php:36
Bitrix\Im\Integration\Bizproc\Message\NewsTemplate\setFields
setFields(array $fields)
Definition
newstemplate.php:59
Bitrix\Im\Integration\Bizproc\Message\PlainTemplate
Definition
plaintemplate.php:12
Bitrix\Im\Integration\Bizproc\Message\PlainTemplate\buildMessageText
buildMessageText()
Definition
plaintemplate.php:22
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Im\Integration\Bizproc\Message
Definition
alerttemplate.php:3
modules
im
lib
integration
bizproc
message
newstemplate.php
Создано системой
1.10.0