/// <summary> /// Sets properties (Enabled, Text, Visible, etc.) of all controls based on various conditions. /// </summary> private void RenderControls() { chkEnabledTwitter.Visible = IsWorkflow; btnPostAtTwitter.Visible = true; chkEnabledTwitter.Checked = dataElement.AutoPostAfterPublishing; txtTemplateTwitter.Text = dataElement.Template; if (dataElement.IsPublished) { lblTwitterIsPublished.Text = ResHelper.GetString("socialnetworking.twitter.ispublished"); lnkTwitterPostURL.NavigateUrl = dataElement.PostURL; lnkTwitterPostURL.Text = dataElement.PostURL; lnkTwitterPostURL.Target = "_blank"; lnkTwitterPostURL.Visible = true; } else { lblTwitterIsPublished.Text = ResHelper.GetString("socialnetworking.twitter.isnotpublished"); } bool isSetting = SocialNetworkingHelper.IsSettingSet(CMSContext.CurrentSiteName, SocialNetworkType.Twitter); // Check the license string currentDomain = URLHelper.GetCurrentDomain(); if (!String.IsNullOrEmpty(currentDomain)) { if (!LicenseHelper.CheckFeature(currentDomain, FeatureEnum.SocialAutoPost)) { Enabled = false; isSetting = true; lblAccessDeniedWarning.Visible = true; } } // Disable button "Post at Twitter" if document wasn't saved yet. btnPostAtTwitter.Enabled = (Enabled && (node.NodeID > 0) && isSetting); chkEnabledTwitter.Enabled = (Enabled && isSetting); txtTemplateTwitter.Enabled = Enabled; if (!btnPostAtTwitter.Enabled) { btnPostAtTwitter.CssClass += "Disabled"; } if (!isSetting) { lblTwitterMissingSetting.Visible = true; } lblCharactersCount.Text = string.Format("{0}/{1}", (dataElement.Template != null ? dataElement.Template.Length : 0), SocialNetworkingHelper.TWITTER_MAX_LENGTH); if ((dataElement.Template != null) && (dataElement.Template.Length > SocialNetworkingHelper.TWITTER_MAX_LENGTH)) { lblCharactersCount.Style.Add("color", "red"); } }
/// <summary> /// Renders controls depending on current state. /// </summary> private void RenderControls() { chkEnabledFacebook.Visible = IsWorkflow; btnPostAtFacebook.Visible = true; chkEnabledFacebook.Checked = dataElement.AutoPostAfterPublishing; txtTemplateFacebook.Text = dataElement.Template; // Set info message if (dataElement.IsPublished) { lblFacebookIsPublished.Text = ResHelper.GetString("socialnetworking.facebook.ispublished"); lnkFacebookPostURL.NavigateUrl = dataElement.PostURL; lnkFacebookPostURL.Text = dataElement.PostURL; lnkFacebookPostURL.Target = "_blank"; lnkFacebookPostURL.Visible = true; } else { lblFacebookIsPublished.Text = ResHelper.GetString("socialnetworking.facebook.isnotpublished"); } bool isSetting = SocialNetworkingHelper.IsSettingSet(CMSContext.CurrentSiteName, SocialNetworkType.Facebook); // Check the license string currentDomain = URLHelper.GetCurrentDomain(); if (!String.IsNullOrEmpty(currentDomain)) { if (!LicenseHelper.CheckFeature(currentDomain, FeatureEnum.SocialAutoPost)) { Enabled = false; isSetting = true; lblAccessDeniedWarning.Visible = true; } } // Disable button "Post at Facebook" if document wasn't saved yet. btnPostAtFacebook.Enabled = (Enabled && (node.NodeID > 0) && isSetting); chkEnabledFacebook.Enabled = (Enabled && isSetting); txtTemplateFacebook.Enabled = Enabled; if (!btnPostAtFacebook.Enabled) { btnPostAtFacebook.CssClass += "Disabled"; } if (!isSetting) { lblFacebookMissingSetting.Visible = true; } if (FacebookProvider.IsAccessTokenExpired(CMSContext.CurrentSiteName)) { lblExpirationWarning.Visible = true; } }