/// <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; } }
/// <summary> /// Deserializes the passed XmlDocument and sets data directly into controls. /// </summary> /// <param name="xmlDocument">XmlDocument to be desrialized</param> private void DeserializeData(XmlDocument xmlDocument) { dataElement = SocialNetworkingHelper.DeserializePublishingElement(xmlDocument); if (dataElement.SocialNetworkType != SocialNetworkType.Twitter) { throw new Exception("Unrecognized XML format - wrong name element"); } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do not process } else { // Initialize variables string dataJobLocation = String.Empty, dataLogo = String.Empty, dataThemeColor = String.Empty, dataButtonSize = String.Empty, dataQuestions = String.Empty; string src = "http://platform.linkedin.com/in.js"; string apiKey = LinkedInHelper.GetLinkedInApiKey(CMSContext.CurrentSiteName); string apiSecret = LinkedInHelper.GetLinkedInSecretKey(CMSContext.CurrentSiteName); // Check settings if (!String.IsNullOrEmpty(apiKey) && !String.IsNullOrEmpty(apiSecret)) { // Check if optional parameters are set and transform them accordingly if (!string.IsNullOrEmpty(CompanyLogo)) { dataLogo = "data-logo=\"" + URLHelper.GetAbsoluteUrl(CompanyLogo) + "\""; } if (!string.IsNullOrEmpty(JobLocation)) { dataJobLocation = "data-joblocation=\"" + JobLocation + "\""; } if (!string.IsNullOrEmpty(ThemeColor)) { dataThemeColor = "data-themecolor=\"" + ThemeColor + "\""; } if (ButtonSize.EqualsCSafe("medium")) { dataButtonSize = "data-size=\"medium\""; } // Parse questions string and format it if (!string.IsNullOrEmpty(Questions)) { dataQuestions = "data-questions='["; string[] questionArray = Questions.Split(new string[1] { Environment.NewLine }, StringSplitOptions.None); foreach (string s in questionArray) { dataQuestions += "{\"question\": \"" + s + "\"},"; } dataQuestions = dataQuestions.TrimEnd(','); dataQuestions += "]'"; } // Build plugin code string output = "<div style=\"overflow: hidden; width: {0}px;\"><script src=\"{1}\" type=\"text/javascript\">api_key: {2}</script><script type=\"IN/Apply\" data-companyid=\"{3}\" data-jobtitle=\"{4}\" data-email=\"{5}\" {6} data-phone=\"{7}\" data-coverletter=\"{8}\" {9} data-showtext=\"{10}\" {11} {12} {13}></script></div>"; ltlPluginCode.Text = String.Format(output, Width, src, apiKey, CompanyID, JobTitle, DeliveryEmail, dataJobLocation, RequestPhone, RequestCoverLetter, dataLogo, ShowHelpText.ToString().ToLowerCSafe(), dataThemeColor, dataButtonSize, dataQuestions); } else { if (CMSContext.ViewMode == ViewModeEnum.Design) { string pathToSettings = SocialNetworkingHelper.GetPathToLinkedInSettings(); ltlPluginCode.Text = "<span class='ErrorLabel'>" + String.Format(ResHelper.GetString("socialnetworking.linkedin.settingsrequired"), pathToSettings) + "</span>"; } // Log event EventLogProvider.LogException("SocialNetworking", "LinkedInApplyWith", new Exception("Missing LinkedIn settings.")); } } }
/// <summary> /// Serializes data from controls and returns XmlDocument. /// </summary> private XmlDocument SerializeData() { dataElement.SocialNetworkType = SocialNetworkType.Twitter; return(SocialNetworkingHelper.SerializePublishingElement(dataElement)); }
/// <summary> /// Initializes the control properties /// </summary> protected void SetupControl() { if (this.StopProcessing) { // Do not process } else { string apiKey = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSGooglePlusClientID"); string apiSecret = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSGooglePlusClientSecret"); string accessToken = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSGooglePlusAccessToken"); // Check Social networking DLL and settings if (!SiteManagerFunctions.CheckSocialNetworkingDLL()) { // Error label is displayed in Design mode when Dll is renamed if (CMSContext.ViewMode == ViewModeEnum.Design) { lblError.Text = GetString("socialnetworking.renameddll"); lblError.Visible = true; } else { Visible = false; } } else if (String.IsNullOrEmpty(apiKey) || String.IsNullOrEmpty(apiSecret) || String.IsNullOrEmpty(accessToken)) { // Error label is displayed in Design mode when missing settings if (CMSContext.ViewMode == ViewModeEnum.Design) { string pathToSettings = SocialNetworkingHelper.GetPathToGooglePlusSettings(); lblError.Text = String.Format(GetString("socialnetworking.googleplus.allsettingsmissing"), pathToSettings); lblError.Visible = true; } else { Visible = false; } } else { // Process ID - it can be URL string showID = ExtractUserID(FeedID); // Fetch data from Google+ GooglePlusPerson profile = GooglePlusProvider.GetProfileInfo(showID); List <GooglePlusActivity> activities = GooglePlusProvider.GetActivities(showID, NumberOfActivities); if (profile != null) { // Build code for plugin StringBuilder sb = new StringBuilder(); sb.Append("<div class=\"gpaf-plugin\"><div class=\"gpaf-doc\" style=\"width: "); sb.Append(Width); sb.Append("px; height: "); sb.Append(Height); sb.Append("px; border: 1px solid "); sb.Append(BorderColor); sb.Append("; position: relative; background-color: "); sb.Append(ShellBackgroundColor); sb.Append("\"><div style=\"margin: 15px;\">"); // Build plugin header sb.Append("<div class=\"gpaf-header\">"); sb.Append("<table><tr><td style=\"vertical-align: center;\">"); sb.Append("<a href=\""); sb.Append(profile.URL); sb.Append("\">"); sb.Append("<img src=\""); string imageURL = profile.ImageURL.Remove(profile.ImageURL.Length - 2) + "40"; sb.Append(imageURL); sb.Append("\" alt=\""); sb.Append(profile.DisplayName); sb.Append("\" style=\"float: left; border: none;\" />"); sb.Append("</a>"); sb.Append("</td>"); sb.Append("<td style=\"vertical-align: center; padding-left: 10px;\">"); sb.Append("<a href=\""); sb.Append(profile.URL); sb.Append("\" style=\"text-decoration: none; font-size: 25px; color: "); sb.Append(ShellTextColor); sb.Append(";\">"); sb.Append(profile.DisplayName); sb.Append("</a>"); sb.Append("</td></tr></table>"); sb.Append("</div>"); // Insert section separator sb.Append("<div class=\"gpaf-doc-separator\" style=\"height: 15px; margin-top: 15px; width: 100%; border-top: 1px solid "); sb.Append(BorderColor); sb.Append(";\"></div>"); // Build plugin body sb.Append("<div class=\"gpaf-body\" style=\"height: "); sb.Append(Height - 164); sb.Append("px; overflow: "); sb.Append((Scrollbar) ? "auto" : "hidden"); sb.Append(";\">"); int counting = 1; foreach (GooglePlusActivity s in activities) { sb.Append("<div class=\"gpaf-activity\" style=\"color: "); sb.Append(ActivityTextColor); sb.Append("\">"); sb.Append("<div class=\"gpaf-activity-text\">"); sb.Append(s.Content); sb.Append("</div>"); sb.Append("<div class=\"gpaf-activity-footer\" style=\"color: "); sb.Append(ActivityFooterTextColor); sb.Append("; font-size: 13px; margin-top: 3px;\">"); sb.Append(s.Published); sb.Append("</div>"); sb.Append("</div>"); // Insert activity separator if (counting < activities.Count) { sb.Append("<div class=\"gpaf-body-separator\" style=\"height: 10px; margin-top: 5px; width: 100%; border-top: 1px dashed "); sb.Append(BorderColor); sb.Append(";\"></div>"); counting++; } } sb.Append("</div></div>"); // Insert section separator sb.Append("<div style=\"margin: 15px; position: absolute; bottom: 0px; left: 0px; width: "); sb.Append(Width - 30); sb.Append("px;\">"); sb.Append("<div class=\"gpaf-doc-separator\" style=\"height: 15px; margin-top: 15px; width: 100%; border-top: 1px solid "); sb.Append(BorderColor); sb.Append(";\"></div>"); // Build plugin footer sb.Append("<div class=\"gpaf-footer\">"); sb.Append("<a href=\"https://plus.google.com\">"); sb.Append("<img src=\"https://ssl.gstatic.com/images/icons/gplus-32.png\" alt=\"\" style=\"float: left; border: none;\" />"); sb.Append("</a>"); sb.Append("<div class=\"gpaf-footer-text\" style=\"text-align: left; margin-left: 50px;\">"); sb.Append("<table style=\"height: 32px;\"><tr><td style=\"vertical-align: center;\">"); sb.Append("<a href=\""); sb.Append(profile.URL); sb.Append("\" style=\"text-decoration: none; font-size: 12px; color: "); sb.Append(ShellTextColor); sb.Append(";\">"); sb.Append(ResHelper.GetString("socialnetworking.viewfullprofile")); sb.Append("</a>"); sb.Append("</td></tr></table>"); sb.Append("</div>"); sb.Append("<div style=\"clear: both;\"></div>"); sb.Append("</div>"); // Close open divs and finish plugin sb.Append("</div></div></div>"); ltlPluginCode.Text = sb.ToString(); } } } }