protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        txtVariantName.MaxLength = VARIANT_NAME_SIZE;

        gridVariants.OrderBy              = "IssueVariantName, IssueID";
        gridVariants.WhereCondition       = new WhereCondition().WhereEquals("IssueVariantOfIssueID", ParentIssueId).ToString(true);
        gridVariants.OnAction            += GridVariants_OnAction;
        gridVariants.OnExternalDataBound += GridVariants_OnExternalDataBound;

        ucTitle.TitleText            = GetString("newslettervariant.addvariant");
        btnCloseDialog.OnClientClick = $@"
            hideModalPopup('{variantDialog.ClientID}', '{variantDialog.ClientID}_background');
            return false;";

        if (Enabled && NewsletterHelper.IsABTestingAvailable())
        {
            gridVariants.ZeroRowsText = GetString("emailbuilder.variantlist.novariants");

            if (IsTrackingEnabled())
            {
                btnSaveDialog.Click += btnSaveDialog_Click;

                btnNewVariant.OnClientClick = $@"
                $cmsj('#{errorMessage.ClientID}').hide();
                var $txtVariantName = $cmsj('#{txtVariantName.ClientID}');
                $txtVariantName.val('');

                showModalPopup('{variantDialog.ClientID}', '{variantDialog.ClientID}_background');
                $txtVariantName.focus();
                return false;";
            }
            else
            {
                btnNewVariant.Enabled = false;
                btnNewVariant.ToolTip = GetString("emailbuilder.abtest.trackingdisabled");
            }
        }
        else
        {
            errorMessage.Text     = GetString("emailbuilder.generalerror");
            btnNewVariant.Enabled = false;
            btnSaveDialog.Enabled = false;
        }
    }
Exemple #2
0
    private void InitAbTestingTab()
    {
        if (issueInfo.IssueIsABTest && (issueInfo.IssueVariantOfIssueID <= 0))
        {
            // Parent issue of A/B tests cannot be modified in Email builder => redirect to the original variant
            string originalVariantUrl = EmailBuilderHelper.GetOriginalVariantIssueUrl(issueInfo);
            URLHelper.Redirect(originalVariantUrl);
        }

        if (!NewsletterHelper.IsABTestingAvailable())
        {
            lnkAbTesting.Visible    = false;
            plcAbTestingTab.Visible = false;
        }

        // Initialize A/B testing control
        abVariants.Issue   = issueInfo;
        abVariants.Enabled = EditEnabled;
    }
