Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
mailblockbase.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
MailBlockBase
25
{
29
const
LOCAL_DIR_BLOCK
=
'/modules/sender/preset/mailblock/'
;
30
34
public
static
function
onPresetMailBlockList
()
35
{
36
return
static::getList();
37
}
38
42
public
static
function
getList
()
43
{
44
$resultList = array();
45
46
$arBlockByType = static::getBlockListByType();
47
48
foreach
($arBlockByType as $type => $arBlock)
49
{
50
foreach
($arBlock as $blockName)
51
{
52
$result = static::getById($blockName);
53
if
(!empty($result))
54
{
55
$resultList[] = $result;
56
}
57
}
58
}
59
60
$resultListPersonal = array();
61
foreach
(\
Bitrix
\
Sender
\
PostingRecipientTable::getPersonalizeList
() as $arPersonalizeBlock)
62
{
63
$resultListPersonal[] = array(
64
'TYPE'
=>
Loc::getMessage
(
'TYPE_PRESET_MAILBLOCK_PERSONALISE'
),
65
'CODE'
=> $arPersonalizeBlock[
'CODE'
],
66
'NAME'
=> $arPersonalizeBlock[
'NAME'
],
67
'DESC'
=> $arPersonalizeBlock[
'DESC'
],
68
'ICON'
=>
''
,
69
'HTML'
=>
'#'
. $arPersonalizeBlock[
'CODE'
] .
'#'
70
);
71
}
72
73
$resultList = array_merge($resultListPersonal, $resultList);
74
75
return
$resultList;
76
}
77
81
public
static
function
getBlockListByType
()
82
{
83
$arBlockByType = array(
84
'BASE'
=> array(
85
'unsub'
,
86
'image'
,
87
'text'
,
88
'line'
,
89
'image_text'
,
90
'text_image'
,
91
'image2'
,
92
'image3'
,
93
'text2'
,
94
'text3'
,
95
)
96
);
97
98
return
$arBlockByType;
99
}
100
105
public
static
function
getById
($blockName)
106
{
107
$result =
null
;
108
$type =
null
;
109
110
$arBlockByType = static::getBlockListByType();
111
foreach
($arBlockByType as $searchType => $arBlock)
112
{
113
foreach
($arBlock as $searchBlockName)
114
{
115
if
($blockName == $searchBlockName)
116
{
117
$type = $searchType;
118
break
;
119
}
120
}
121
}
122
123
$fullPathOfFile = \Bitrix\Main\Loader::getLocal(static::LOCAL_DIR_BLOCK . bx_basename($blockName) .
'.html'
);
124
if
($fullPathOfFile)
125
{
126
$fileContent = File::getFileContents($fullPathOfFile);
127
128
if
($blockName ==
'unsub'
)
129
{
130
$fileContent = str_replace(
131
array(
'%TEXT_UNSUB_TEXT%'
,
'%TEXT_UNSUB_LINK%'
),
132
array(
133
Loc::getMessage
(
'PRESET_MAILBLOCK_'
. $blockName.
'_TEXT_UNSUB_TEXT'
),
134
Loc::getMessage
(
'PRESET_MAILBLOCK_'
. $blockName.
'_TEXT_UNSUB_LINK'
)
135
),
136
$fileContent
137
);
138
}
139
140
$result = array(
141
'TYPE'
=>
Loc::getMessage
(
'TYPE_PRESET_MAILBLOCK_'
.$type),
142
'CODE'
=> $blockName,
143
'NAME'
=>
Loc::getMessage
(
'PRESET_MAILBLOCK_'
. $blockName),
144
'ICON'
=>
''
,
145
'HTML'
=> $fileContent
146
);
147
}
148
149
150
return
$result;
151
}
152
158
public
static
function
update
($blockName, $html)
159
{
160
$result =
false
;
161
$fullPathOfFile = \Bitrix\Main\Loader::getLocal(static::LOCAL_DIR_BLOCK . bx_basename($blockName) .
'.html'
);
162
if
($fullPathOfFile)
163
$result = File::putFileContents($fullPathOfFile, $html);
164
165
return
$result;
166
}
167
}
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\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\ORM\Entity
Definition
entity.php:26
Bitrix\Sender\Posting\Sender
Definition
sender.php:44
Bitrix\Sender\PostingRecipientTable\getPersonalizeList
static getPersonalizeList()
Definition
posting.php:762
Bitrix\Sender\Preset\MailBlockBase
Definition
mailblockbase.php:25
Bitrix\Sender\Preset\MailBlockBase\update
static update($blockName, $html)
Definition
mailblockbase.php:158
Bitrix\Sender\Preset\MailBlockBase\getById
static getById($blockName)
Definition
mailblockbase.php:105
Bitrix\Sender\Preset\MailBlockBase\onPresetMailBlockList
static onPresetMailBlockList()
Definition
mailblockbase.php:34
Bitrix\Sender\Preset\MailBlockBase\LOCAL_DIR_BLOCK
const LOCAL_DIR_BLOCK
Definition
mailblockbase.php:29
Bitrix\Sender\Preset\MailBlockBase\getBlockListByType
static getBlockListByType()
Definition
mailblockbase.php:81
Bitrix\Sender\Preset\MailBlockBase\getList
static getList()
Definition
mailblockbase.php:42
Bitrix\Sender\Preset
Bitrix
modules
sender
lib
preset
mailblockbase.php
Создано системой
1.10.0