using System; using CMS.CMSHelper; using CMS.GlobalHelper; using CMS.PortalControls; using CMS.PortalEngine; public partial class CMSWebParts_Layouts_ZonesWithEffect : CMSAbstractLayoutWebPart { #region "Properties" /// /// Number of zones. /// public int Zones { get { return ValidationHelper.GetInteger(GetValue("Zones"), 2); } set { SetValue("Zones", value); } } /// /// Content before all zones. /// public string BeforeZones { get { return ValidationHelper.GetString(GetValue("BeforeZones"), ""); } set { SetValue("BeforeZones", value); } } /// /// Separator between zones. /// public string Separator { get { return ValidationHelper.GetString(GetValue("Separator"), ""); } set { SetValue("Separator", value); } } /// /// Content after all zones. /// public string AfterZones { get { return ValidationHelper.GetString(GetValue("AfterZones"), ""); } set { SetValue("AfterZones", value); } } /// /// Zone CSS class. /// public string ZoneCSSClass { get { return ValidationHelper.GetString(GetValue("ZoneCSSClass"), ""); } set { SetValue("ZoneCSSClass", value); } } /// /// Zone width. /// public string ZoneWidth { get { return ValidationHelper.GetString(GetValue("ZoneWidth"), ""); } set { SetValue("ZoneWidth", value); } } /// /// Content before each zone. /// public string BeforeZone { get { return ValidationHelper.GetString(GetValue("BeforeZone"), ""); } set { SetValue("BeforeZone", value); } } /// /// Content after each zone. /// public string AfterZone { get { return ValidationHelper.GetString(GetValue("AfterZone"), ""); } set { SetValue("AfterZone", value); } } /// /// Include jQuery script. /// public bool IncludeJQuery { get { return ValidationHelper.GetBoolean(GetValue("IncludeJQuery"), false); } set { SetValue("IncludeJQuery", value); } } /// /// Script files. /// public string ScriptFiles { get { return ValidationHelper.GetString(GetValue("ScriptFiles"), ""); } set { SetValue("ScriptFiles", value); } } /// /// Initialization script. /// public string InitScript { get { return ValidationHelper.GetString(GetValue("InitScript"), ""); } set { SetValue("InitScript", value); } } /// /// Additional CSS files. /// public string CSSFiles { get { return ValidationHelper.GetString(GetValue("CSSFiles"), ""); } set { SetValue("CSSFiles", value); } } /// /// Inline CSS styles. /// public string InlineCSS { get { return ValidationHelper.GetString(GetValue("InlineCSS"), ""); } set { SetValue("InlineCSS", value); } } #endregion #region "Methods" /// /// Prepares the layout of the web part. /// protected override void PrepareLayout() { StartLayout(); if (IsDesign) { Append(""); if (ViewMode == ViewModeEnum.Design) { Append(""); } Append(""); // Footer if (AllowDesignMode) { Append(""); } Append("
"); // Add header container AddHeaderContainer(); Append("
"); } // Content before zones Append(BeforeZones); string separator = Separator; string before = BeforeZone; string after = AfterZone; string zoneclass = ZoneCSSClass; string zonewidth = ZoneWidth; // Render the zones for (int i = 1; i <= Zones; i++) { if (i > 1) { Append(separator); } Append("", before); // Add the zone CMSWebPartZone zone = AddZone(ID + "_" + i, "[" + i + "]"); Append(after, ""); } // Content after zones Append(AfterZones); if (IsDesign) { Append("
"); // Zone actions AppendRemoveAction(ResHelper.GetString("Layout.RemoveZone"), "Zones"); Append("  "); AppendAddAction(ResHelper.GetString("Layout.AddZone"), "Zones"); Append("
"); } // Register jQuery if (IncludeJQuery) { ScriptHelper.RegisterJQuery(Page); } // Register scripts string[] scripts = ScriptFiles.Split('\r', '\n'); foreach (string script in scripts) { // Register the script file string sfile = script.Trim(); if (!String.IsNullOrEmpty(sfile)) { ScriptHelper.RegisterScriptFile(Page, sfile); } } // Add init script string resolvedInitScript = CMSContext.ResolveMacros(InitScript); if (!string.IsNullOrEmpty(resolvedInitScript)) { ScriptHelper.RegisterStartupScript(this, typeof(string), ShortClientID + "_Init", ScriptHelper.GetScript(resolvedInitScript)); } // Register CSS files string[] cssFiles = CSSFiles.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); Array.ForEach(cssFiles, cssFile => CSSHelper.RegisterCSSLink(Page, cssFile.Trim())); // Add inline CSS string inlinecss = CMSContext.ResolveMacros(InlineCSS); if (!string.IsNullOrEmpty(inlinecss)) { // Add css to page header CSSHelper.RegisterCSSBlock(Page, inlinecss); } FinishLayout(); } #endregion }