Exemple #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        mNewsletter = EditedObject as NewsletterInfo;

        if (mNewsletter == null)
        {
            RedirectToAccessDenied(GetString("general.invalidparameters"));
        }

        if (!mNewsletter.CheckPermissions(PermissionsEnum.Read, CurrentSiteName, CurrentUser))
        {
            RedirectToAccessDenied(mNewsletter.TypeInfo.ModuleName, "Read");
        }

        mBounceMonitoringEnabled = NewsletterHelper.MonitorBouncedEmails(CurrentSiteName);
        mOnlineMarketingEnabled  = NewsletterHelper.OnlineMarketingAvailable(CurrentSiteName);
        mTrackingEnabled         = NewsletterHelper.IsTrackingAvailable();
        mABTestEnabled           = NewsletterHelper.IsABTestingAvailable();

        ScriptHelper.RegisterDialogScript(this);

        string scriptBlock = string.Format(@"
            function RefreshPage() {{ document.location.replace(document.location); }}
            function NewItem(id) {{ modalDialog('{0}?parentobjectid=' + id, 'NewsletterNewIssue', screen.availWidth - 10, screen.availHeight - 80); }}
            function ShowOpenedBy(id) {{ modalDialog('{1}?objectid=' + id, 'NewsletterIssueOpenedBy', '900px', '700px');  return false; }}
            function ViewClickedLinks(id) {{ modalDialog('{2}?objectid=' + id, 'NewsletterTrackedLinks', '900px', '700px'); return false; }}",
                                           ResolveUrl(@"~\CMSModules\Newsletters\Tools\Newsletters\Newsletter_Issue_New.aspx"),
                                           ResolveUrl(@"~\CMSModules\Newsletters\Tools\Newsletters\Newsletter_Issue_OpenedBy.aspx"),
                                           ResolveUrl(@"~\CMSModules\Newsletters\Tools\Newsletters\Newsletter_Issue_TrackedLinks.aspx"));

        ScriptHelper.RegisterClientScriptBlock(this, GetType(), "Actions", scriptBlock, true);

        // Initialize unigrid
        UniGrid.WhereCondition       = String.Format("IssueNewsletterID={0} AND IssueVariantOfIssueID IS NULL", mNewsletter.NewsletterID);
        UniGrid.ZeroRowsText         = GetString("Newsletter_Issue_List.NoIssuesFound");
        UniGrid.OnAction            += uniGrid_OnAction;
        UniGrid.OnBeforeDataReload  += UniGrid_OnBeforeDataReload;
        UniGrid.OnExternalDataBound += UniGrid_OnExternalDataBound;

        // Initialize header actions
        InitHeaderActions();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        newsletterId = QueryHelper.GetInteger("newsletterid", 0);
        if (newsletterId == 0)
        {
            RequestHelper.EndResponse();
        }

        // Get newsletter object and check its existence
        mNewsletter  = NewsletterInfoProvider.GetNewsletterInfo(newsletterId);
        EditedObject = mNewsletter;

        string siteName = CMSContext.CurrentSiteName;

        mBounceMonitoringEnabled = NewsletterHelper.MonitorBouncedEmails(siteName);
        mOnlineMarketingEnabled  = NewsletterHelper.OnlineMarketingAvailable(siteName);
        mTrackingEnabled         = NewsletterHelper.IsTrackingAvailable();
        mABTestEnabled           = NewsletterHelper.IsABTestingAvailable();

        ScriptHelper.RegisterDialogScript(this);

        string scriptBlock = string.Format(@"
            function RefreshPage() {{ document.location.replace(document.location); }}
            function NewItem(id) {{ modalDialog('{0}?newsletterid=' + id, 'NewsletterNewIssue', screen.availWidth - 10, screen.availHeight - 80); }}
            function ShowOpenedBy(id) {{ modalDialog('{1}?issueid=' + id, 'NewsletterIssueOpenedBy', '900px', '700px');  return false; }}
            function ViewClickedLinks(id) {{ modalDialog('{2}?issueid=' + id, 'NewsletterTrackedLinks', '900px', '700px'); return false; }}",
                                           ResolveUrl(@"~\CMSModules\Newsletters\Tools\Newsletters\Newsletter_Issue_New.aspx"),
                                           ResolveUrl(@"~\CMSModules\Newsletters\Tools\Newsletters\Newsletter_Issue_OpenedBy.aspx"),
                                           ResolveUrl(@"~\CMSModules\Newsletters\Tools\Newsletters\Newsletter_Issue_TrackedLinks.aspx"));

        ScriptHelper.RegisterClientScriptBlock(this, GetType(), "Actions", scriptBlock, true);

        // Initialize unigrid
        UniGrid.WhereCondition       = String.Format("IssueNewsletterID={0} AND IssueVariantOfIssueID IS NULL", newsletterId);
        UniGrid.ZeroRowsText         = GetString("Newsletter_Issue_List.NoIssuesFound");
        UniGrid.OnAction            += uniGrid_OnAction;
        UniGrid.OnBeforeDataReload  += UniGrid_OnBeforeDataReload;
        UniGrid.OnExternalDataBound += UniGrid_OnExternalDataBound;

        // Initialize header actions
        InitHeaderActions();
    }
