/// <summary>Refreshes this instance.</summary> private void Refresh() { this.Renderings.Controls.Clear(); this.Placeholders.Controls.Clear(); this.Controls = new ArrayList(); DeviceDefinition device = CustomDeviceEditor.GetLayoutDefinition().GetDevice(this.DeviceID); if (device.Renderings == null) { SheerResponse.SetOuterHtml("Renderings", (System.Web.UI.Control) this.Renderings); SheerResponse.SetOuterHtml("Placeholders", (System.Web.UI.Control) this.Placeholders); SheerResponse.Eval("if (!scForm.browser.isIE) { scForm.browser.initializeFixsizeElements(); }"); } else { int selectedIndex = this.SelectedIndex; this.RenderRenderings(device, selectedIndex, 0); this.RenderPlaceholders(device); this.UpdateRenderingsCommandsState(); this.UpdatePlaceholdersCommandsState(); SheerResponse.SetOuterHtml("Renderings", (System.Web.UI.Control) this.Renderings); SheerResponse.SetOuterHtml("Placeholders", (System.Web.UI.Control) this.Placeholders); SheerResponse.Eval("if (!scForm.browser.isIE) { scForm.browser.initializeFixsizeElements(); }"); } }
/// <summary>Updates the state of the commands.</summary> private void UpdateRenderingsCommandsState() { if (this.SelectedIndex < 0) { this.ChangeButtonsState(true); } else { ArrayList renderings = CustomDeviceEditor.GetLayoutDefinition().GetDevice(this.DeviceID).Renderings; if (renderings == null) { this.ChangeButtonsState(true); } else { RenderingDefinition definition = renderings[this.SelectedIndex] as RenderingDefinition; if (definition == null) { this.ChangeButtonsState(true); } else { this.ChangeButtonsState(false); this.Personalize.Disabled = !string.IsNullOrEmpty(definition.MultiVariateTest); this.Test.Disabled = CustomDeviceEditor.HasRenderingRules(definition); } } } }
/// <summary>Raises the load event.</summary> /// <param name="e"> /// The <see cref="T:System.EventArgs" /> instance containing the event data. /// </param> /// <remarks> /// This method notifies the server control that it should perform actions common to each HTTP /// request for the page it is associated with, such as setting up a database query. At this /// stage in the page life cycle, server controls in the hierarchy are created and initialized, /// view state is restored, and form controls reflect client-side data. Use the IsPostBack /// property to determine whether the page is being loaded in response to a client post back, /// or if it is being loaded and accessed for the first time. /// </remarks> protected override void OnLoad(EventArgs e) { Assert.ArgumentNotNull((object)e, "e"); base.OnLoad(e); if (Context.ClientPage.IsEvent) { return; } this.DeviceID = WebUtil.GetQueryString("de"); DeviceDefinition device = CustomDeviceEditor.GetLayoutDefinition().GetDevice(this.DeviceID); if (device.Layout != null) { this.Layout.Value = device.Layout; } this.Personalize.Visible = Policy.IsAllowed("Page Editor/Extended features/Personalization"); #if (!SC72 && !SC75 && !SC80) this.Test.Visible = Sitecore.Xdb.Configuration.XdbSettings.Enabled && Policy.IsAllowed("Page Editor/Extended features/Testing"); #else this.Test.Visible = Policy.IsAllowed("Page Editor/Extended features/Testing"); #endif this.Refresh(); this.SelectedIndex = -1; }
protected void SortUp(Message message) { Assert.ArgumentNotNull((object)message, "message"); if (this.SelectedIndex <= 0) { return; } LayoutDefinition layoutDefinition = CustomDeviceEditor.GetLayoutDefinition(); ArrayList renderings = layoutDefinition.GetDevice(this.DeviceID).Renderings; if (renderings == null) { return; } RenderingDefinition renderingDefinition = renderings[this.SelectedIndex] as RenderingDefinition; if (renderingDefinition == null) { return; } renderings.Remove((object)renderingDefinition); renderings.Insert(this.SelectedIndex - 1, (object)renderingDefinition); --this.SelectedIndex; CustomDeviceEditor.SetDefinition(layoutDefinition); this.Refresh(); }
/// <summary>Handles a click on the OK button.</summary> /// <param name="sender">The sender.</param> /// <param name="args">The arguments.</param> /// <remarks> /// When the user clicks OK, the dialog is closed by calling /// the <see cref="M:Sitecore.Web.UI.Sheer.ClientResponse.CloseWindow">CloseWindow</see> method. /// </remarks> protected override void OnOK(object sender, EventArgs args) { Assert.ArgumentNotNull(sender, "sender"); Assert.ArgumentNotNull((object)args, "args"); if (this.Layout.Value.Length > 0) { Item obj = Client.ContentDatabase.GetItem(this.Layout.Value); if (obj == null) { Context.ClientPage.ClientResponse.Alert("Layout not found."); return; } if (obj.TemplateID == TemplateIDs.Folder || obj.TemplateID == TemplateIDs.Node) { Context.ClientPage.ClientResponse.Alert(Translate.Text("\"{0}\" is not a layout.", (object)obj.DisplayName)); return; } } LayoutDefinition layoutDefinition = CustomDeviceEditor.GetLayoutDefinition(); DeviceDefinition device = layoutDefinition.GetDevice(this.DeviceID); ArrayList renderings = device.Renderings; if (renderings != null && renderings.Count > 0 && this.Layout.Value.Length == 0) { Context.ClientPage.ClientResponse.Alert("You must specify a layout when you specify renderings."); } else { device.Layout = this.Layout.Value; CustomDeviceEditor.SetDefinition(layoutDefinition); Context.ClientPage.ClientResponse.SetDialogValue("yes"); base.OnOK(sender, args); } }
protected void AddPlaceholder(ClientPipelineArgs args) { if (args.IsPostBack) { if (string.IsNullOrEmpty(args.Result) || !(args.Result != "undefined")) { return; } LayoutDefinition layoutDefinition = CustomDeviceEditor.GetLayoutDefinition(); DeviceDefinition device = layoutDefinition.GetDevice(this.DeviceID); string placeholderKey; Item dialogResult = SelectPlaceholderSettingsOptions.ParseDialogResult(args.Result, Client.ContentDatabase, out placeholderKey); if (dialogResult == null || string.IsNullOrEmpty(placeholderKey)) { return; } PlaceholderDefinition placeholderDefinition = new PlaceholderDefinition() { UniqueId = ID.NewID.ToString(), MetaDataItemId = dialogResult.Paths.FullPath, Key = placeholderKey }; device.AddPlaceholder(placeholderDefinition); CustomDeviceEditor.SetDefinition(layoutDefinition); this.Refresh(); } else { SheerResponse.ShowModalDialog(new SelectPlaceholderSettingsOptions() { IsPlaceholderKeyEditable = true }.ToUrlString().ToString(), "460px", "460px", string.Empty, true); args.WaitForPostBack(); } }
protected void Add(ClientPipelineArgs args) { Assert.ArgumentNotNull((object)args, "args"); if (args.IsPostBack) { if (!args.HasResult) { return; } string[] strArray = args.Result.Split(','); string str1 = strArray[0]; string str2 = strArray[1].Replace("-c-", ","); bool flag = strArray[2] == "1"; LayoutDefinition layoutDefinition = CustomDeviceEditor.GetLayoutDefinition(); DeviceDefinition device = layoutDefinition.GetDevice(this.DeviceID); RenderingDefinition renderingDefinition = new RenderingDefinition() { ItemID = str1, Placeholder = str2 }; device.AddRendering(renderingDefinition); CustomDeviceEditor.SetDefinition(layoutDefinition); this.Refresh(); if (flag) { ArrayList renderings = device.Renderings; if (renderings != null) { this.SelectedIndex = renderings.Count - 1; Context.ClientPage.SendMessage((object)this, "device:edit"); } } Registry.SetString("/Current_User/SelectRendering/Selected", str1); } else { Item itm = UIUtil.GetItemFromQueryString(Sitecore.Client.ContentDatabase); SelectRenderingOptions renderingOptions = new SelectRenderingOptions() { ShowOpenProperties = true, ShowPlaceholderName = true, PlaceholderName = string.Empty }; string @string = Registry.GetString("/Current_User/SelectRendering/Selected"); if (!string.IsNullOrEmpty(@string)) { renderingOptions.SelectedItem = Client.ContentDatabase.GetItem(@string); } //Modify the following line to include id and deviceid parameters SheerResponse.ShowModalDialog(renderingOptions.ToUrlString(Sitecore.Client.ContentDatabase).ToString() + "&ciId=" + System.Web.HttpUtility.UrlEncode(itm.ID.ToString()) + "&deviceid=" + System.Web.HttpUtility.UrlEncode(this.DeviceID), true); //SheerResponse.ShowModalDialog(renderingOptions.ToUrlString(Client.ContentDatabase).ToString(), true); args.WaitForPostBack(); } }
protected void SetTest(ClientPipelineArgs args) { Assert.ArgumentNotNull((object)args, "args"); if (this.SelectedIndex < 0) { return; } LayoutDefinition layoutDefinition = CustomDeviceEditor.GetLayoutDefinition(); DeviceDefinition device = layoutDefinition.GetDevice(this.DeviceID); ArrayList renderings = device.Renderings; if (renderings == null) { return; } RenderingDefinition renderingDefinition = renderings[this.SelectedIndex] as RenderingDefinition; if (renderingDefinition == null) { return; } if (args.IsPostBack) { if (!args.HasResult) { return; } if (args.Result == "#reset#") { renderingDefinition.MultiVariateTest = string.Empty; CustomDeviceEditor.SetDefinition(layoutDefinition); this.Refresh(); } else { ID dialogResult = SetTestDetailsOptions.ParseDialogResult(args.Result); if (ID.IsNullOrEmpty(dialogResult)) { SheerResponse.Alert("Item not found."); } else { renderingDefinition.MultiVariateTest = dialogResult.ToString(); CustomDeviceEditor.SetDefinition(layoutDefinition); this.Refresh(); } } } else { SheerResponse.ShowModalDialog(new SetTestDetailsOptions("SC_DEVICEEDITOR", UIUtil.GetItemFromQueryString(Client.ContentDatabase).Uri.ToString(), device.ID, renderingDefinition.UniqueId).ToUrlString().ToString(), "520px", "695px", string.Empty, true); args.WaitForPostBack(); } }
protected void Change(ClientPipelineArgs args) { Assert.ArgumentNotNull((object)args, "args"); if (this.SelectedIndex < 0) { return; } LayoutDefinition layoutDefinition = CustomDeviceEditor.GetLayoutDefinition(); ArrayList renderings = layoutDefinition.GetDevice(this.DeviceID).Renderings; if (renderings == null) { return; } RenderingDefinition renderingDefinition = renderings[this.SelectedIndex] as RenderingDefinition; if (renderingDefinition == null || string.IsNullOrEmpty(renderingDefinition.ItemID)) { return; } if (args.IsPostBack) { if (!args.HasResult) { return; } string[] strArray = args.Result.Split(','); renderingDefinition.ItemID = strArray[0]; bool flag = strArray[2] == "1"; CustomDeviceEditor.SetDefinition(layoutDefinition); this.Refresh(); if (!flag) { return; } Context.ClientPage.SendMessage((object)this, "device:edit"); } else { SelectRenderingOptions renderingOptions = new SelectRenderingOptions(); renderingOptions.ShowOpenProperties = true; renderingOptions.ShowPlaceholderName = false; renderingOptions.PlaceholderName = string.Empty; renderingOptions.SelectedItem = Client.ContentDatabase.GetItem(renderingDefinition.ItemID); SheerResponse.ShowModalDialog(renderingOptions.ToUrlString(Client.ContentDatabase).ToString(), true); args.WaitForPostBack(); } }
protected void PersonalizeControl(ClientPipelineArgs args) { Assert.ArgumentNotNull((object)args, "args"); if (this.SelectedIndex < 0) { return; } LayoutDefinition layoutDefinition = CustomDeviceEditor.GetLayoutDefinition(); ArrayList renderings = layoutDefinition.GetDevice(this.DeviceID).Renderings; if (renderings == null) { return; } RenderingDefinition renderingDefinition = renderings[this.SelectedIndex] as RenderingDefinition; if (renderingDefinition == null || string.IsNullOrEmpty(renderingDefinition.ItemID) || string.IsNullOrEmpty(renderingDefinition.UniqueId)) { return; } if (args.IsPostBack) { if (!args.HasResult) { return; } XElement xelement = XElement.Parse(args.Result); renderingDefinition.Rules = xelement; CustomDeviceEditor.SetDefinition(layoutDefinition); this.Refresh(); } else { Item itemFromQueryString = UIUtil.GetItemFromQueryString(Client.ContentDatabase); string str = itemFromQueryString != null?itemFromQueryString.Uri.ToString() : string.Empty; SheerResponse.ShowModalDialog(new PersonalizeOptions() { SessionHandle = CustomDeviceEditor.GetSessionHandle(), DeviceId = this.DeviceID, RenderingUniqueId = renderingDefinition.UniqueId, ContextItemUri = str }.ToUrlString().ToString(), "980px", "712px", string.Empty, true); args.WaitForPostBack(); } }
protected void EditPlaceholder(ClientPipelineArgs args) { if (string.IsNullOrEmpty(this.UniqueId)) { return; } LayoutDefinition layoutDefinition = CustomDeviceEditor.GetLayoutDefinition(); PlaceholderDefinition placeholder = layoutDefinition.GetDevice(this.DeviceID).GetPlaceholder(this.UniqueId); if (placeholder == null) { return; } if (args.IsPostBack) { if (string.IsNullOrEmpty(args.Result) || !(args.Result != "undefined")) { return; } string placeholderKey; Item dialogResult = SelectPlaceholderSettingsOptions.ParseDialogResult(args.Result, Client.ContentDatabase, out placeholderKey); if (dialogResult == null) { return; } placeholder.MetaDataItemId = dialogResult.Paths.FullPath; placeholder.Key = placeholderKey; CustomDeviceEditor.SetDefinition(layoutDefinition); this.Refresh(); } else { Item obj = string.IsNullOrEmpty(placeholder.MetaDataItemId) ? (Item)null : Client.ContentDatabase.GetItem(placeholder.MetaDataItemId); SelectPlaceholderSettingsOptions placeholderSettingsOptions = new SelectPlaceholderSettingsOptions(); placeholderSettingsOptions.TemplateForCreating = (Template)null; placeholderSettingsOptions.PlaceholderKey = placeholder.Key; placeholderSettingsOptions.CurrentSettingsItem = obj; placeholderSettingsOptions.SelectedItem = obj; placeholderSettingsOptions.IsPlaceholderKeyEditable = true; SheerResponse.ShowModalDialog(placeholderSettingsOptions.ToUrlString().ToString(), "460px", "460px", string.Empty, true); args.WaitForPostBack(); } }
protected void RemovePlaceholder(Message message) { Assert.ArgumentNotNull((object)message, "message"); if (string.IsNullOrEmpty(this.UniqueId)) { return; } LayoutDefinition layoutDefinition = CustomDeviceEditor.GetLayoutDefinition(); DeviceDefinition device = layoutDefinition.GetDevice(this.DeviceID); PlaceholderDefinition placeholder = device.GetPlaceholder(this.UniqueId); if (placeholder == null) { return; } ArrayList placeholders = device.Placeholders; if (placeholders != null) { placeholders.Remove((object)placeholder); } CustomDeviceEditor.SetDefinition(layoutDefinition); this.Refresh(); }
protected void Remove(Message message) { Assert.ArgumentNotNull((object)message, "message"); int selectedIndex = this.SelectedIndex; if (selectedIndex < 0) { return; } LayoutDefinition layoutDefinition = CustomDeviceEditor.GetLayoutDefinition(); ArrayList renderings = layoutDefinition.GetDevice(this.DeviceID).Renderings; if (renderings == null || selectedIndex < 0 || selectedIndex >= renderings.Count) { return; } renderings.RemoveAt(selectedIndex); if (selectedIndex >= 0) { --this.SelectedIndex; } CustomDeviceEditor.SetDefinition(layoutDefinition); this.Refresh(); }