Exemple #1
0
    /**
     * Init editor
     *
     * @param array $params
     * @return string
     */
    public static function initEditor(array $params)
    {
        $fieldName = $params['FIELD_NAME'];
        $fieldValue = $params['FIELD_VALUE'];
        $isUserHavePhpAccess = $params['HAVE_USER_ACCESS'];
        $showSaveTemplate = isset($params['SHOW_SAVE_TEMPLATE']) ? $params['SHOW_SAVE_TEMPLATE'] : true;
        $site = isset($params['SITE']) ? $params['SITE'] : '';
        $charset = isset($params['CHARSET']) ? $params['CHARSET'] : '';
        $contentUrl = isset($params['CONTENT_URL']) ? $params['CONTENT_URL'] : '';
        $templateTypeInput = isset($params['TEMPLATE_TYPE_INPUT']) ? $params['TEMPLATE_TYPE_INPUT'] : 'TEMPLATE_TYPE';
        $templateIdInput = isset($params['TEMPLATE_ID_INPUT']) ? $params['TEMPLATE_ID_INPUT'] : 'TEMPLATE_ID';
        $templateType = isset($params['TEMPLATE_TYPE']) ? $params['TEMPLATE_TYPE'] : '';
        $templateId = isset($params['TEMPLATE_ID']) ? $params['TEMPLATE_ID'] : '';
        $isTemplateMode = isset($params['IS_TEMPLATE_MODE']) ? (bool) $params['IS_TEMPLATE_MODE'] : true;
        if (!empty($params['PERSONALIZE_LIST']) && is_array($params['PERSONALIZE_LIST'])) {
            PostingRecipientTable::setPersonalizeList($params['PERSONALIZE_LIST']);
        }
        \CJSCore::RegisterExt("editor_mailblock", array("js" => array("/bitrix/js/sender/editor_mailblock.js"), "rel" => array()));
        \CJSCore::Init(array("editor_mailblock"));
        static $isInit;
        $isDisplayBlockEditor = $templateType && $templateId || static::isContentForBlockEditor($fieldValue);
        $editorHeight = 650;
        $editorWidth = '100%';
        ob_start();
        ?>
		<div id="bx-sender-visual-editor-<?php 
        echo $fieldName;
        ?>
" style="<?php 
        if ($isDisplayBlockEditor) {
            ?>
display: none;<?php 
        }
        ?>
">
		<?php 
        if (\Bitrix\Main\Config\Option::get('fileman', 'use_editor_3') == 'Y') {
            \Bitrix\Main\Loader::includeModule('fileman');
            ?>
		<script>
			BX.ready(function(){
				<?php 
            if (!$isInit) {
                $isInit = true;
                ?>
					var letterManager = new SenderLetterManager;
					letterManager.setMailBlockList(<?php 
                echo \CUtil::PhpToJSObject(\Bitrix\Sender\Preset\MailBlock::getBlockForVisualEditor());
                ?>
);
					letterManager.setPlaceHolderList(<?php 
                echo \CUtil::PhpToJSObject(\Bitrix\Sender\PostingRecipientTable::getPersonalizeList());
                ?>
);
				<?php 
            }
            ?>
			});

			BX.message({
				"BXEdMailBlocksTitle" : "<?php 
            echo Loc::getMessage('SENDER_TEMPLATE_EDITOR_MAILBLOCK');
            ?>
",
				"BXEdMailBlocksSearchPlaceHolder" : "<?php 
            echo Loc::getMessage('SENDER_TEMPLATE_EDITOR_MAILBLOCK_SEARCH');
            ?>
",
				"BXEdPlaceHolderSelectorTitle" : "<?php 
            echo Loc::getMessage('SENDER_TEMPLATE_EDITOR_PLACEHOLDER');
            ?>
"
			});
		</script>
		<?php 
            \CFileMan::AddHTMLEditorFrame($fieldName, $fieldValue, false, "text", array('height' => $editorHeight, 'width' => $editorWidth), "N", 0, "", "onfocus=\"t=this\"", false, !$isUserHavePhpAccess, false, array('componentFilter' => array('TYPE' => 'mail'), 'limit_php_access' => !$isUserHavePhpAccess));
            ?>
		<?php 
        } else {
            $fieldValue = htmlspecialcharsback($fieldValue);
            ?>
			<br>
			<?php 
            echo Loc::getMessage("SENDER_ENTITY_TEMPLATE_NOTE_OLD_EDITOR", array("%LINK_START%" => '<a href="/bitrix/admin/settings.php?mid=fileman&lang=' . LANGUAGE_ID . '">', "%LINK_END%" => '</a>'));
            ?>
			<br>
			<br>
			<textarea class="typearea" style="width:<?php 
            echo $editorWidth;
            ?>
;height:<?php 
            echo $editorHeight;
            ?>
px;" name="<?php 
            echo $fieldName;
            ?>
" id="bxed_<?php 
            echo $fieldName;
            ?>
" wrap="virtual"><?php 
            echo htmlspecialcharsbx($fieldValue);
            ?>
</textarea>
			<?php 
        }
        ?>
		</div>

		<div id="bx-sender-block-editor-<?php 
        echo $fieldName;
        ?>
" style="<?php 
        if (!$isDisplayBlockEditor) {
            ?>
display: none;<?php 
        }
        ?>
">
			<br/>
			<input type="hidden" name="<?php 
        echo htmlspecialcharsbx($templateTypeInput);
        ?>
" value="<?php 
        echo htmlspecialcharsbx($templateType);
        ?>
" />
			<input type="hidden" name="<?php 
        echo htmlspecialcharsbx($templateIdInput);
        ?>
" value="<?php 
        echo htmlspecialcharsbx($templateId);
        ?>
" />
			<?php 
        $url = '';
        if ($isDisplayBlockEditor) {
            if ($templateType && $templateId) {
                $url = '/bitrix/admin/sender_template_admin.php?';
                $url .= 'action=get_template&template_type=' . $templateType . '&template_id=' . $templateId;
                $url .= '&lang=' . LANGUAGE_ID . '&' . bitrix_sessid_get();
            } else {
                $url = $contentUrl;
            }
        }
        echo \Bitrix\Fileman\Block\EditorMail::show(array('id' => $fieldName, 'charset' => $charset, 'site' => $site, 'own_result_id' => 'bxed_' . $fieldName, 'url' => $url, 'templateType' => $templateType, 'templateId' => $templateId, 'isTemplateMode' => $isTemplateMode, 'isUserHavePhpAccess' => $isUserHavePhpAccess));
        ?>
		</div>

		<?php 
        if ($showSaveTemplate) {
            ?>
		<script>
			function ToggleTemplateSaveDialog()
			{
				BX('TEMPLATE_ACTION_SAVE_NAME_CONT').value = '';

				var currentDisplay =  BX('TEMPLATE_ACTION_SAVE_NAME_CONT').style.display;
				BX('TEMPLATE_ACTION_SAVE_NAME_CONT').style.display = BX.toggle(currentDisplay, ['inline', 'none']);
			}
		</script>
		<div class="adm-detail-content-item-block-save">
			<span>
				<input type="checkbox" value="Y" name="TEMPLATE_ACTION_SAVE" id="TEMPLATE_ACTION_SAVE" onclick="ToggleTemplateSaveDialog();">
				<label for="TEMPLATE_ACTION_SAVE"><?php 
            echo Loc::getMessage('SENDER_TEMPLATE_EDITOR_SAVE');
            ?>
</label>
			</span>
			<span id="TEMPLATE_ACTION_SAVE_NAME_CONT" style="display: none;"> <?php 
            echo Loc::getMessage('SENDER_TEMPLATE_EDITOR_SAVE_NAME');
            ?>
 <input type="text" name="TEMPLATE_ACTION_SAVE_NAME"></span>
		</div>
		<?php 
        }
        return ob_get_clean();
    }