Exemple #5
0
    /// <summary>
    /// Initializes the variants drop-down list or hides it if the issue has no variants.
    /// </summary>
    private void InitVariantDropDownList()
    {
        if (!NewsletterHelper.IsABTestingAvailable())
        {
            return;
        }

        var variants = IssueHelper.GetIssueVariants(Issue)
                       .Select(v => new ListItem(v.IssueVariantName, v.IssueID.ToString())).ToList();

        if (variants.Any())
        {
            foreach (var variant in variants)
            {
                drpVariantsSelector.Items.Add(variant);
            }

            drpVariantsSelector.SelectedValue = Issue.IssueID.ToString();
            pnlTabs.AddCssClass("with-variants");
            plcVariantSelection.Visible = true;
        }
    }
    /// <summary>
    /// Initializes header action control.
    /// </summary>
    /// <param name="issueId">Issue ID</param>
    private void InitHeaderActions(int issueId)
    {
        // Show info message and get current issue state
        bool editingEnabled;
        bool variantSliderEnabled;

        UpdateDialog(issueId, out editingEnabled, out variantSliderEnabled);
        editElem.Enabled = editingEnabled;

        bool isIssueVariant = ucVariantSlider.Variants.Count > 0;

        ucVariantSlider.Visible        = isIssueVariant;
        ucVariantSlider.EditingEnabled = editingEnabled && variantSliderEnabled;

        ScriptHelper.RegisterDialogScript(Page);

        CurrentMaster.HeaderActions.ActionsList.Clear();

        // Init save button
        CurrentMaster.HeaderActions.ActionsList.Add(new SaveAction
        {
            OnClientClick = "if (GetContent != null) {return GetContent();} else {return false;}",
            Enabled       = editingEnabled
        });

        // Ensure spell check action
        if (editingEnabled)
        {
            CurrentMaster.HeaderActions.ActionsList.Add(new HeaderAction
            {
                Text          = GetString("EditMenu.IconSpellCheck"),
                Tooltip       = GetString("EditMenu.SpellCheck"),
                OnClientClick = "var frame = GetFrame(); if ((frame != null) && (frame.contentWindow.SpellCheck_" + ClientID + " != null)) {frame.contentWindow.SpellCheck_" + ClientID + "();} return false;",
                ButtonStyle   = ButtonStyle.Default,
            });
        }

        // Init send draft button
        CurrentMaster.HeaderActions.ActionsList.Add(new HeaderAction
        {
            Text          = GetString("newsletterissue_content.senddraft"),
            Tooltip       = GetString("newsletterissue_content.senddraft"),
            OnClientClick = string.Format(@"if (modalDialog) {{modalDialog('{0}?objectid={1}', 'SendDraft', '700', '300');}}", ResolveUrl(@"~/CMSModules/Newsletters/Tools/Newsletters/Newsletter_Issue_SendDraft.aspx"), issueId) + " return false;",
            Enabled       = true,
            ButtonStyle   = ButtonStyle.Default,
        });

        // Init preview button
        CurrentMaster.HeaderActions.ActionsList.Add(new HeaderAction
        {
            Text          = GetString("general.preview"),
            Tooltip       = GetString("general.preview"),
            OnClientClick = string.Format(@"if (modalDialog) {{modalDialog('{0}?objectid={1}', 'Preview', '90%', '90%');}}", ResolveUrl(@"~/CMSModules/Newsletters/Tools/Newsletters/Newsletter_Issue_Preview.aspx"), issueId) + " return false;",
            ButtonStyle   = ButtonStyle.Default,
        });

        int attachCount = 0;
        // Get number of attachments
        InfoDataSet <MetaFileInfo> ds = MetaFileInfoProvider.GetMetaFiles(issueId,
                                                                          (isIssueVariant ? IssueInfo.OBJECT_TYPE_VARIANT : IssueInfo.OBJECT_TYPE), ObjectAttachmentsCategories.ISSUE, null, null, "MetafileID", -1);

        attachCount = ds.Items.Count;

        // Register attachments count update module
        ScriptHelper.RegisterModule(this, "CMS/AttachmentsCountUpdater", new { Selector = "." + mAttachmentsActionClass, Text = ResHelper.GetString("general.attachments") });


        // Prepare metafile dialog URL
        string metaFileDialogUrl = ResolveUrl(@"~/CMSModules/AdminControls/Controls/MetaFiles/MetaFileDialog.aspx");
        string query             = string.Format("?objectid={0}&objecttype={1}", issueId, (isIssueVariant? IssueInfo.OBJECT_TYPE_VARIANT : IssueInfo.OBJECT_TYPE));

        metaFileDialogUrl += string.Format("{0}&category={1}&hash={2}", query, ObjectAttachmentsCategories.ISSUE, QueryHelper.GetHash(query));

        // Init attachment button
        CurrentMaster.HeaderActions.ActionsList.Add(new HeaderAction
        {
            Text          = GetString("general.attachments") + ((attachCount > 0) ? " (" + attachCount + ")" : string.Empty),
            Tooltip       = GetString("general.attachments"),
            OnClientClick = string.Format(@"if (modalDialog) {{modalDialog('{0}', 'Attachments', '700', '500');}}", metaFileDialogUrl) + " return false;",
            Enabled       = true,
            CssClass      = mAttachmentsActionClass,
            ButtonStyle   = ButtonStyle.Default,
        });

        // Init create A/B test button - online marketing, open email and click through tracking are required
        if (!isIssueVariant)
        {
            IssueInfo issue = (IssueInfo)EditedObject;
            if (editingEnabled && (issue.IssueStatus == IssueStatusEnum.Idle) && NewsletterHelper.IsABTestingAvailable())
            {
                // Check that trackings are enabled
                bool trackingsEnabled = (newsletter != null) && newsletter.NewsletterTrackOpenEmails && newsletter.NewsletterTrackClickedLinks;

                CurrentMaster.HeaderActions.ActionsList.Add(new HeaderAction
                {
                    Text          = GetString("newsletterissue_content.createabtest"),
                    Tooltip       = trackingsEnabled ? GetString("newsletterissue_content.createabtest") : GetString("newsletterissue_content.abtesttooltip"),
                    OnClientClick = trackingsEnabled ? "ShowVariantDialog_" + ucVariantDialog.ClientID + "('addvariant', ''); return false;" : "return false;",
                    Enabled       = trackingsEnabled,
                    ButtonStyle   = ButtonStyle.Default,
                });
                ucVariantDialog.IssueID       = issueId;
                ucVariantDialog.OnAddVariant += ucVariantSlider_OnVariantAdded;
            }
        }

        // Init masterpage
        CurrentMaster.HeaderActions.ActionPerformed += HeaderActions_ActionPerformed;
        CurrentMaster.DisplayControlsPanel           = isIssueVariant;
        CurrentMaster.PanelContent.Attributes.Add("onmouseout", "if (RememberFocusedRegion) {RememberFocusedRegion();}");
    }
    /// <summary>
    /// Initializes header action control.
    /// </summary>
    private void InitHeaderActions()
    {
        bool isNew          = (IssueId == 0);
        bool isIssueVariant = !isNew && IssueInfoProvider.IsABTestIssue(IssueId);

        hdrActions.ActionsList.Clear();

        // Init save button
        hdrActions.ActionsList.Add(new SaveAction(this)
        {
            OnClientClick = "if (GetContent != null) {return GetContent();} else {return false;}"
        });

        // Ensure spell check action
        hdrActions.ActionsList.Add(new HeaderAction()
        {
            CssClass      = "MenuItemEdit",
            Text          = GetString("EditMenu.IconSpellCheck"),
            Tooltip       = GetString("EditMenu.SpellCheck"),
            OnClientClick = "var frame = GetFrame(); if ((frame != null) && (frame.contentWindow.SpellCheck_" + ClientID + " != null)) {frame.contentWindow.SpellCheck_" + ClientID + "();} return false;",
            ImageUrl      = GetImageUrl("CMSModules/CMS_Content/EditMenu/spellcheck.png"),
            SmallImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/16/spellcheck.png"),
        });

        // Init send draft button
        hdrActions.ActionsList.Add(new HeaderAction()
        {
            ControlType   = HeaderActionTypeEnum.LinkButton,
            Text          = GetString("newsletterissue_content.senddraft"),
            Tooltip       = GetString("newsletterissue_content.senddraft"),
            OnClientClick = (isNew) ? "return false;" : string.Format(@"if (modalDialog) {{modalDialog('{0}?issueid={1}', 'SendDraft', '500', '300');}}", ResolveUrl(@"~/CMSModules/Newsletters/Tools/Newsletters/Newsletter_Issue_SendDraft.aspx"), IssueId) + " return false;",
            ImageUrl      = (isNew) ? GetImageUrl("CMSModules/CMS_Newsletter/senddraft_disabled.png") : GetImageUrl("CMSModules/CMS_Newsletter/senddraft.png"),
            Enabled       = !isNew
        });

        // Init preview button
        hdrActions.ActionsList.Add(new HeaderAction()
        {
            ControlType   = HeaderActionTypeEnum.Hyperlink,
            Text          = GetString("general.preview"),
            Tooltip       = GetString("general.preview"),
            OnClientClick = (isNew) ? "return false;" : string.Format(@"if (modalDialog) {{modalDialog('{0}?issueid={1}', 'Preview', '90%', '90%');}}", ResolveUrl(@"~/CMSModules/Newsletters/Tools/Newsletters/Newsletter_Issue_Preview.aspx"), IssueId) + " return false;",
            ImageUrl      = (isNew) ? GetImageUrl("CMSModules/CMS_Newsletter/preview_disabled.png") : GetImageUrl("CMSModules/CMS_Newsletter/preview.png"),
            Enabled       = !isNew
        });

        int    attachCount       = 0;
        string metaFileDialogUrl = null;

        if (!isNew)
        {
            ScriptHelper.RegisterDialogScript(Page);

            // Get number of attachments
            InfoDataSet <MetaFileInfo> ds = MetaFileInfoProvider.GetMetaFiles(IssueId,
                                                                              (isIssueVariant ? NewsletterObjectType.NEWSLETTERISSUEVARIANT : NewsletterObjectType.NEWSLETTERISSUE),
                                                                              MetaFileInfoProvider.OBJECT_CATEGORY_ISSUE, null, null, "MetafileID", -1);
            attachCount = ds.Items.Count;

            string script = @"function UpdateAttachmentCount(count) {
                                var counter = document.getElementById('attachmentCount');
                                if (counter != null) {
                                    if (count > 0) { counter.innerHTML = ' (' + count + ')'; }
                                    else { counter.innerHTML = ''; }
                                }
                            }";
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "UpdateAttachmentScript_" + this.ClientID, script, true);

            // Prepare metafile dialog URL
            metaFileDialogUrl = ResolveUrl(@"~/CMSModules/AdminControls/Controls/MetaFiles/MetaFileDialog.aspx");
            string query = string.Format("?objectid={0}&objecttype={1}", IssueId, (isIssueVariant ? NewsletterObjectType.NEWSLETTERISSUEVARIANT : NewsletterObjectType.NEWSLETTERISSUE));
            metaFileDialogUrl += string.Format("{0}&category={1}&hash={2}", query, MetaFileInfoProvider.OBJECT_CATEGORY_ISSUE, QueryHelper.GetHash(query));
        }

        // Init attachment button
        hdrActions.ActionsList.Add(new HeaderAction()
        {
            ControlType   = HeaderActionTypeEnum.LinkButton,
            Text          = GetString("general.attachments") + string.Format("<span id='attachmentCount'>{0}</span>", (attachCount > 0) ? " (" + attachCount.ToString() + ")" : string.Empty),
            Tooltip       = GetString("general.attachments"),
            OnClientClick = (isNew) ? "return false;" : string.Format(@"if (modalDialog) {{modalDialog('{0}', 'Attachments', '700', '500');}}", metaFileDialogUrl) + " return false;",
            ImageUrl      = (isNew) ? GetImageUrl("Objects/CMS_MetaFile/attachment_disabled.png") : GetImageUrl("Objects/CMS_MetaFile/attachment.png"),
            Enabled       = !isNew
        });

        // Init create A/B test button - online marketing, open email and click through tracking are required
        if (isNew || !isIssueVariant)
        {
            if (NewsletterHelper.IsABTestingAvailable())
            {
                // Check that trackings are enabled
                NewsletterInfo news             = NewsletterInfoProvider.GetNewsletterInfo(newsletterId);
                bool           trackingsEnabled = (news != null) && news.NewsletterTrackOpenEmails && news.NewsletterTrackClickedLinks;

                hdrActions.ActionsList.Add(new HeaderAction()
                {
                    ControlType   = HeaderActionTypeEnum.LinkButton,
                    Text          = GetString("newsletterissue_content.createabtest"),
                    Tooltip       = trackingsEnabled ? GetString("newsletterissue_content.createabtest") : GetString("newsletterissue_content.abtesttooltip"),
                    OnClientClick = (isNew || !trackingsEnabled) ? "return false;" : "ShowVariantDialog_" + ucVariantDialog.ClientID + "('addvariant', ''); return false;",
                    ImageUrl      = (isNew || !trackingsEnabled) ? GetImageUrl("CMSModules/CMS_Newsletter/abtest_disabled.png") : GetImageUrl("CMSModules/CMS_Newsletter/abtest.png"),
                    Enabled       = !isNew && trackingsEnabled
                });
                ucVariantDialog.IssueID       = IssueId;
                ucVariantDialog.OnAddVariant += new EventHandler(ucVariantSlider_OnVariantAdded);
            }
        }

        hdrActions.ActionPerformed += HeaderActions_ActionPerformed;
        hdrActions.ReloadData();
        pnlActions.Attributes.Add("onmouseover", "if (RememberFocusedRegion) {RememberFocusedRegion();}");
    }
