8namespace Bitrix\Fileman\Block;
11use Bitrix\Main\EventResult;
12use Bitrix\Main\Localization\Loc;
13use Bitrix\Main\Mail\EventMessageCompiler;
14use Bitrix\Main\SiteTable;
15use Bitrix\Main\Web\DOM\StyleInliner;
17Loc::loadMessages(__FILE__);
30 if (!isset(
$params[
'previewUrl']))
32 $params[
'previewUrl'] =
'/bitrix/admin/fileman_block_editor.php?action=preview_mail';
34 if (!isset(
$params[
'saveFileUrl']))
36 $params[
'saveFileUrl'] =
'/bitrix/admin/fileman_block_editor.php?action=save_file';
41 $editor->componentsAsBlocks =
array(
42 'bitrix:sale.basket.basket.small.mail' =>
array(
'NAME' => Loc::getMessage(
'BLOCK_EDITOR_BLOCK_COMPONENT_BASKET_NAME')),
43 'bitrix:sale.personal.order.detail.mail' =>
array(
'NAME' => Loc::getMessage(
'BLOCK_EDITOR_BLOCK_COMPONENT_ORDER_NAME')),
44 'bitrix:catalog.top.mail' =>
array(
'NAME' => Loc::getMessage(
'BLOCK_EDITOR_BLOCK_COMPONENT_CATALOG_NAME')),
45 'bitrix:sale.discount.coupon.mail' =>
array(
'NAME' => Loc::getMessage(
'BLOCK_EDITOR_BLOCK_COMPONENT_COUPON_NAME')),
46 'bitrix:bigdata.recommends.mail' =>
array(
'NAME' => Loc::getMessage(
'BLOCK_EDITOR_BLOCK_COMPONENT_BIGDATA_NAME')),
49 $editor->setBlockList(self::getBlockList());
64 'js' =>
array(
'/bitrix/js/fileman/block_editor/mail_handlers.js'),
65 'rel' =>
array(
'core',
'block_editor')
81 public static function removePhpFromHtml($html, $previousHtml =
null, $canEditPhp =
false, $canUseLpa =
false)
83 if (!$canEditPhp && $canUseLpa)
85 $html = \LPA::Process($html, $previousHtml);
87 else if (!$canEditPhp)
90 foreach($phpList as $php)
92 $surrogate =
'<span class="bxhtmled-surrogate" title="">'
95 $html = str_replace($php[2], $surrogate, $html);
98 $html = str_replace([
'<?',
'?>'], [
'< ?',
'? >'], $html);
124 $canEditPhp = (isset(
$params[
'CAN_EDIT_PHP']) &&
$params[
'CAN_EDIT_PHP']);
125 $canUseLpa = (isset(
$params[
'CAN_USE_LPA']) &&
$params[
'CAN_USE_LPA']);
126 $html = static::removePhpFromHtml($html,
null, $canEditPhp, $canUseLpa);
136 $siteDb = SiteTable::getList(
array(
137 'select' =>
array(
'LID',
'SERVER_NAME',
'SITE_NAME',
'CULTURE_CHARSET'=>
'CULTURE.CHARSET'),
140 if(!$siteRow = $siteDb->fetch())
142 $siteDb = SiteTable::getList(
array(
143 'select' =>
array(
'LID',
'SERVER_NAME',
'SITE_NAME',
'CULTURE_CHARSET'=>
'CULTURE.CHARSET'),
144 'filter' =>
array(
'DEF' =>
true)
146 $siteRow = $siteDb->fetch();
149 $fields[
'SITE_NAME'] = $siteRow[
'SITE_NAME'];
150 $fields[
'SERVER_NAME'] = $siteRow[
'SERVER_NAME'];
151 $charset = $siteRow[
'CULTURE_CHARSET'];
153 $messageParams =
array(
156 'BODY_TYPE' =>
'html',
157 'EMAIL_TO' =>
'#EMAIL_TO#',
160 'SITE' => $siteRow[
'LID'],
161 'CHARSET' => $charset,
164 $event =
new Event(
"main",
"OnBeforeBlockEditorMailPreview", $messageParams);
166 foreach (
$event->getResults() as $eventResult)
168 if($eventResult->getType() !== EventResult::ERROR)
170 $messageParams = array_merge($messageParams, $eventResult->getParameters());
179 $eventParams =
array(
'HTML' => $html,
'INLINE_HTML' => $inlineHtml);
180 $event =
new Event(
"main",
"OnAfterBlockEditorMailPreview", $eventParams);
182 foreach (
$event->getResults() as $eventResult)
184 if($eventResult->getType() !== EventResult::ERROR)
186 $eventParams = array_merge($eventParams, $eventResult->getParameters());
191 return $eventParams[
'INLINE_HTML'];
203 'CODE' =>
'text',
'NAME' => Loc::getMessage(
'BLOCK_EDITOR_BLOCK_TEXT_NAME'),
204 'DESC' => Loc::getMessage(
'BLOCK_EDITOR_BLOCK_TEXT_DESC'),
206 <table border="0" cellpadding="0" cellspacing="0" width="100%" class="bxBlockText">
207 <tbody class="bxBlockOut">
209 <td valign="top" class="bxBlockInn bxBlockInnText">
210 <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%">
213 <td valign="top" class="bxBlockPadding bxBlockContentText">
214 ' . Loc::getMessage(
'BLOCK_EDITOR_BLOCK_TEXT_EXAMPLE') .
'
226 'CODE' =>
'boxedtext',
'NAME' => Loc::getMessage(
'BLOCK_EDITOR_BLOCK_BOXEDTEXT_NAME'),
227 'DESC' => Loc::getMessage(
'BLOCK_EDITOR_BLOCK_BOXEDTEXT_DESC'),
229 <table border="0" cellpadding="0" cellspacing="0" width="100%" class="bxBlockBoxedText">
230 <tbody class="bxBlockOut">
232 <td valign="top" class="bxBlockInn bxBlockInnBoxedText" >
233 <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%">
236 <td valign="top" class="bxBlockPadding">
237 <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%" class="bxBlockContentEdge" style="border: 1px solid rgb(153, 153, 153); background-color: rgb(235, 235, 235);">
240 <td valign="top" class="bxBlockPadding bxBlockContentText">
241 ' . Loc::getMessage(
'BLOCK_EDITOR_BLOCK_BOXEDTEXT_EXAMPLE') .
'
257 'CODE' =>
'line',
'NAME' => Loc::getMessage(
'BLOCK_EDITOR_BLOCK_LINE_NAME'),
258 'DESC' => Loc::getMessage(
'BLOCK_EDITOR_BLOCK_LINE_DESC'),
260 <table border="0" cellpadding="0" cellspacing="0" width="100%" class="bxBlockLine">
261 <tbody class="bxBlockOut">
263 <td valign="top" class="bxBlockInn bxBlockInnLine">
264 <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%">
267 <td valign="top" class="bxBlockPadding">
268 <span class="bxBlockContentLine" style="height: 2px; background-color: #EBEBEB; display: block;"></span>
280 'CODE' =>
'image',
'NAME' => Loc::getMessage(
'BLOCK_EDITOR_BLOCK_IMAGE_NAME'),
281 'DESC' => Loc::getMessage(
'BLOCK_EDITOR_BLOCK_IMAGE_DESC'),
283 <table border="0" cellpadding="0" cellspacing="0" width="100%" class="bxBlockImage">
284 <tbody class="bxBlockOut">
286 <td valign="top" class="bxBlockInn bxBlockInnImage">
287 <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%">
290 <td valign="top" class="bxBlockPadding bxBlockContentImage" style="text-align: center">
292 <img align="center" data-bx-editor-def-image="1" src="/bitrix/images/fileman/block_editor/photo-default.png" class="bxImage">
305 'CODE' =>
'imagegroup',
'NAME' => Loc::getMessage(
'BLOCK_EDITOR_BLOCK_IMAGEGROUP_NAME'),
306 'DESC' => Loc::getMessage(
'BLOCK_EDITOR_BLOCK_IMAGEGROUP_DESC'),
308 <table border="0" cellpadding="0" cellspacing="0" width="100%" class="bxBlockImageGroup">
309 <tbody class="bxBlockOut">
311 <td valign="top" class="bxBlockInn bxBlockInnImageGroup">
312 <table align="left" border="0" cellpadding="0" cellspacing="0">
315 <td valign="top" class="bxBlockContentImageGroup">
316 <table align="left" border="0" cellpadding="0" cellspacing="0" width="260" >
319 <td valign="top" class="bxBlockPadding bxBlockContentImage">
320 <img align="left" data-bx-editor-def-image="1" src="/bitrix/images/fileman/block_editor/photo-default.png" class="bxImage">
324 </table><table align="left" border="0" cellpadding="0" cellspacing="0" width="260">
327 <td valign="top" class="bxBlockPadding bxBlockContentImage">
328 <img align="left" data-bx-editor-def-image="1" src="/bitrix/images/fileman/block_editor/photo-default.png" class="bxImage">
344 'CODE' =>
'boxedimage',
'NAME' => Loc::getMessage(
'BLOCK_EDITOR_BLOCK_BOXEDIMAGE_NAME'),
345 'DESC' => Loc::getMessage(
'BLOCK_EDITOR_BLOCK_BOXEDIMAGE_DESC'),
347 <table border="0" cellpadding="0" cellspacing="0" width="100%" class="bxBlockBoxedImage">
348 <tbody class="bxBlockOut">
350 <td valign="top" class="bxBlockInn bxBlockInnBoxedImage">
351 <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%">
354 <td valign="top" class="bxBlockPadding">
355 <table width="100%" align="left" border="0" cellpadding="0" cellspacing="0" class="bxBlockContentEdge" style="border: 1px solid rgb(153, 153, 153); background-color: rgb(235, 235, 235);">
358 <td valign="top" class="bxBlockPadding bxBlockContentImage" style="text-align: center;">
360 <img align="center" data-bx-editor-def-image="1" src="/bitrix/images/fileman/block_editor/photo-default.png" class="bxImage">
365 <td valign="top" class="bxBlockPadding bxBlockContentText" style="text-align: center;">
366 ' . Loc::getMessage(
'BLOCK_EDITOR_BLOCK_TEXT_EXAMPLE') .
'
382 'CODE' =>
'imagetext',
'NAME' => Loc::getMessage(
'BLOCK_EDITOR_BLOCK_IMAGETEXT_NAME'),
383 'DESC' => Loc::getMessage(
'BLOCK_EDITOR_BLOCK_IMAGETEXT_DESC'),
385 <table border="0" cellpadding="0" cellspacing="0" width="100%" class="bxBlockImageText">
386 <tbody class="bxBlockOut">
388 <td valign="top" class="bxBlockInn bxBlockInnImageText">
389 <table align="left" border="0" cellpadding="0" cellspacing="0" class="bxBlockContentItemImageText" width="290">
392 <td valign="top" class="bxBlockPadding bxBlockContentImage">
394 <img data-bx-editor-def-image="1" src="/bitrix/images/fileman/block_editor/photo-default.png" class="bxImage">
401 <table align="left" border="0" cellpadding="0" cellspacing="0" class="bxBlockContentItemImageText" width="290">
404 <td valign="top" class="bxBlockPadding bxBlockContentText">
405 ' . Loc::getMessage(
'BLOCK_EDITOR_BLOCK_TEXT_EXAMPLE') .
'
417 'CODE' =>
'button',
'NAME' => Loc::getMessage(
'BLOCK_EDITOR_BLOCK_BUTTON_NAME'),
418 'DESC' => Loc::getMessage(
'BLOCK_EDITOR_BLOCK_BUTTON_DESC'),
420 <table border="0" cellpadding="0" cellspacing="0" width="100%" class="bxBlockButton">
421 <tbody class="bxBlockOut">
423 <td valign="top" class="bxBlockPadding bxBlockInn bxBlockInnButton">
424 <table align="center" border="0" cellpadding="0" cellspacing="0" class="bxBlockContentButtonEdge">
429 class="bxBlockContentButton"
430 title="' . Loc::getMessage(
'BLOCK_EDITOR_BLOCK_BUTTON_EXAMPLE') .
'"
434 ' . Loc::getMessage(
'BLOCK_EDITOR_BLOCK_BUTTON_EXAMPLE') .
'
447 'CODE' =>
'code',
'NAME' => Loc::getMessage(
'BLOCK_EDITOR_BLOCK_CODE_NAME'),
448 'DESC' => Loc::getMessage(
'BLOCK_EDITOR_BLOCK_CODE_DESC'),
450 <table border="0" cellpadding="0" cellspacing="0" width="100%" class="bxBlockCode">
451 <tbody class="bxBlockOut">
453 <td valign="top" class="bxBlockPadding bxBlockInn bxBlockInnCode">
454 ' . Loc::getMessage(
'BLOCK_EDITOR_BLOCK_CODE_EXAMPLE') .
'
461 'CODE' =>
'footer',
'TYPE' =>
'text',
'NAME' => Loc::getMessage(
'BLOCK_EDITOR_BLOCK_FOOTER_NAME'),
462 'DESC' => Loc::getMessage(
'BLOCK_EDITOR_BLOCK_FOOTER_DESC'),
464 <table border="0" cellpadding="0" cellspacing="0" width="100%" class="bxBlockText">
465 <tbody class="bxBlockOut">
467 <td valign="top" class="bxBlockInn bxBlockInnText" >
468 <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%">
471 <td valign="top" class="bxBlockPadding bxBlockContentText" style="text-align: center;">
472 <br><a href="#UNSUBSCRIBE_LINK#">' . Loc::getMessage(
'BLOCK_EDITOR_BLOCK_FOOTER_EXAMPLE') .
'</a>
473 <br><a href="#CONSENT_LINK#">' . Loc::getMessage(
'BLOCK_EDITOR_BLOCK_FOOTER_CONSENT_EXAMPLE') .
'</a>
485 'CODE' =>
'social',
'NAME' => Loc::getMessage(
'BLOCK_EDITOR_BLOCK_SOCIAL_NAME'),
486 'DESC' => Loc::getMessage(
'BLOCK_EDITOR_BLOCK_SOCIAL_DESC'),
488 <table border="0" cellpadding="0" cellspacing="0" width="100%" class="bxBlockSocial">
489 <tbody class="bxBlockOut">
491 <td valign="top" class="bxBlockInn bxBlockInnSocial" >
493 <table align="center" border="0" cellpadding="0" cellspacing="0" class="bxBlockContentEdgeSocial">
496 <td valign="top" class="bxBlockPadding">
498 <table align="left" border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate !important; margin-right: 10px;">
501 <td valign="top" class="" style="padding-top: 5px; padding-right: 10px; padding-bottom: 5px; padding-left: 10px;">
503 class="bxBlockContentSocial"
504 href="http://vk.com/"
506 style="font-weight: bold; color: #626262; letter-spacing: normal;line-height: 100%;text-align: center; text-decoration: underline; font-size: 12px;"
507 >' . Loc::getMessage(
'BLOCK_EDITOR_BLOCK_SOCIAL_VK') .
'</a>
515 <table align="left" border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate !important; margin-right: 10px;">
518 <td valign="top" class="" style="padding-top: 5px; padding-right: 10px; padding-bottom: 5px; padding-left: 10px; font-size: 12px;">
520 class="bxBlockContentSocial"
521 href="http://facebook.com/"
523 style="font-weight: bold; color: #626262; letter-spacing: normal;line-height: 100%;text-align: center; text-decoration: underline; font-size: 12px;"
524 >' . Loc::getMessage(
'BLOCK_EDITOR_BLOCK_SOCIAL_FACEBOOK') .
'</a>
530 <table align="left" border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate !important; margin-right: 10px;">
533 <td valign="top" class="" style="padding-top: 5px; padding-right: 10px; padding-bottom: 5px; padding-left: 10px; font-size: 12px;">
535 class="bxBlockContentSocial"
536 href="http://www.instagram.com/"
538 style="font-weight: bold; color: #626262; letter-spacing: normal;line-height: 100%;text-align: center; text-decoration: underline; font-size: 12px;"
539 >' . Loc::getMessage(
'BLOCK_EDITOR_BLOCK_SOCIAL_INSTAGRAM') .
'</a>
547 <table align="left" border="0" cellpadding="0" cellspacing="0" style="border-collapse: separate !important; margin-right: 10px;">
550 <td valign="top" class="" style="padding-top: 5px; padding-right: 10px; padding-bottom: 5px; padding-left: 10px; font-size: 12px;">
552 class="bxBlockContentSocial"
553 href="http://twitter.com/"
555 style="font-weight: bold; color: #626262; letter-spacing: normal;line-height: 100%;text-align: center; text-decoration: underline; font-size: 12px;"
556 >' . Loc::getMessage(
'BLOCK_EDITOR_BLOCK_SOCIAL_TWITTER') .
'</a>
static isAvailableRussian()
static isNotAvailableInRussian()
static removePhpFromHtml($html, $previousHtml=null, $canEditPhp=false, $canUseLpa=false)
static createInstance($params)
static getPreview(array $params)
static show(array $params)
static createInstance(array $arMessageParams)
static inlineHtml($html, array $styleList=null)
static Init($arExt=array(), $bReturn=false)
static RegisterExt($name, $arPaths)
static ParseFile($filesrc, $limit=false)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
$GLOBALS['_____370096793']