Exemple #2
0
    /**
     * @param array $arParams
     * @return string
     */
    public static function initEditor(array $arParams)
    {
        $fieldName = $arParams['FIELD_NAME'];
        $fieldValue = $arParams['FIELD_VALUE'];
        $isUserHavePhpAccess = $arParams['HAVE_USER_ACCESS'];
        $showSaveTemplate = isset($arParams['SHOW_SAVE_TEMPLATE']) ? $arParams['SHOW_SAVE_TEMPLATE'] : true;
        if (!empty($arParams['PERSONALIZE_LIST']) && is_array($arParams['PERSONALIZE_LIST'])) {
            PostingRecipientTable::setPersonalizeList($arParams['PERSONALIZE_LIST']);
        }
        \CJSCore::RegisterExt("editor_mailblock", array("js" => "/bitrix/js/sender/editor_mailblock.js", "rel" => array()));
        static $isInit;
        $editorHeight = 650;
        $editorWidth = '100%';
        ob_start();
        if (\Bitrix\Main\Config\Option::get('fileman', 'use_editor_3') == 'Y') {
            \Bitrix\Main\Loader::includeModule('fileman');
            \CJSCore::Init(array("editor_mailblock"));
            ?>
		<script>
			//BX.ready(function(){
				<?php 
            if (!$isInit) {
                $isInit = true;
                ?>
					letterManager = new SenderLetterManager;
					letterManager.setMailBlockList(<?php 
                echo \CUtil::PhpToJSObject(\Bitrix\Sender\Preset\MailBlock::getBlockForVisualEditor());
                ?>
);
				<?php 
            }
            ?>
			//});

			BX.message({"BXEdMailBlocksTitle" : "<?php 
            echo Loc::getMessage('SENDER_TEMPLATE_EDITOR_MAILBLOCK');
            ?>
"});
			BX.message({"BXEdMailBlocksSearchPlaceHolder" : "<?php 
            echo Loc::getMessage('SENDER_TEMPLATE_EDITOR_MAILBLOCK_SEARCH');
            ?>
"});
		</script>
		<?php 
            \CFileMan::AddHTMLEditorFrame($fieldName, $fieldValue, false, "html", array('height' => $editorHeight, 'width' => $editorWidth), "N", 0, "", "onfocus=\"t=this\"", false, !$isUserHavePhpAccess, false, array('componentFilter' => array('TYPE' => 'mail'), 'limit_php_access' => !$isUserHavePhpAccess));
            ?>
		<?php 
        } else {
            $fieldValue = htmlspecialcharsback($fieldValue);
            ?>
			<br>
			<?php 
            echo Loc::getMessage("SENDER_ENTITY_TEMPLATE_NOTE_OLD_EDITOR", array("%LINK_START%" => '<a href="/bitrix/admin/settings.php?mid=fileman&lang=' . LANGUAGE_ID . '">', "%LINK_END%" => '</a>'));
            ?>
			<br>
			<br>
			<textarea class="typearea" style="width:<?php 
            echo $editorWidth;
            ?>
;height:<?php 
            echo $editorHeight;
            ?>
px;" name="<?php 
            echo $fieldName;
            ?>
" id="bxed_<?php 
            echo $fieldName;
            ?>
" wrap="virtual"><?php 
            echo htmlspecialcharsbx($fieldValue);
            ?>
</textarea>
			<?php 
        }
        if ($showSaveTemplate) {
            ?>
		<script>
			function ToggleTemplateSaveDialog()
			{
				BX('TEMPLATE_ACTION_SAVE_NAME_CONT').value = '';

				var currentDisplay =  BX('TEMPLATE_ACTION_SAVE_NAME_CONT').style.display;
				BX('TEMPLATE_ACTION_SAVE_NAME_CONT').style.display = BX.toggle(currentDisplay, ['inline', 'none']);
			}
		</script>
		<div class="adm-detail-content-item-block-save">
			<span>
				<input type="checkbox" value="Y" name="TEMPLATE_ACTION_SAVE" id="TEMPLATE_ACTION_SAVE" onclick="ToggleTemplateSaveDialog();">
				<label for="TEMPLATE_ACTION_SAVE"><?php 
            echo Loc::getMessage('SENDER_TEMPLATE_EDITOR_SAVE');
            ?>
</label>
			</span>
			<span id="TEMPLATE_ACTION_SAVE_NAME_CONT" style="display: none;"> <?php 
            echo Loc::getMessage('SENDER_TEMPLATE_EDITOR_SAVE_NAME');
            ?>
 <input type="text" name="TEMPLATE_ACTION_SAVE_NAME"></span>
		</div>
		<?php 
        }
        return ob_get_clean();
    }