Exemple #8
0
    /// <summary>
    /// Initializes header action control.
    /// </summary>
    private void InitHeaderActions()
    {
        bool isNew          = (IssueId == 0);
        var  issue          = IssueInfoProvider.GetIssueInfo(IssueId);
        bool isIssueVariant = !isNew && (issue != null) && issue.IssueIsABTest;

        hdrActions.ActionsList.Clear();

        // Init save button
        hdrActions.ActionsList.Add(new SaveAction(this)
        {
            OnClientClick = "if (GetContent != null) {return GetContent();} else {return false;}"
        });

        // Ensure spell check action
        hdrActions.ActionsList.Add(new HeaderAction
        {
            Text          = GetString("EditMenu.IconSpellCheck"),
            Tooltip       = GetString("EditMenu.SpellCheck"),
            OnClientClick = "var frame = GetFrame(); if ((frame != null) && (frame.contentWindow.SpellCheck_" + ClientID + " != null)) {frame.contentWindow.SpellCheck_" + ClientID + "();} return false;"
        });

        // Init send draft button
        hdrActions.ActionsList.Add(new HeaderAction
        {
            Text          = GetString("newsletterissue_content.senddraft"),
            Tooltip       = (isNew) ? GetString("newsletterissue_new.issueunsaved") : GetString("newsletterissue_content.senddraft"),
            OnClientClick = (isNew) ? "return false;" : string.Format(@"if (modalDialog) {{modalDialog('{0}?objectid={1}', 'SendDraft', '700', '300');}}", ResolveUrl(@"~/CMSModules/Newsletters/Tools/Newsletters/Newsletter_Issue_SendDraft.aspx"), IssueId) + " return false;",
            Enabled       = !isNew
        });

        // Init preview button
        hdrActions.ActionsList.Add(new HeaderAction
        {
            Text          = GetString("general.preview"),
            Tooltip       = (isNew) ? GetString("newsletterissue_new.issueunsaved") : GetString("general.preview"),
            OnClientClick = (isNew) ? "return false;" : string.Format(@"if (modalDialog) {{modalDialog('{0}?objectid={1}', 'Preview', '90%', '90%');}}", ResolveUrl(@"~/CMSModules/Newsletters/Tools/Newsletters/Newsletter_Issue_Preview.aspx"), IssueId) + " return false;",
            Enabled       = !isNew
        });

        int    attachCount       = 0;
        string metaFileDialogUrl = null;

        if (!isNew)
        {
            ScriptHelper.RegisterDialogScript(Page);

            // Get number of attachments
            InfoDataSet <MetaFileInfo> ds = MetaFileInfoProvider.GetMetaFiles(IssueId,
                                                                              (isIssueVariant ? IssueInfo.OBJECT_TYPE_VARIANT : IssueInfo.OBJECT_TYPE),
                                                                              ObjectAttachmentsCategories.ISSUE, null, null, "MetafileID", -1);
            attachCount = ds.Items.Count;

            // Register attachments count update module
            ScriptHelper.RegisterModule(this, "CMS/AttachmentsCountUpdater", new { Selector = "." + mAttachmentsActionClass, Text = ResHelper.GetString("general.attachments") });

            // Prepare metafile dialog URL
            metaFileDialogUrl = ResolveUrl(@"~/CMSModules/AdminControls/Controls/MetaFiles/MetaFileDialog.aspx");
            string query = string.Format("?objectid={0}&objecttype={1}", IssueId, (isIssueVariant ? IssueInfo.OBJECT_TYPE_VARIANT : IssueInfo.OBJECT_TYPE));
            metaFileDialogUrl += string.Format("{0}&category={1}&hash={2}", query, ObjectAttachmentsCategories.ISSUE, QueryHelper.GetHash(query));
        }

        // Init attachment button
        hdrActions.ActionsList.Add(new HeaderAction
        {
            Text          = GetString("general.attachments") + ((attachCount > 0) ? " (" + attachCount + ")" : string.Empty),
            Tooltip       = (isNew) ? GetString("newsletterissue_new.issueunsaved") : GetString("general.attachments"),
            OnClientClick = (isNew) ? "return false;" : string.Format(@"if (modalDialog) {{modalDialog('{0}', 'Attachments', '700', '500');}}", metaFileDialogUrl) + " return false;",
            Enabled       = !isNew,
            CssClass      = mAttachmentsActionClass
        });

        // Init create A/B test button - online marketing, open email and click through tracking are required
        if (isNew || !isIssueVariant)
        {
            if (NewsletterHelper.IsABTestingAvailable())
            {
                // Check that trackings are enabled
                NewsletterInfo news             = NewsletterInfoProvider.GetNewsletterInfo(newsletterId);
                bool           trackingsEnabled = (news != null) && news.NewsletterTrackOpenEmails && news.NewsletterTrackClickedLinks;

                hdrActions.ActionsList.Add(new HeaderAction
                {
                    Text          = GetString("newsletterissue_content.createabtest"),
                    Tooltip       = (isNew) ? GetString("newsletterissue_new.issueunsaved") : (trackingsEnabled ? GetString("newsletterissue_content.createabtest") : GetString("newsletterissue_content.abtesttooltip")),
                    OnClientClick = (isNew || !trackingsEnabled) ? "return false;" : "ShowVariantDialog_" + ucVariantDialog.ClientID + "('addvariant', ''); return false;",
                    Enabled       = !isNew && trackingsEnabled
                });
                ucVariantDialog.IssueID       = IssueId;
                ucVariantDialog.OnAddVariant += ucVariantSlider_OnVariantAdded;
            }
        }

        hdrActions.ActionPerformed += HeaderActions_ActionPerformed;
        hdrActions.ReloadData();
        pnlActions.Attributes.Add("onmouseover", "if (RememberFocusedRegion) {RememberFocusedRegion();}");
    }
