Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
mailblock.php
1
<?php
8
namespace
Bitrix\Sender\Preset
;
9
10
use
Bitrix\Main\Entity
;
11
use
Bitrix\Main\EventResult
;
12
use
Bitrix\Main\Event
;
13
use
Bitrix\Main\IO\File
;
14
use
Bitrix\Main\Localization\Loc
;
15
16
Loc::loadMessages
(__FILE__);
17
24
class
MailBlock
25
{
29
public
static
function
getListByType
()
30
{
31
$resultTemplateList = array();
32
$arTemplateList = static::getList();
33
foreach
($arTemplateList as $template)
34
$resultTemplateList[$template[
'TYPE'
]][] = $template;
35
36
return
$resultTemplateList;
37
}
38
42
public
static
function
getList
()
43
{
44
$resultList = array();
45
$event =
new
Event
(
'sender'
,
'OnPresetMailBlockList'
);
46
$event->send();
47
48
foreach
($event->getResults() as $eventResult)
49
{
50
if
($eventResult->getType() == EventResult::ERROR)
51
{
52
continue
;
53
}
54
55
$eventResultParameters = $eventResult->getParameters();
56
57
if
(!empty($eventResultParameters))
58
{
59
$resultList = array_merge($resultList, $eventResultParameters);
60
}
61
}
62
63
return
$resultList;
64
}
65
69
public
static
function
getBlockForVisualEditor
()
70
{
71
$arResult = array(
72
'items'
=> array(),
73
'groups'
=> array(),
74
'rootDefaultFilename'
=>
''
75
);
76
77
$arGroupExists = array();
78
$arBlocksByType = static::getListByType();
79
foreach
($arBlocksByType as $type => $arBlockList)
80
{
81
foreach
($arBlockList as $blockNum => $arBlock)
82
{
83
$name =
'mailblock'
.str_pad($blockNum+1, 4,
'0'
, STR_PAD_LEFT);
84
$key = $arBlock[
'TYPE'
].
'/'
.$name;
85
$arResult[
'items'
][$key] = array(
86
'name'
=> $name,
87
'path'
=> $arBlock[
'TYPE'
],
88
'title'
=> $arBlock[
'NAME'
],
89
'thumb'
=>
''
,
90
'code'
=> $arBlock[
'HTML'
],
91
'description'
=> empty($arBlock[
'DESC'
]) ?
''
: $arBlock[
'DESC'
],
92
'template'
=>
''
,
93
'level'
=>
''
,
94
'parent'
=> $arBlock[
'TYPE'
],
95
);
96
97
if
(!in_array($arBlock[
'TYPE'
], $arGroupExists))
98
{
99
$arResult[
'groups'
][] = array(
100
'path'
=>
''
,
101
'name'
=> $arBlock[
'TYPE'
],
102
'level'
=>
'0'
,
103
'default_name'
=>
'mailblockgroup'
. (count($arGroupExists) + 1)
104
);
105
$arGroupExists[] = $arBlock[
'TYPE'
];
106
}
107
108
}
// foreach $arBlockList
109
110
}
// foreach $arBlocksByType
111
112
if
(isset($arResult[
'groups'
][0]))
113
$arResult[
'rootDefaultFilename'
] = $arResult[
'groups'
][0][
'default_name'
];
114
115
return
$arResult;
116
}
117
}
Bitrix\Main\Event
Definition
event.php:5
Bitrix\Main\EventResult
Definition
eventresult.php:5
Bitrix\Main\IO\File
Definition
file.php:7
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\ORM\Entity
Definition
entity.php:26
Bitrix\Sender\Preset\MailBlock
Definition
mailblock.php:25
Bitrix\Sender\Preset\MailBlock\getBlockForVisualEditor
static getBlockForVisualEditor()
Definition
mailblock.php:69
Bitrix\Sender\Preset\MailBlock\getListByType
static getListByType()
Definition
mailblock.php:29
Bitrix\Sender\Preset\MailBlock\getList
static getList()
Definition
mailblock.php:42
Bitrix\Sender\Preset
modules
sender
lib
preset
mailblock.php
Создано системой
1.10.0