Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
mailblockbase.php
1<?php
9
15
16Loc::loadMessages(__FILE__);
17
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}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static update($blockName, $html)