protected void SwitchRenderingClick(string id) { Assert.ArgumentNotNull(id, "id"); XElement rulesSet = this.RulesSet; XElement ruleById = PersonalizationFormWithActions.GetRuleById(rulesSet, id); if (ruleById != null) { if (this.IsComponentDisplayed(ruleById)) { PersonalizationFormWithActions.AddAction(ruleById, this.HideRenderingActionId); } else { PersonalizationFormWithActions.RemoveAction(ruleById, this.HideRenderingActionId); } this.RulesSet = rulesSet; } }
protected void SetRendering(ClientPipelineArgs args) { string result; Assert.ArgumentNotNull(args, "args"); if (!args.IsPostBack) { string placeholder = this.RenderingDefition.Placeholder; Assert.IsNotNull(placeholder, "placeholder"); string layout = this.Layout; GetPlaceholderRenderingsArgs getPlaceholderRenderingsArg = new GetPlaceholderRenderingsArgs(placeholder, layout, Client.ContentDatabase, ID.Parse(this.DeviceId)) { OmitNonEditableRenderings = true }; getPlaceholderRenderingsArg.Options.ShowOpenProperties = false; CorePipeline.Run("getPlaceholderRenderings", getPlaceholderRenderingsArg); string dialogURL = getPlaceholderRenderingsArg.DialogURL; if (string.IsNullOrEmpty(dialogURL)) { SheerResponse.Alert("An error occurred.", new string[0]); return; } SheerResponse.ShowModalDialog(dialogURL, "720px", "470px", string.Empty, true); args.WaitForPostBack(); return; } if (args.HasResult) { if (args.Result.IndexOf(',') < 0) { result = args.Result; } else { string str = args.Result; char[] chrArray = new char[] { ',' }; result = str.Split(chrArray)[0]; } XElement rulesSet = this.RulesSet; string item = args.Parameters["id"]; XElement ruleById = PersonalizationFormWithActions.GetRuleById(rulesSet, item); Assert.IsNotNull(ruleById, "rule"); (PersonalizationFormWithActions.GetActionById(ruleById, this.SetRenderingActionId) ?? PersonalizationFormWithActions.AddAction(ruleById, this.SetRenderingActionId)).SetAttributeValue("RenderingItem", ShortID.DecodeID(result)); this.RulesSet = rulesSet; HtmlTextWriter htmlTextWriter = new HtmlTextWriter(new StringWriter()); this.RenderSetRenderingAction(ruleById, htmlTextWriter); SheerResponse.SetInnerHtml(string.Concat(item, "_setrendering"), htmlTextWriter.InnerWriter.ToString().Replace("{ID}", item)); } }
protected void SetDatasource(ClientPipelineArgs args) { Language language; Assert.ArgumentNotNull(args, "args"); string item = args.Parameters["id"]; XElement rulesSet = this.RulesSet; XElement ruleById = PersonalizationFormWithActions.GetRuleById(rulesSet, item); Assert.IsNotNull(ruleById, "rule"); if (args.IsPostBack) { if (args.HasResult) { (PersonalizationFormWithActions.GetActionById(ruleById, this.SetDatasourceActionId) ?? PersonalizationFormWithActions.AddAction(ruleById, this.SetDatasourceActionId)).SetAttributeValue("DataSource", args.Result); this.RulesSet = rulesSet; HtmlTextWriter htmlTextWriter = new HtmlTextWriter(new StringWriter()); this.RenderSetDatasourceAction(ruleById, htmlTextWriter); SheerResponse.SetInnerHtml(string.Concat(item, "_setdatasource"), htmlTextWriter.InnerWriter.ToString().Replace("{ID}", item)); } return; } XElement actionById = PersonalizationFormWithActions.GetActionById(ruleById, this.SetRenderingActionId); Item item1 = null; if (actionById != null && !string.IsNullOrEmpty(actionById.GetAttributeValue("RenderingItem"))) { item1 = Client.ContentDatabase.GetItem(actionById.GetAttributeValue("RenderingItem")); } else if (!string.IsNullOrEmpty(this.RenderingDefition.ItemID)) { item1 = Client.ContentDatabase.GetItem(this.RenderingDefition.ItemID); } if (item1 == null) { SheerResponse.Alert("Item not found.", new string[0]); return; } Item contextItem = this.ContextItem; GetRenderingDatasourceArgs getRenderingDatasourceArg = new GetRenderingDatasourceArgs(item1) { FallbackDatasourceRoots = new List <Item>() { Client.ContentDatabase.GetRootItem() } }; GetRenderingDatasourceArgs getRenderingDatasourceArg1 = getRenderingDatasourceArg; if (contextItem != null) { language = contextItem.Language; } else { language = null; } getRenderingDatasourceArg1.ContentLanguage = language; getRenderingDatasourceArg.ContextItemPath = (contextItem != null ? contextItem.Paths.FullPath : string.Empty); getRenderingDatasourceArg.ShowDialogIfDatasourceSetOnRenderingItem = true; GetRenderingDatasourceArgs datasource = getRenderingDatasourceArg; XElement xElement = PersonalizationFormWithActions.GetActionById(ruleById, this.SetDatasourceActionId); if (xElement == null || string.IsNullOrEmpty(xElement.GetAttributeValue("DataSource"))) { datasource.CurrentDatasource = this.RenderingDefition.Datasource; } else { datasource.CurrentDatasource = xElement.GetAttributeValue("DataSource"); } if (string.IsNullOrEmpty(datasource.CurrentDatasource)) { datasource.CurrentDatasource = contextItem.ID.ToString(); } CorePipeline.Run("getRenderingDatasource", datasource); if (string.IsNullOrEmpty(datasource.DialogUrl)) { SheerResponse.Alert("An error occurred.", new string[0]); return; } SheerResponse.ShowModalDialog(datasource.DialogUrl, "960px", "660px", string.Empty, true); args.WaitForPostBack(); }