/** * @return string */ public static function getTemplateListHtml($containerId = 'TEMPLATE_CONTAINER') { static $templateListByType; if (!$templateListByType) { $templateListByType = \Bitrix\Sender\Preset\Template::getListByType(); } $templateTypeList = \Bitrix\Sender\Preset\Template::getTypeList(); ob_start(); ?> <script> BX.ready(function(){ letterManager = new SenderLetterManager; letterManager.setTemplateListByType(<?php echo \CUtil::PhpToJSObject($templateListByType); ?> ); if(!letterManager.get('<?php echo $containerId; ?> ')) { letterManager.add('<?php echo $containerId; ?> ', {'container': BX('<?php echo $containerId; ?> ')}); } }); </script> <div class="sender-template-cont"> <div> <table> <tr> <td style="vertical-align: top;"> <div class="sender-template-type-selector"> <?php $firstTemplateType = null; foreach ($templateTypeList as $templateType => $templateTypeName) { if (!$firstTemplateType) { $firstTemplateType = $templateType; } ?> <div class="sender-template-type-selector-button sender-template-type-selector-button-type-<?php echo $templateType; ?> " bxsendertype="<?php echo htmlspecialcharsbx($templateType); ?> "> <?php echo $templateTypeName; ?> </div> <?php } ?> </div> </td> <td style="vertical-align: top;"> <div class="sender-template-list-container"> <?php foreach ($templateTypeList as $templateType => $templateTypeName) { ?> <div class="sender-template-list-type-container sender-template-list-type-container-<?php echo $templateType; ?> " style="display: none;"> <?php if (isset($templateListByType[$templateType])) { foreach ($templateListByType[$templateType] as $templateNum => $template) { ?> <div class="sender-template-list-type-block"> <div class="sender-template-list-type-block-caption sender-template-list-block-selector"> <a class="sender-link-email" href="javascript: void(0);" bxsendertype="<?php echo htmlspecialcharsbx($template['TYPE']); ?> " bxsendernum="<?php echo intval($templateNum); ?> "> <?php echo htmlspecialcharsbx($template['NAME']); ?> </a> </div> <div class="sender-template-list-type-block-img sender-template-list-block-selector" bxsendertype="<?php echo htmlspecialcharsbx($template['TYPE']); ?> " bxsendernum="<?php echo intval($templateNum); ?> "> <?php if (!empty($template['ICON'])) { ?> <img src="<?php echo $template['ICON']; ?> "> <?php } ?> </div> </div> <?php } } ?> <?php if (empty($templateListByType[$templateType])) { ?> <div class="sender-template-list-type-blockempty"> <?php echo Loc::getMessage('SENDER_PRESET_TEMPLATE_NO_TMPL'); ?> </div> <?php } ?> </div> <?php } ?> </div> </td> </tr> </table> </div> </div> <?php return ob_get_clean(); }
/** * @return string */ public static function getTemplateListHtml() { $arTemplateListByType = \Bitrix\Sender\Preset\Template::getListByType(); $arTemplateTypeList = \Bitrix\Sender\Preset\Template::getTypeList(); ob_start(); ?> <script> function ChangeTemplateList(type) { var tmplTypeContList = BX.findChildren(BX('TEMPLATE_CONTAINER'), {'className': 'sender-template-list-type-container'}, true); for(var i in tmplTypeContList) tmplTypeContList[i].style.display = 'none'; BX('TEMPLATE_CONTAINER_'+type).style.display = 'table-row'; var buttonList = BX.findChildren(BX('TEMPLATE_BUTTON_CONTAINER'), {'className': 'sender-template-type-selector-button'}, true); for(var j in buttonList) BX.removeClass(buttonList[j], 'sender-template-type-selector-button-selected'); BX.addClass(BX('TEMPLATE_BUTTON_'+type), 'sender-template-type-selector-button-selected'); } function SetTemplateToMessage(type, num) { BX('TEMPLATE_SELECTED_TITILE').innerHTML = templateListByType[type][num]['NAME']; var tmplTypeContList = BX.findChildren(BX('tabControl_layout'), {'className': 'hidden-when-show-template-list'}, true); for(i in tmplTypeContList) tmplTypeContList[i].style.display = 'table-row'; tmplTypeContList = BX.findChildren(BX('tabControl_layout'), {'className': 'show-when-show-template-list'}, true); for(i in tmplTypeContList) tmplTypeContList[i].style.display = 'none'; PutStringToMessageContainer(templateListByType[type][num]['HTML'], true); BX('IS_TEMPLATE_LIST_SHOWN').value = 'N'; } var templateListByType = <?php echo \CUtil::PhpToJSObject($arTemplateListByType); ?> ; </script> <div id="TEMPLATE_CONTAINER"> <div> <table> <tr> <td style="vertical-align: top;"> <div class="sender-template-type-selector" id="TEMPLATE_BUTTON_CONTAINER"> <?php $firstTemplateType = null; foreach ($arTemplateTypeList as $templateType => $templateTypeName) { if (!$firstTemplateType) { $firstTemplateType = $templateType; } ?> <div id="TEMPLATE_BUTTON_<?php echo $templateType; ?> " class="sender-template-type-selector-button" onclick="ChangeTemplateList('<?php echo htmlspecialcharsbx($templateType); ?> ');"> <?php echo $templateTypeName; ?> </div> <?php } ?> </div> </td> <td style="vertical-align: top;"> <div class="sender-template-list-container"> <?php foreach ($arTemplateTypeList as $templateType => $templateTypeName) { ?> <div class="sender-template-list-type-container" id="TEMPLATE_CONTAINER_<?php echo $templateType; ?> " style="display: none;"> <?php if (isset($arTemplateListByType[$templateType])) { foreach ($arTemplateListByType[$templateType] as $templateNum => $arTemplate) { ?> <div class="sender-template-list-type-block"> <div class="sender-template-list-type-block-caption"> <a class="sender-link-email" href="javascript: void(0);" onclick="SetTemplateToMessage('<?php echo htmlspecialcharsbx($arTemplate['TYPE']); ?> ', <?php echo intval($templateNum); ?> );" > <?php echo htmlspecialcharsbx($arTemplate['NAME']); ?> </a> </div> <div class="sender-template-list-type-block-img" onclick="SetTemplateToMessage('<?php echo htmlspecialcharsbx($arTemplate['TYPE']); ?> ', <?php echo intval($templateNum); ?> );"> <?php if (!empty($arTemplate['ICON'])) { ?> <img src="<?php echo $arTemplate['ICON']; ?> "> <?php } ?> </div> </div> <?php } } ?> <?php if (empty($arTemplateListByType[$templateType])) { ?> <div class="sender-template-list-type-blockempty"> <?php echo Loc::getMessage('SENDER_PRESET_TEMPLATE_NO_TMPL'); ?> </div> <?php } ?> </div> <?php } ?> </div> </td> </tr> </table> <script> ChangeTemplateList('BASE'); </script> </div> </div> <?php return ob_get_clean(); }
/** * @return string */ public static function getTemplateListHtml($containerId = 'TEMPLATE_CONTAINER') { static $templateListByType; if (!$templateListByType) { $templateListByType = \Bitrix\Sender\Preset\Template::getListByType(); } $templateTypeList = \Bitrix\Sender\Preset\Template::getTypeList(); ob_start(); ?> <script> BX.ready(function(){ letterManager = new SenderLetterManager; if(!letterManager.get('<?php echo $containerId; ?> ')) { letterManager.add('<?php echo $containerId; ?> ', {'container': BX('<?php echo $containerId; ?> ')}); } }); </script> <div class="sender-template-cont"> <div> <table> <tr> <td style="vertical-align: top;"> <div class="sender-template-type-selector"> <?php $firstTemplateType = null; foreach ($templateTypeList as $templateType => $templateTypeName) { if (!$firstTemplateType) { $firstTemplateType = $templateType; } ?> <div class="sender-template-type-selector-button sender-template-type-selector-button-type-<?php echo $templateType; ?> " data-bx-sender-tmpl-type="<?php echo htmlspecialcharsbx($templateType); ?> "> <?php echo $templateTypeName; ?> </div> <?php } ?> </div> </td> <td style="vertical-align: top;"> <div class="sender-template-list-container"> <?php foreach ($templateTypeList as $templateType => $templateTypeName) { ?> <div id="sender-template-list-type-container-<?php echo $templateType; ?> " class="sender-template-list-type-container sender-template-list-type-container-<?php echo $templateType; ?> " style="display: none;"> <?php /* if($templateType == 'MARKETPLACE') { \Bitrix\Main\Page\Asset::getInstance()->addCss('/bitrix/panel/main/marketplace.css'); ?> <script> function mp_hl(el, show) { if(show) BX.addClass(el, 'mp-over-over'); else BX.removeClass(el, 'mp-over-over'); } BX.ready(function(){ BX.ajax.insertToNode( '/bitrix/admin/update_system_market.php?category=55&lang=ru&mode=list', BX('sender-template-list-type-container-<?=$templateType?>') ); }); </script> <? } else */ if (isset($templateListByType[$templateType])) { foreach ($templateListByType[$templateType] as $templateNum => $template) { $isContentForBlockEditor = TemplateTable::isContentForBlockEditor($template['HTML']); ?> <div class="sender-template-list-type-block"> <div class="sender-template-list-type-block-caption sender-template-list-block-selector" data-bx-sender-tmpl-version="<?php echo $isContentForBlockEditor ? 'block' : 'visual'; ?> " data-bx-sender-tmpl-name="<?php echo htmlspecialcharsbx($template['NAME']); ?> " data-bx-sender-tmpl-type="<?php echo htmlspecialcharsbx($template['TYPE']); ?> " data-bx-sender-tmpl-code="<?php echo htmlspecialcharsbx($template['ID']); ?> " data-bx-sender-tmpl-lang="<?php echo LANGUAGE_ID; ?> "> <a class="sender-link-email" href="javascript: void(0);"> <?php echo htmlspecialcharsbx($template['NAME']); ?> </a> <?php if (!$isContentForBlockEditor) { ?> <br> <span style="font-size: 10px;"><?php echo Loc::getMessage('SENDER_PRESET_TEMPLATE_OLD_EDITOR'); ?> </span> <?php } ?> </div> <div class="sender-template-list-type-block-img sender-template-list-block-selector" data-bx-sender-tmpl-version="<?php echo $isContentForBlockEditor ? 'block' : 'visual'; ?> " data-bx-sender-tmpl-name="<?php echo htmlspecialcharsbx($template['NAME']); ?> " data-bx-sender-tmpl-type="<?php echo htmlspecialcharsbx($template['TYPE']); ?> " data-bx-sender-tmpl-code="<?php echo htmlspecialcharsbx($template['ID']); ?> " data-bx-sender-tmpl-lang="<?php echo LANGUAGE_ID; ?> "> <?php if (!empty($template['ICON'])) { ?> <img src="<?php echo $template['ICON']; ?> "> <?php } ?> </div> <?php if (!empty($template['HTML'])) { ?> <div class="sender-template-message-preview-btn" data-bx-sender-tmpl-name="<?php echo htmlspecialcharsbx($template['NAME']); ?> " data-bx-sender-tmpl-type="<?php echo htmlspecialcharsbx($template['TYPE']); ?> " data-bx-sender-tmpl-code="<?php echo htmlspecialcharsbx($template['ID']); ?> " data-bx-sender-tmpl-lang="<?php echo LANGUAGE_ID; ?> "> <a class="sender-link-email " href="javascript: void(0);"><?php echo Loc::getMessage('SENDER_PRESET_TEMPLATE_BTN_PREVIEW'); ?> </a> </div> <?php } ?> </div> <?php } } ?> <?php if (empty($templateListByType[$templateType])) { ?> <div class="sender-template-list-type-blockempty"> <?php echo Loc::getMessage('SENDER_PRESET_TEMPLATE_NO_TMPL'); ?> </div> <?php } ?> </div> <?php } ?> </div> </td> <td style="vertical-align: top;"> <span class="sender-template-btn-close" title="<?php echo Loc::getMessage('SENDER_PRESET_TEMPLATE_BTN_CLOSE'); ?> "></span> </td> </tr> </table> </div> </div> <?php return ob_get_clean(); }