/// <summary>
    /// Loads content from specific newsletter template.
    /// </summary>
    private void LoadContent()
    {
        EmailTemplateInfo emailTemplate = EmailTemplateInfoProvider.GetEmailTemplateInfo(mTemplateID);

        if ((emailTemplate == null) || string.IsNullOrEmpty(emailTemplate.TemplateBody))
        {
            return;
        }

        // Remove security parameters from macros
        string templateText = MacroResolver.RemoveSecurityParameters(emailTemplate.TemplateBody, true, null);

        if (!RequestHelper.IsPostBack() && (issue != null))
        {
            // Load content of editable regions
            IssueHelper.LoadRegionsContents(ref regionsContents, issue.IssueText);
        }

        CMSEditableRegion editableRegion = null;
        LiteralControl    before         = null;
        int    count     = 0;
        int    textStart = 0;
        string region    = null;

        string[] parts           = null;
        string   name            = null;
        int      width           = 0;
        int      height          = 0;
        string   toolbarLocation = "Out:CKEditorToolbar";
        string   toolbarSetName  = "Newsletter";

        int editRegStart = templateText.IndexOfCSafe("$$", textStart);
        int editRegEnd   = 0;

        // Apply CSS e-mail template style
        HTMLHelper.AddToHeader(Page, CSSHelper.GetCSSFileLink(EmailTemplateInfoProvider.GetStylesheetUrl(emailTemplate.TemplateName)));

        while (editRegStart >= 0)
        {
            count++;

            before = new LiteralControl();
            // Get template text surrounding editable regions - make links absolute
            before.Text = URLHelper.MakeLinksAbsolute(templateText.Substring(textStart, (editRegStart - textStart)));
            plcContent.Controls.Add(before);

            // End of region
            editRegStart += 2;
            textStart     = editRegStart;
            if (editRegStart < templateText.Length - 1)
            {
                editRegEnd = templateText.IndexOfCSafe("$$", editRegStart);
                if (editRegEnd >= 0)
                {
                    region = templateText.Substring(editRegStart, editRegEnd - editRegStart);
                    parts  = (region + ":" + ":").Split(':');

                    try
                    {
                        name = parts[0];
                        if (!string.IsNullOrEmpty(name.Trim()))
                        {
                            width  = ValidationHelper.GetInteger(parts[1], 0);
                            height = ValidationHelper.GetInteger(parts[2], 0);

                            editableRegion            = new CMSEditableRegion();
                            editableRegion.ID         = name;
                            editableRegion.RegionType = CMSEditableRegionTypeEnum.HtmlEditor;
                            editableRegion.ViewMode   = ViewModeEnum.Edit;

                            editableRegion.DialogHeight = height;
                            editableRegion.DialogWidth  = width;

                            editableRegion.WordWrap = false;
                            editableRegion.HtmlAreaToolbarLocation = toolbarLocation;
                            editableRegion.RegionTitle             = name;
                            editableRegion.UseStylesheet           = false;
                            editableRegion.HTMLEditorCssStylesheet = EmailTemplateInfoProvider.GetStylesheetUrl(emailTemplate.TemplateName);

                            if (!mReadOnly)
                            {
                                editableRegion.HtmlAreaToolbar = toolbarSetName;
                            }
                            else
                            {
                                editableRegion.HtmlAreaToolbar = "Disabled";
                            }

                            CMSHtmlEditor editor = editableRegion.HtmlEditor;
                            editor.AddExtraPlugin("CMSPlugins");
                            editor.AddExtraPlugin("autogrow");
                            editor.AutoGrowMinHeight            = height;
                            editor.LinkDialogConfig.UseFullURL  = true;
                            editor.QuickInsertConfig.UseFullURL = true;
                            editor.ResolverName = "NewsletterResolver";

                            DialogConfiguration dialogConfig = editor.MediaDialogConfig;
                            dialogConfig.UseFullURL         = true;
                            dialogConfig.MetaFileObjectID   = (issue != null) ? issue.IssueID : 0;
                            dialogConfig.MetaFileObjectType = (issue != null) && issue.IssueIsVariant ? NewsletterObjectType.NEWSLETTERISSUEVARIANT : NewsletterObjectType.NEWSLETTERISSUE;
                            dialogConfig.MetaFileCategory   = MetaFileInfoProvider.OBJECT_CATEGORY_ISSUE;
                            dialogConfig.HideAttachments    = false;

                            editableRegion.LoadContent(ValidationHelper.GetString(regionsContents[name.ToLowerCSafe()], string.Empty));

                            plcContent.Controls.Add(editableRegion);

                            textStart = editRegEnd + 2;
                        }
                    }
                    catch
                    {
                    }
                }
            }
            editRegStart = templateText.IndexOfCSafe("$$", textStart);
        }

        before      = new LiteralControl();
        before.Text = URLHelper.MakeLinksAbsolute(templateText.Substring(textStart));

        plcContent.Controls.Add(before);
    }
    /// <summary>
    /// Loads content from specific newsletter template.
    /// </summary>
    private void LoadContent()
    {
        EmailTemplateInfo emailTemplate = EmailTemplateInfoProvider.GetEmailTemplateInfo(mTemplateID);
        if ((emailTemplate == null) || string.IsNullOrEmpty(emailTemplate.TemplateBody))
        {
            return;
        }

        // Remove security parameters from macros
        string templateText = MacroResolver.RemoveSecurityParameters(emailTemplate.TemplateBody, true, null);

        if (!RequestHelper.IsPostBack() && (issue != null))
        {
            // Load content of editable regions
            IssueHelper.LoadRegionsContents(ref regionsContents, issue.IssueText);
        }

        CMSEditableRegion editableRegion = null;
        LiteralControl before = null;
        int count = 0;
        int textStart = 0;
        string region = null;
        string[] parts = null;
        string name = null;
        int width = 0;
        int height = 0;
        string toolbarLocation = "Out:CKEditorToolbar";
        string toolbarSetName = "Newsletter";

        int editRegStart = templateText.IndexOfCSafe("$$", textStart);
        int editRegEnd = 0;

        // Apply CSS e-mail template style
        HTMLHelper.AddToHeader(Page, CSSHelper.GetCSSFileLink(EmailTemplateInfoProvider.GetStylesheetUrl(emailTemplate.TemplateName)));

        while (editRegStart >= 0)
        {
            count++;

            before = new LiteralControl();
            // Get template text surrounding editable regions - make links absolute
            before.Text = URLHelper.MakeLinksAbsolute(templateText.Substring(textStart, (editRegStart - textStart)));
            plcContent.Controls.Add(before);

            // End of region
            editRegStart += 2;
            textStart = editRegStart;
            if (editRegStart < templateText.Length - 1)
            {
                editRegEnd = templateText.IndexOfCSafe("$$", editRegStart);
                if (editRegEnd >= 0)
                {
                    region = templateText.Substring(editRegStart, editRegEnd - editRegStart);
                    parts = (region + ":" + ":").Split(':');

                    try
                    {
                        name = parts[0];
                        if (!string.IsNullOrEmpty(name.Trim()))
                        {
                            width = ValidationHelper.GetInteger(parts[1], 0);
                            height = ValidationHelper.GetInteger(parts[2], 0);

                            editableRegion = new CMSEditableRegion();
                            editableRegion.ID = name;
                            editableRegion.RegionType = CMSEditableRegionTypeEnum.HtmlEditor;
                            editableRegion.ViewMode = ViewModeEnum.Edit;

                            editableRegion.DialogHeight = height;
                            editableRegion.DialogWidth = width;

                            editableRegion.WordWrap = false;
                            editableRegion.HtmlAreaToolbarLocation = toolbarLocation;
                            editableRegion.RegionTitle = name;
                            editableRegion.UseStylesheet = false;
                            editableRegion.HTMLEditorCssStylesheet = EmailTemplateInfoProvider.GetStylesheetUrl(emailTemplate.TemplateName);

                            if (!mReadOnly)
                            {
                                editableRegion.HtmlAreaToolbar = toolbarSetName;
                            }
                            else
                            {
                                editableRegion.HtmlAreaToolbar = "Disabled";
                            }

                            CMSHtmlEditor editor = editableRegion.HtmlEditor;
                            editor.AddExtraPlugin("CMSPlugins");
                            editor.AddExtraPlugin("autogrow");
                            editor.AutoGrowMinHeight = height;
                            editor.LinkDialogConfig.UseFullURL = true;
                            editor.QuickInsertConfig.UseFullURL = true;
                            editor.ResolverName = "NewsletterResolver";

                            DialogConfiguration dialogConfig = editor.MediaDialogConfig;
                            dialogConfig.UseFullURL = true;
                            dialogConfig.MetaFileObjectID = (issue != null) ? issue.IssueID : 0;
                            dialogConfig.MetaFileObjectType = (issue != null) && issue.IssueIsVariant ? NewsletterObjectType.NEWSLETTERISSUEVARIANT : NewsletterObjectType.NEWSLETTERISSUE;
                            dialogConfig.MetaFileCategory = MetaFileInfoProvider.OBJECT_CATEGORY_ISSUE;
                            dialogConfig.HideAttachments = false;

                            editableRegion.LoadContent(ValidationHelper.GetString(regionsContents[name.ToLowerCSafe()], string.Empty));

                            plcContent.Controls.Add(editableRegion);

                            textStart = editRegEnd + 2;
                        }
                    }
                    catch
                    {
                    }
                }
            }
            editRegStart = templateText.IndexOfCSafe("$$", textStart);
        }

        before = new LiteralControl();
        before.Text = URLHelper.MakeLinksAbsolute(templateText.Substring(textStart));

        plcContent.Controls.Add(before);
    }