Exemple #9
0
    /// <summary>
    /// Initializes header action control.
    /// </summary>
    /// <param name="issueId">Issue ID</param>
    private void InitHeaderActions(int issueId)
    {
        // Show info message and get current issue state
        bool editingEnabled       = false;
        bool variantSliderEnabled = false;

        UpdateDialog(issueId, out editingEnabled, out variantSliderEnabled);
        editElem.Enabled = editingEnabled;

        bool   isAuthorized   = CurrentUser.IsAuthorizedPerResource("CMS.Newsletter", "AuthorIssues");
        bool   isIssueVariant = ucVariantSlider.Variants.Count > 0;
        string script         = null;

        ucVariantSlider.Visible        = isIssueVariant;
        ucVariantSlider.EditingEnabled = editingEnabled && variantSliderEnabled;

        ScriptHelper.RegisterDialogScript(Page);

        CurrentMaster.HeaderActions.ActionsList.Clear();

        // Init save button
        CurrentMaster.HeaderActions.ActionsList.Add(new SaveAction(this)
        {
            OnClientClick = "if (GetContent != null) {return GetContent();} else {return false;}",
            SmallImageUrl = isAuthorized && editingEnabled ? GetImageUrl("CMSModules/CMS_Content/EditMenu/16/save.png") : GetImageUrl("CMSModules/CMS_Content/EditMenu/16/savedisabled.png"),
            Enabled       = isAuthorized && editingEnabled
        });

        // Ensure spell check action
        if (isAuthorized && editingEnabled)
        {
            CurrentMaster.HeaderActions.ActionsList.Add(new HeaderAction()
            {
                CssClass      = "MenuItemEdit",
                Text          = GetString("EditMenu.IconSpellCheck"),
                Tooltip       = GetString("EditMenu.SpellCheck"),
                OnClientClick = "var frame = GetFrame(); if ((frame != null) && (frame.contentWindow.SpellCheck_" + ClientID + " != null)) {frame.contentWindow.SpellCheck_" + ClientID + "();} return false;",
                ImageUrl      = GetImageUrl("CMSModules/CMS_Content/EditMenu/spellcheck.png"),
                SmallImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/16/spellcheck.png"),
            });
        }

        // Init send draft button
        CurrentMaster.HeaderActions.ActionsList.Add(new HeaderAction()
        {
            ControlType   = HeaderActionTypeEnum.LinkButton,
            Text          = GetString("newsletterissue_content.senddraft"),
            Tooltip       = GetString("newsletterissue_content.senddraft"),
            OnClientClick = string.Format(@"if (modalDialog) {{modalDialog('{0}?issueid={1}', 'SendDraft', '500', '300');}}", ResolveUrl(@"~/CMSModules/Newsletters/Tools/Newsletters/Newsletter_Issue_SendDraft.aspx"), issueId) + " return false;",
            ImageUrl      = GetImageUrl("CMSModules/CMS_Newsletter/senddraft.png"),
            Enabled       = isAuthorized
        });

        // Init preview button
        CurrentMaster.HeaderActions.ActionsList.Add(new HeaderAction()
        {
            ControlType   = HeaderActionTypeEnum.Hyperlink,
            Text          = GetString("general.preview"),
            Tooltip       = GetString("general.preview"),
            OnClientClick = string.Format(@"if (modalDialog) {{modalDialog('{0}?issueid={1}', 'Preview', '90%', '90%');}}", ResolveUrl(@"~/CMSModules/Newsletters/Tools/Newsletters/Newsletter_Issue_Preview.aspx"), issueId) + " return false;",
            ImageUrl      = GetImageUrl("CMSModules/CMS_Newsletter/preview.png")
        });

        int attachCount = 0;

        if (isAuthorized)
        {
            // Get number of attachments
            InfoDataSet <MetaFileInfo> ds = MetaFileInfoProvider.GetMetaFiles(issueId,
                                                                              (isIssueVariant ? NewsletterObjectType.NEWSLETTERISSUEVARIANT : NewsletterObjectType.NEWSLETTERISSUE), MetaFileInfoProvider.OBJECT_CATEGORY_ISSUE, null, null, "MetafileID", -1);
            attachCount = ds.Items.Count;

            script = @"
function UpdateAttachmentCount(count) {
    var counter = document.getElementById('attachmentCount');
    if (counter != null) {
        if (count > 0) { counter.innerHTML = ' (' + count + ')'; }
        else { counter.innerHTML = ''; }
    }
}";
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "UpdateAttachmentScript_" + ClientID, script, true);
        }

        // Prepare metafile dialog URL
        string metaFileDialogUrl = ResolveUrl(@"~/CMSModules/AdminControls/Controls/MetaFiles/MetaFileDialog.aspx");
        string query             = string.Format("?objectid={0}&objecttype={1}", issueId, (isIssueVariant? NewsletterObjectType.NEWSLETTERISSUEVARIANT : NewsletterObjectType.NEWSLETTERISSUE));

        metaFileDialogUrl += string.Format("{0}&category={1}&hash={2}", query, MetaFileInfoProvider.OBJECT_CATEGORY_ISSUE, QueryHelper.GetHash(query));

        // Init attachment button
        CurrentMaster.HeaderActions.ActionsList.Add(new HeaderAction()
        {
            ControlType   = HeaderActionTypeEnum.LinkButton,
            Text          = GetString("general.attachments") + string.Format("<span id='attachmentCount'>{0}</span>", (attachCount > 0) ? " (" + attachCount.ToString() + ")" : string.Empty),
            Tooltip       = GetString("general.attachments"),
            OnClientClick = string.Format(@"if (modalDialog) {{modalDialog('{0}', 'Attachments', '700', '500');}}", metaFileDialogUrl) + " return false;",
            ImageUrl      = GetImageUrl("Objects/CMS_MetaFile/attachment.png"),
            Enabled       = isAuthorized
        });

        // Init create A/B test button - online marketing, open email and click through tracking are required
        if (!isIssueVariant)
        {
            IssueInfo issue = (IssueInfo)EditedObject;
            if (editingEnabled && (issue.IssueStatus == IssueStatusEnum.Idle) && NewsletterHelper.IsABTestingAvailable())
            {
                // Check that trackings are enabled
                bool trackingsEnabled = (newsletter != null) && newsletter.NewsletterTrackOpenEmails && newsletter.NewsletterTrackClickedLinks;

                CurrentMaster.HeaderActions.ActionsList.Add(new HeaderAction()
                {
                    ControlType   = HeaderActionTypeEnum.LinkButton,
                    Text          = GetString("newsletterissue_content.createabtest"),
                    Tooltip       = trackingsEnabled ? GetString("newsletterissue_content.createabtest") : GetString("newsletterissue_content.abtesttooltip"),
                    OnClientClick = isAuthorized && trackingsEnabled ? "ShowVariantDialog_" + ucVariantDialog.ClientID + "('addvariant', ''); return false;" : "return false;",
                    ImageUrl      = isAuthorized && trackingsEnabled ? GetImageUrl("CMSModules/CMS_Newsletter/abtest.png") : GetImageUrl("CMSModules/CMS_Newsletter/abtest_disabled.png"),
                    Enabled       = isAuthorized && trackingsEnabled
                });
                ucVariantDialog.IssueID       = issueId;
                ucVariantDialog.OnAddVariant += new EventHandler(ucVariantSlider_OnVariantAdded);
            }
        }

        // Init fullscreen button
        string imageOff = ResolveUrl(GetImageUrl("CMSModules/CMS_Newsletter/fullscreenoff.png"));
        string imageOn  = ResolveUrl(GetImageUrl("CMSModules/CMS_Newsletter/fullscreenon.png"));

        // Create fullscreen toogle function
        script = string.Format(@"
function ToogleFullScreen(elem) {{
 if (window.maximized) {{
     window.maximized = false;
     $j(elem).find('img').attr('src','{0}');
     MaximizeAll(top.window);
 }} else {{
     window.maximized = true;
     $j(elem).find('img').attr('src','{1}');
     MinimizeAll(top.window);
 }}
}}", imageOff, imageOn);

        // Register fullscreen toogle function and necessary scripts
        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "ToogleFullScreen_" + ClientID, script, true);
        ScriptHelper.RegisterResizer(this);
        ScriptHelper.RegisterJQuery(this);

        CurrentMaster.HeaderActions.ActionsList.Add(new HeaderAction()
        {
            ControlType   = HeaderActionTypeEnum.LinkButton,
            Text          = GetString("general.fullscreen"),
            OnClientClick = "ToogleFullScreen(this);return false;",
            ImageUrl      = GetImageUrl("CMSModules/CMS_Newsletter/fullscreenoff.png"),
            CssClass      = !isIssueVariant ? "MenuItemEdit Right" : "MenuItemEdit RightABVariant"
        });

        // Init masterpage
        CurrentMaster.HeaderActions.ActionPerformed += HeaderActions_ActionPerformed;
        CurrentMaster.DisplayControlsPanel           = isIssueVariant;
        CurrentMaster.PanelContent.Attributes.Add("onmouseout", "if (RememberFocusedRegion) {RememberFocusedRegion();}");
    }