Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
template.php
1<?php
9
11
14
15Loc::loadMessages(__FILE__);
16
24{
30 public static function getListByType()
31 {
32 return Templates\Selector::create()->getCategorized();
33 }
34
40 public static function getTypeList()
41 {
42 return Templates\Category::getNamedCodes();
43 }
44
52 public static function getById($type, $id)
53 {
54 return Templates\Selector::create()
55 ->withTypeId($type)
56 ->withId($id)
57 ->get();
58 }
59
66 public static function getList(array $parameters = array())
67 {
68 $selector = Templates\Selector::create();
69 if (isset($parameters[0]))
70 {
71 $selector->withTypeId($parameters[0]);
72 }
73 if (isset($parameters[1]))
74 {
75 $selector->withId($parameters[1]);
76 }
77 return $selector->withDefaultMessageCode()->getList();
78 }
79
87 public static function getTemplateListHtml($containerId = 'TEMPLATE_CONTAINER')
88 {
89 static $templateListByType;
90
91 if(!$templateListByType)
92 $templateListByType = \Bitrix\Sender\Preset\Template::getListByType();
93
94 $templateTypeList = \Bitrix\Sender\Preset\Template::getTypeList();
95
96 ob_start();
97 ?>
98 <script>
99 BX.ready(function(){
100 letterManager = new SenderLetterManager;
101 if(!letterManager.get('<?=$containerId?>'))
102 {
103 letterManager.add('<?=$containerId?>', {'container': BX('<?=$containerId?>')});
104 }
105 });
106 </script>
107 <div class="sender-template-cont">
108 <div>
109 <table style="width: 100%;">
110 <tr>
111 <td style="vertical-align: top;">
112 <div class="sender-template-type-selector">
113 <?
114 $firstTemplateType = null;
115 foreach($templateTypeList as $templateType => $templateTypeName):
116 if(!$firstTemplateType) $firstTemplateType = $templateType;
117 ?>
118 <div class="sender-template-type-selector-button sender-template-type-selector-button-type-<?=$templateType?>"
119 data-bx-sender-tmpl-type="<?=htmlspecialcharsbx($templateType)?>">
120 <?=$templateTypeName?>
121 </div>
122 <?endforeach;?>
123 </div>
124 </td>
125 <td style="vertical-align: top; width: 100%;">
126 <div class="sender-template-list-container">
127 <?foreach($templateTypeList as $templateType => $templateTypeName):?>
128 <div id="sender-template-list-type-container-<?=$templateType?>" class="sender-template-list-type-container sender-template-list-type-container-<?=$templateType?>" style="display: none;">
129 <?
130 if(isset($templateListByType[$templateType]))
131 foreach($templateListByType[$templateType] as $templateNum => $template):
132 $isContentForBlockEditor = TemplateTable::isContentForBlockEditor($template['HTML']);
133 ?>
134 <div class="sender-template-list-type-block">
135 <div class="sender-template-list-type-block-caption sender-template-list-block-selector"
136 data-bx-sender-tmpl-version="<?=($isContentForBlockEditor?'block':'visual')?>"
137 data-bx-sender-tmpl-name="<?=htmlspecialcharsbx($template['NAME'])?>"
138 data-bx-sender-tmpl-type="<?=htmlspecialcharsbx($template['TYPE'])?>"
139 data-bx-sender-tmpl-code="<?=htmlspecialcharsbx($template['ID'])?>"
140 data-bx-sender-tmpl-lang="<?=LANGUAGE_ID?>">
141 <a class="sender-link-email" href="javascript: void(0);">
142 <?=htmlspecialcharsbx($template['NAME'])?>
143 </a>
144 <?if(!$isContentForBlockEditor):?>
145 <br>
146 <span style="font-size: 10px;"><?=Loc::getMessage('SENDER_PRESET_TEMPLATE_OLD_EDITOR')?></span>
147 <?endif;?>
148 </div>
149 <div class="sender-template-list-type-block-img sender-template-list-block-selector"
150 data-bx-sender-tmpl-version="<?=($isContentForBlockEditor?'block':'visual')?>"
151 data-bx-sender-tmpl-name="<?=htmlspecialcharsbx($template['NAME'])?>"
152 data-bx-sender-tmpl-type="<?=htmlspecialcharsbx($template['TYPE'])?>"
153 data-bx-sender-tmpl-code="<?=htmlspecialcharsbx($template['ID'])?>"
154 data-bx-sender-tmpl-lang="<?=LANGUAGE_ID?>">
155 <?if(!empty($template['ICON'])):?>
156 <img src="<?=$template['ICON']?>">
157 <?endif;?>
158 </div>
159 <?if(!empty($template['HTML'])):?>
160 <div class="sender-template-message-preview-btn"
161 data-bx-sender-tmpl-name="<?=htmlspecialcharsbx($template['NAME'])?>"
162 data-bx-sender-tmpl-type="<?=htmlspecialcharsbx($template['TYPE'])?>"
163 data-bx-sender-tmpl-code="<?=htmlspecialcharsbx($template['ID'])?>"
164 data-bx-sender-tmpl-lang="<?=LANGUAGE_ID?>">
165 <a class="sender-link-email " href="javascript: void(0);"><?=Loc::getMessage('SENDER_PRESET_TEMPLATE_BTN_PREVIEW')?></a>
166 </div>
167 <?endif;?>
168 </div>
169 <?endforeach;?>
170 <?if(empty($templateListByType[$templateType])):?>
171 <div class="sender-template-list-type-blockempty">
172 <?=Loc::getMessage('SENDER_PRESET_TEMPLATE_NO_TMPL')?>
173 </div>
174 <?endif;?>
175 </div>
176 <?endforeach;?>
177 </div>
178 </td>
179 <td style="vertical-align: top;">
180 <span class="sender-template-btn-close" title="<?=Loc::getMessage('SENDER_PRESET_TEMPLATE_BTN_CLOSE')?>"></span>
181 </td>
182 </tr>
183 </table>
184 </div>
185 </div>
186 <?
187 return ob_get_clean();
188 }
189}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static getById($type, $id)
Definition template.php:52
static getList(array $parameters=array())
Definition template.php:66
static getTemplateListHtml($containerId='TEMPLATE_CONTAINER')
Definition template.php:87
static isContentForBlockEditor($content)
Definition template.php:258