using System; using System.Data; using System.Collections; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using CMS.PortalControls; using CMS.GlobalHelper; using CMS.CMSHelper; public partial class CMSWebParts_CommunityServices_GooglePlus_GooglePlusBadge : CMSAbstractWebPart { #region "Properties" /// /// Second part of the Google+ page link. /// public string PageLink { get { return ValidationHelper.GetString(GetValue("Link"), string.Empty); } set { SetValue("Link", value); } } /// /// Width of the web part in pixels. /// public int Width { get { return ValidationHelper.GetInteger(GetValue("Width"), 110); } set { SetValue("Width", value); } } /// /// Style. /// public string Style { get { return ValidationHelper.GetString(GetValue("Style"), string.Empty); } set { SetValue("Style", value); } } /// /// Language. /// public string Language { get { return ValidationHelper.GetString(GetValue("Language"), string.Empty); } set { SetValue("Language", value); } } /// /// Custom text. /// public string CustomName { get { return ValidationHelper.GetString(GetValue("CustomName"), string.Empty); } set { SetValue("CustomName", value); } } #endregion #region "Methods" /// /// Content loaded event handler /// public override void OnContentLoaded() { base.OnContentLoaded(); SetupControl(); } /// /// Initializes the control properties /// protected void SetupControl() { if (this.StopProcessing) { // Do not process } else { // Build code for plugin string output = String.Empty; string src = "https://apis.google.com/js/plusone.js"; if (string.IsNullOrEmpty(Language)) { Language = CMSContext.CurrentDocumentCulture.CultureCode; } switch (Style) { case "badge": case "smallbadge": output = "
"; ltlPluginCode.Text = String.Format(output, Width, src, Language, PageLink, Style); break; default: string iconSize = Style.Substring(4); output = "
{2}on\"\"
"; ltlPluginCode.Text = String.Format(output, Width, PageLink, CustomName, iconSize); break; } } } /// /// Reloads the control data /// public override void ReloadData() { base.ReloadData(); SetupControl(); } protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); if (StopProcessing) { // Do nothing } else { // Add link tag to head string linkTag = String.Format("", PageLink); Page.Header.Controls.Add(new LiteralControl(linkTag)); } } #endregion }