예제 #3
0
    /// <summary>
    /// Loads content from specific newsletter template.
    /// </summary>
    private void LoadContent()
    {
        EmailTemplate emailTemplate = EmailTemplateProvider.GetEmailTemplate(templateId);

        if ((emailTemplate == null) || string.IsNullOrEmpty(emailTemplate.TemplateBody))
        {
            return;
        }

        // Remove security parameters from macros
        string templateText = MacroResolver.RemoveSecurityParameters(emailTemplate.TemplateBody, true, null);

        if (!RequestHelper.IsPostBack() && (issue != null))
        {
            // Load content of editable regions
            IssueHelper.LoadRegionsContents(ref regionsContents, issue.IssueText);
        }

        CMSEditableRegion editableRegion = null;
        LiteralControl    before         = null;
        int count        = 0;
        int textStart    = 0;
        int editRegStart = templateText.IndexOf("$$", textStart);

        // Apply CSS e-mail template style
        HTMLHelper.AddToHeader(this.Page, CSSHelper.GetCSSFileLink(EmailTemplateProvider.GetStylesheetUrl(emailTemplate.TemplateName)));

        while (editRegStart >= 0)
        {
            count++;

            before = new LiteralControl();
            // Get template text surrounding editable regions - make links absolute
            before.Text = URLHelper.MakeLinksAbsolute(templateText.Substring(textStart, (editRegStart - textStart)));
            plcContent.Controls.Add(before);

            // End of region
            editRegStart += 2;
            textStart     = editRegStart;
            if (editRegStart < templateText.Length - 1)
            {
                int editRegEnd = templateText.IndexOf("$$", editRegStart);
                if (editRegEnd >= 0)
                {
                    string   region = templateText.Substring(editRegStart, editRegEnd - editRegStart);
                    string[] parts  = (region + ":" + ":").Split(':');

                    try
                    {
                        string name = parts[0];
                        if (!string.IsNullOrEmpty(name.Trim()))
                        {
                            int width  = ValidationHelper.GetInteger(parts[1], 0);
                            int height = ValidationHelper.GetInteger(parts[2], 0);

                            editableRegion            = new CMSEditableRegion();
                            editableRegion.ID         = name;
                            editableRegion.RegionType = CMSEditableRegionTypeEnum.HtmlEditor;
                            editableRegion.ViewMode   = ViewModeEnum.Edit;

                            editableRegion.DialogHeight = height;
                            editableRegion.DialogWidth  = width;

                            editableRegion.WordWrap = false;
                            editableRegion.HtmlAreaToolbarLocation = "Out:CKEditorToolbar";
                            editableRegion.RegionTitle             = name;
                            editableRegion.UseStylesheet           = false;
                            editableRegion.HTMLEditorCssStylesheet = EmailTemplateProvider.GetStylesheetUrl(emailTemplate.TemplateName);
                            editableRegion.HtmlAreaToolbar         = "Newsletter";
                            editableRegion.HtmlEditor.MediaDialogConfig.UseFullURL = true;
                            editableRegion.HtmlEditor.LinkDialogConfig.UseFullURL  = true;
                            editableRegion.HtmlEditor.QuickInsertConfig.UseFullURL = true;

                            editableRegion.LoadContent(ValidationHelper.GetString(regionsContents[name.ToLower()], ""));

                            plcContent.Controls.Add(editableRegion);

                            textStart = editRegEnd + 2;
                        }
                    }
                    catch
                    {
                    }
                }
            }
            editRegStart = templateText.IndexOf("$$", textStart);
        }

        before      = new LiteralControl();
        before.Text = URLHelper.MakeLinksAbsolute(templateText.Substring(textStart));

        plcContent.Controls.Add(before);
    }
    /// <summary>
    /// Loads content from specific newsletter template.
    /// </summary>
    private void LoadContent()
    {
        EmailTemplate emailTemplate = EmailTemplateProvider.GetEmailTemplate(templateId);
        if ((emailTemplate == null) || string.IsNullOrEmpty(emailTemplate.TemplateBody))
        {
            return;
        }

        // Remove security parameters from macros
        string templateText = MacroResolver.RemoveSecurityParameters(emailTemplate.TemplateBody, true, null);

        if (!RequestHelper.IsPostBack() && (issue != null))
        {
            // Load content of editable regions
            IssueHelper.LoadRegionsContents(ref regionsContents, issue.IssueText);
        }

        CMSEditableRegion editableRegion = null;
        LiteralControl before = null;
        int count = 0;
        int textStart = 0;
        int editRegStart = templateText.IndexOf("$$", textStart);

        // Apply CSS e-mail template style
        HTMLHelper.AddToHeader(this.Page, CSSHelper.GetCSSFileLink(EmailTemplateProvider.GetStylesheetUrl(emailTemplate.TemplateName)));

        while (editRegStart >= 0)
        {
            count++;

            before = new LiteralControl();
            // Get template text surrounding editable regions - make links absolute
            before.Text = URLHelper.MakeLinksAbsolute(templateText.Substring(textStart, (editRegStart - textStart)));
            plcContent.Controls.Add(before);

            // End of region
            editRegStart += 2;
            textStart = editRegStart;
            if (editRegStart < templateText.Length - 1)
            {
                int editRegEnd = templateText.IndexOf("$$", editRegStart);
                if (editRegEnd >= 0)
                {
                    string region = templateText.Substring(editRegStart, editRegEnd - editRegStart);
                    string[] parts = (region + ":" + ":").Split(':');

                    try
                    {
                        string name = parts[0];
                        if (!string.IsNullOrEmpty(name.Trim()))
                        {
                            int width = ValidationHelper.GetInteger(parts[1], 0);
                            int height = ValidationHelper.GetInteger(parts[2], 0);

                            editableRegion = new CMSEditableRegion();
                            editableRegion.ID = name;
                            editableRegion.RegionType = CMSEditableRegionTypeEnum.HtmlEditor;
                            editableRegion.ViewMode = ViewModeEnum.Edit;

                            editableRegion.DialogHeight = height;
                            editableRegion.DialogWidth = width;

                            editableRegion.WordWrap = false;
                            editableRegion.HtmlAreaToolbarLocation = "Out:CKEditorToolbar";
                            editableRegion.RegionTitle = name;
                            editableRegion.UseStylesheet = false;
                            editableRegion.HTMLEditorCssStylesheet = EmailTemplateProvider.GetStylesheetUrl(emailTemplate.TemplateName);
                            editableRegion.HtmlAreaToolbar = "Newsletter";
                            editableRegion.HtmlEditor.MediaDialogConfig.UseFullURL = true;
                            editableRegion.HtmlEditor.LinkDialogConfig.UseFullURL = true;
                            editableRegion.HtmlEditor.QuickInsertConfig.UseFullURL = true;

                            editableRegion.LoadContent(ValidationHelper.GetString(regionsContents[name.ToLower()], ""));

                            plcContent.Controls.Add(editableRegion);

                            textStart = editRegEnd + 2;
                        }
                    }
                    catch
                    {
                    }
                }
            }
            editRegStart = templateText.IndexOf("$$", textStart);
        }

        before = new LiteralControl();
        before.Text = URLHelper.MakeLinksAbsolute(templateText.Substring(textStart));

        plcContent.Controls.Add(before);
    }
    /// <summary>
    /// Loads content from specific newsletter template.
    /// </summary>
    private void LoadContent()
    {
        var urlHelper = new URLHelper();

        EmailTemplateInfo emailTemplate = EmailTemplateInfoProvider.GetEmailTemplateInfo(mTemplateID);

        if ((emailTemplate == null) || string.IsNullOrEmpty(emailTemplate.TemplateBody))
        {
            return;
        }

        // Remove security parameters from macros
        string templateText = MacroSecurityProcessor.RemoveSecurityParameters(emailTemplate.TemplateBody, true, null);

        if (!RequestHelper.IsPostBack() && (issue != null))
        {
            // Load content of editable regions
            IssueHelper.LoadRegionsContents(ref regionsContents, issue.IssueText);
        }

        LiteralControl before;
        int            count           = 0;
        int            textStart       = 0;
        string         toolbarLocation = "Out:CKToolbar";
        string         toolbarSetName  = "Newsletter";

        int editRegStart = templateText.IndexOfCSafe("$$", textStart);

        // Apply CSS e-mail template style
        Page.AddToHeader(CssLinkHelper.GetCssFileLink(EmailTemplateInfoProvider.GetStylesheetUrl(emailTemplate.TemplateName)));

        string domainName = SiteContext.CurrentSite.SiteIsContentOnly ? SiteContext.CurrentSite.SitePresentationURL : SiteContext.CurrentSite.DomainName;

        while (editRegStart >= 0)
        {
            count++;
            before = new LiteralControl();
            // Get template text surrounding editable regions - make links absolute
            before.Text = urlHelper.MakeLinksAbsolute(templateText.Substring(textStart, (editRegStart - textStart)), domainName);
            plcContent.Controls.Add(before);

            // End of region
            editRegStart += 2;
            textStart     = editRegStart;
            if (editRegStart < templateText.Length - 1)
            {
                int editRegEnd = templateText.IndexOfCSafe("$$", editRegStart);
                if (editRegEnd >= 0)
                {
                    string   region = templateText.Substring(editRegStart, editRegEnd - editRegStart);
                    string[] parts  = (region + ":" + ":").Split(':');

                    try
                    {
                        string name = parts[0];
                        if (!string.IsNullOrEmpty(name.Trim()))
                        {
                            Regex intNumber = RegexHelper.GetRegex("^[0-9]+");
                            int   width     = ValidationHelper.GetInteger(intNumber.Match(parts[1]).Value, 0);
                            int   height    = ValidationHelper.GetInteger(intNumber.Match(parts[2]).Value, 0);

                            CMSEditableRegion editableRegion = new CMSEditableRegion();
                            editableRegion.ID         = name;
                            editableRegion.RegionType = CMSEditableRegionTypeEnum.HtmlEditor;
                            editableRegion.ViewMode   = ViewModeEnum.Edit;

                            editableRegion.DialogHeight = height;
                            editableRegion.DialogWidth  = width;

                            editableRegion.WordWrap = false;
                            editableRegion.HtmlAreaToolbarLocation = toolbarLocation;
                            editableRegion.RegionTitle             = name;
                            editableRegion.UseStylesheet           = false;
                            editableRegion.HTMLEditorCssStylesheet = EmailTemplateInfoProvider.GetStylesheetUrl(emailTemplate.TemplateName);

                            if (!mReadOnly)
                            {
                                editableRegion.HtmlAreaToolbar = toolbarSetName;
                            }
                            else
                            {
                                editableRegion.HtmlAreaToolbar = "Disabled";
                            }

                            CMSHtmlEditor editor = editableRegion.HtmlEditor;
                            editor.ExtraPlugins.Add("autogrow");
                            editor.AutoGrowMinHeight = height;
                            editor.ResolverName      = "NewsletterResolver";

                            DialogConfiguration dialogConfig = editor.MediaDialogConfig;
                            dialogConfig.MetaFileObjectID   = (issue != null) ? issue.IssueID : 0;
                            dialogConfig.MetaFileObjectType = (issue != null) && issue.IssueIsVariant ? IssueInfo.OBJECT_TYPE_VARIANT : IssueInfo.OBJECT_TYPE;
                            dialogConfig.MetaFileCategory   = ObjectAttachmentsCategories.ISSUE;
                            dialogConfig.HideAttachments    = false;

                            editableRegion.LoadContent(ValidationHelper.GetString(regionsContents[name.ToLowerCSafe()], string.Empty));

                            plcContent.Controls.Add(editableRegion);

                            textStart = editRegEnd + 2;
                        }
                    }
                    catch
                    {
                    }
                }
            }
            editRegStart = templateText.IndexOfCSafe("$$", textStart);
        }

        before      = new LiteralControl();
        before.Text = urlHelper.MakeLinksAbsolute(templateText.Substring(textStart), domainName);

        plcContent.Controls.Add(before);
    }