private string GetUtmCampaignNameHtmlOutput() { CampaignInfo campaign = CampaignInfoProvider.GetCampaignByUTMCode(mIssue.IssueUTMCampaign, CurrentSiteName); // Is issue linked to an existing campaign if (campaign != null) { var campaignDetailUrl = Service.Resolve <IUILinkProvider>().GetSingleObjectLink(CampaignInfo.TYPEINFO.ModuleName, CAMPAIGN_ELEMENT_CODENAME, new ObjectDetailLinkParameters { ObjectIdentifier = campaign.CampaignID, AllowNavigationToListing = true }); var hyperLink = new HyperLink { NavigateUrl = URLHelper.GetAbsoluteUrl(campaignDetailUrl), Text = HTMLHelper.HTMLEncode(campaign.CampaignDisplayName), Target = "_top", }; return(hyperLink.GetRenderedHTML()); } return(mIssue.IssueUTMCampaign); }
/// <summary> /// Loads form data. /// </summary> private void LoadForm() { var isABTest = false; IssueInfo issue = null; if (IssueID > 0) { // Get issue object issue = IssueInfoProvider.GetIssueInfo(IssueID); if (issue != null) { if (NewsletterID == 0) { // Set newsletter ID NewsletterID = issue.IssueNewsletterID; } if (!RequestHelper.IsPostBack()) { txtDisplayName.Text = issue.IssueDisplayName; txtSubject.Text = issue.IssueSubject; chkIssueUseUTM.Checked = issue.IssueUseUTM; } isABTest = issue.IssueIsABTest; } } // Get newsletter object if (Newsletter != null) { issueTemplate.WhereCondition = GetAvailableEmailTemplatesWhere(issue); if (TemplateID > 0) { // Set selected value issueTemplate.Value = TemplateID; } if ((TemplateID <= 0) && (issue != null) && (issue.IssueTemplateID != TemplateID)) { // Change selected value issueTemplate.Value = TemplateID = issue.IssueTemplateID; issueTemplate.Reload(false); } // Prevent selecting none value in campaign selector if there is no campaign if (mAreCampaignsAvailable && CampaignInfoProvider.GetCampaigns().OnSite(SiteContext.CurrentSiteID).Count == 0) { radUTMCampaignExisting.Checked = false; radUTMCampaignExisting.Enabled = false; selectorUTMCampaign.Enabled = false; radUTMCampaignNew.Checked = true; mUTMCampaignTextBox.Enabled = true; } // Initialize inputs and content controls if (!RequestHelper.IsPostBack()) { txtSenderName.Text = issue != null ? issue.IssueSenderName : Newsletter.NewsletterSenderName; txtSenderEmail.Text = issue != null ? issue.IssueSenderEmail : Newsletter.NewsletterSenderEmail; txtIssueUTMSource.Text = issue != null ? issue.IssueUTMSource : string.Empty; txtPreheader.Text = issue != null ? issue.IssuePreheader : string.Empty; if (issue != null) { if (mAreCampaignsAvailable && (CampaignInfoProvider.GetCampaignByUTMCode(issue.IssueUTMCampaign, SiteContext.CurrentSiteName) != null)) { selectorUTMCampaign.Value = issue.IssueUTMCampaign; selectorUTMCampaign.Reload(false); selectorUTMCampaign.Enabled = true; radUTMCampaignExisting.Checked = true; radUTMCampaignNew.Checked = false; mUTMCampaignTextBox.Enabled = false; } else { mUTMCampaignTextBox.Text = issue.IssueUTMCampaign; mUTMCampaignTextBox.Enabled = true; radUTMCampaignExisting.Checked = false; radUTMCampaignNew.Checked = true; selectorUTMCampaign.Enabled = false; } } } else { if (issue != null && !pnlUTMParameters.Visible) { if (string.IsNullOrEmpty(txtIssueUTMSource.Text.Trim())) { txtIssueUTMSource.Text = Normalize(Newsletter.NewsletterName + "_" + txtSubject.Text.Trim()); } if (string.IsNullOrEmpty(mUTMCampaignTextBox.Text.Trim())) { mUTMCampaignTextBox.Text = Newsletter.NewsletterName.ToLower(CultureInfo.CurrentCulture); } } } mUTMCampaignTextBox.Attributes["placeholder"] = Newsletter.NewsletterName.ToLower(CultureInfo.CurrentCulture); } txtIssueUTMMedium.Text = DEFAULT_UTM_MEDIUM; btnSubmit.Enabled = Enabled; txtDisplayName.Enabled = Enabled && IsDisplayNameFieldEnabled(issue); txtPreheader.Enabled = Enabled; chkIssueUseUTM.Enabled = pnlIssueUTMCampaign.Enabled = pnlIssueUTMMedium.Enabled = pnlIssueUTMSource.Enabled = Enabled; txtSubject.Enabled = txtSenderEmail.Enabled = txtSenderName.Enabled = issueTemplate.Enabled = Enabled; pnlUTMParameters.Visible = chkIssueUseUTM.Checked; InitTooltips(isABTest); }
/// <summary> /// Reloads control data. /// </summary> /// <param name="forceReload">Indicates if force reload should be used</param> public override void ReloadData(bool forceReload) { var isABTest = false; if (!mLoaded || forceReload) { IssueInfo issue = null; if (IssueID > 0) { // Get issue object issue = IssueInfoProvider.GetIssueInfo(IssueID); if (issue != null) { if (NewsletterID == 0) { // Set newsletter ID NewsletterID = issue.IssueNewsletterID; } if (string.IsNullOrEmpty(txtSubject.Text) || forceReload) { txtSubject.Text = issue.IssueSubject; chkShowInArchive.Checked = issue.IssueShowInNewsletterArchive; chkIssueUseUTM.Checked = issue.IssueUseUTM; } isABTest = issue.IssueIsABTest; } } // Get newsletter object if (Newsletter != null) { // Modify where condition of template selector if issue exists string issueTemplateWhere = (issue != null) ? string.Format(" OR TemplateID IN (SELECT IssueTemplateID From Newsletter_NewsletterIssue WHERE IssueID={0})", issue.IssueID) : string.Empty; // Initialize template selector issueTemplate.WhereCondition = String.Format("(TemplateType='{0}') AND (TemplateID IN (SELECT NewsletterTemplateID FROM Newsletter_Newsletter WHERE NewsletterID={1})" + " OR TemplateID IN (SELECT TemplateID FROM Newsletter_EmailTemplateNewsletter WHERE NewsletterID={1}){2}) AND (TemplateSiteID={3})", EmailTemplateType.Issue, NewsletterID, issueTemplateWhere, Newsletter.NewsletterSiteID); if (TemplateID > 0) { // Set selected value issueTemplate.Value = TemplateID; } if ((forceReload || (TemplateID <= 0)) && (issue != null) && (issue.IssueTemplateID != TemplateID)) { // Change selected value issueTemplate.Value = TemplateID = issue.IssueTemplateID; issueTemplate.Reload(forceReload); } if (TemplateID <= 0) { // Get ID of default template issueTemplate.Value = TemplateID = Newsletter.NewsletterTemplateID; } // Prevent selecting none value in campaign selector if there is no campaign if (CampaignInfoProvider.GetCampaigns().OnSite(SiteContext.CurrentSiteID).Count == 0) { radUTMCampaignExisting.Checked = false; radUTMCampaignExisting.Enabled = false; selectorUTMCampaign.Enabled = false; radUTMCampaignNew.Checked = true; txtIssueUTMCampaign.Enabled = true; } // Initialize inputs and content controls if (!RequestHelper.IsPostBack() || forceReload) { txtSenderName.Text = (issue != null ? issue.IssueSenderName : Newsletter.NewsletterSenderName); txtSenderEmail.Text = (issue != null ? issue.IssueSenderEmail : Newsletter.NewsletterSenderEmail); txtIssueUTMSource.Text = (issue != null ? issue.IssueUTMSource : string.Empty); if (issue != null) { if (CampaignInfoProvider.GetCampaignByUTMCode(issue.IssueUTMCampaign, SiteContext.CurrentSiteName) != null) { selectorUTMCampaign.Value = issue.IssueUTMCampaign; selectorUTMCampaign.Reload(forceReload); selectorUTMCampaign.Enabled = true; radUTMCampaignExisting.Checked = true; radUTMCampaignNew.Checked = false; txtIssueUTMCampaign.Enabled = false; } else { txtIssueUTMCampaign.Text = issue.IssueUTMCampaign; txtIssueUTMCampaign.Enabled = true; radUTMCampaignExisting.Checked = false; radUTMCampaignNew.Checked = true; selectorUTMCampaign.Enabled = false; } } } else { if (issue != null) { if (string.IsNullOrEmpty(txtIssueUTMSource.Text.Trim())) { txtIssueUTMSource.Text = Normalize(Newsletter.NewsletterName + "_" + txtSubject.Text.Trim()); } if (string.IsNullOrEmpty(txtIssueUTMCampaign.Text.Trim())) { txtIssueUTMCampaign.Text = Newsletter.NewsletterName.ToLower(); } } } contentBody.NewsletterID = NewsletterID; contentBody.IssueID = IssueID; contentBody.TemplateID = TemplateID; contentBody.Enabled = Enabled; contentBody.ReloadData(forceReload); // Set simple/advanced options visibility InitSimpleAdvancedOptions(); txtIssueUTMCampaign.Attributes["placeholder"] = Newsletter.NewsletterName.ToLower(); // Set flag mLoaded = true; } } txtIssueUTMMedium.Text = DEFAULT_UTM_MEDIUM; chkShowInArchive.Enabled = txtSubject.Enabled = txtSenderEmail.Enabled = txtSenderName.Enabled = issueTemplate.Enabled = Enabled; chkIssueUseUTM.Enabled = pnlIssueUTMCampaign.Enabled = pnlIssueUTMMedium.Enabled = pnlIssueUTMSource.Enabled = Enabled; pnlUTMParameters.Visible = chkIssueUseUTM.Checked; InitTooltips(isABTest); }