// on ok protected override void OnOK(object sender, EventArgs args) { Assert.ArgumentNotNull(sender, "sender"); Assert.ArgumentNotNull((object)args, "args"); ListString listString = new ListString(WebUtil.GetFormValue("sortorder")); if (listString.Count == 0) // no changes made { base.OnOK(sender, args); } else { if (IsDBsort(listString.ToString())) { SortContentOptions sortContentOptions = SortContentOptions.Parse(); ProcessDbOrder(sortContentOptions.Item.Children[0], listString); // save sort order of db view data } else // sort input view items { ListString source = listString; this.Sort(source.Select <string, ID>(x => ShortID.DecodeID(x))); SheerResponse.SetDialogValue("1"); } base.OnOK(sender, args); } }
/// <summary>Expands the tree view to node.</summary> /// <returns>The tree view to node.</returns> private static string ExpandTreeViewToNode() { var str1 = WebUtil.GetQueryString("root"); var str2 = WebUtil.GetQueryString("id"); var queryString = WebUtil.GetQueryString("la"); if (str2.IndexOf('_') >= 0) { str2 = StringUtil.Mid(str2, str2.LastIndexOf('_') + 1); } if (str1.IndexOf('_') >= 0) { str1 = StringUtil.Mid(str1, str1.LastIndexOf('_') + 1); } if (str2.Length > 0 && str1.Length > 0) { var language = Language.Parse(queryString); var folder = Client.ContentDatabase.GetItem(ShortID.DecodeID(str2), language); var root = Client.ContentDatabase.GetItem(ShortID.DecodeID(str1), language); if (folder != null && root != null) { return(GetTree(folder, root).RenderTree(false)); } } return(string.Empty); }
protected void RenameVariation(Message message) { string argument = message.Arguments["variationId"]; string str2 = message.Arguments["name"]; Assert.ArgumentNotNull(argument, "variationId"); Assert.ArgumentNotNull(str2, "name"); ID id = ShortID.DecodeID(argument); List <VariableValueItemStub> variableValues = VariableValues; int num = variableValues.FindIndex(value => value.Id == id); if (num < 0) { SheerResponse.Alert("Item not found.", new string[0]); } else if (string.IsNullOrEmpty(str2)) { SheerResponse.Alert("An item name cannot be blank.", new string[0]); SheerResponse.Eval("Sitecore.CollapsiblePanel.editName(\"{0}\")".FormatWith(new object[] { argument })); } else { variableValues[num].Name = str2; VariableValues = variableValues; } }
protected override void OnOK(object sender, EventArgs args) { Assert.ArgumentNotNull(sender, "sender"); Assert.ArgumentNotNull(args, "args"); ListString str = new ListString(WebUtil.GetFormValue("sortorder")); ListString strToDelete = new ListString(WebUtil.GetFormValue("deleteItem")); if (str.Count == 0 && strToDelete.Count == 0) { base.OnOK(sender, args); } else { if (strToDelete.Count > 0) { this.Delete(from i in strToDelete select ShortID.DecodeID(i)); } if (str.Count > 0) { this.Sort(from i in str select ShortID.DecodeID(i)); } SheerResponse.SetDialogValue("1"); base.OnOK(sender, args); } }
protected void SetComponent(ClientPipelineArgs args) { string str = args.Parameters["variationid"]; if (string.IsNullOrEmpty(str)) { SheerResponse.Alert("Item not found.", new string[0]); } else if ((Rendering == null) || (Layout == null)) { SheerResponse.Alert("An error ocurred.", new string[0]); } else if (!args.IsPostBack) { string placeholder = Rendering.Placeholder; Assert.IsNotNull(placeholder, "placeholder"); string str3 = Layout.ToXml(); var args2 = new GetPlaceholderRenderingsArgs(placeholder, str3, Client.ContentDatabase, ID.Parse(DeviceId)); args2.OmitNonEditableRenderings = true; args2.CustomData["showOpenProperties"] = false; CorePipeline.Run("getPlaceholderRenderings", args2); string dialogURL = args2.DialogURL; if (string.IsNullOrEmpty(dialogURL)) { SheerResponse.Alert("An error ocurred.", new string[0]); } else { SheerResponse.ShowModalDialog(dialogURL, "720px", "470px", string.Empty, true); args.WaitForPostBack(); } } else if (args.HasResult) { ID id = ShortID.DecodeID(str); List <VariableValueItemStub> variableValues = VariableValues; VariableValueItemStub stub = variableValues.Find(v => v.Id == id); if (stub != null) { string result; if (args.Result.IndexOf(',') >= 0) { result = args.Result.Split(new[] { ',' })[0]; } else { result = args.Result; } stub.ReplacementComponent = result; var output = new HtmlTextWriter(new StringWriter()); RenderComponentControls(output, stub); SheerResponse.SetOuterHtml(str + "_component", output.InnerWriter.ToString()); VariableValues = variableValues; } } }
protected void ResetVariationContent(string variationId) { Assert.ArgumentNotNull(variationId, "variationId"); ID id = ShortID.DecodeID(variationId); List <VariableValueItemStub> variableValues = VariableValues; VariableValueItemStub stub = variableValues.Find(v => v.Id == id); if (stub != null) { stub.Datasource = string.Empty; var output = new HtmlTextWriter(new StringWriter()); RenderContentControls(output, stub); SheerResponse.SetOuterHtml(variationId + "_content", output.InnerWriter.ToString()); VariableValues = variableValues; } }
protected void RemoveVariation(string variationId) { Assert.ArgumentNotNull(variationId, "variationId"); ID id = ShortID.DecodeID(variationId); List <VariableValueItemStub> variableValues = VariableValues; int index = variableValues.FindIndex(value => value.Id == id); if (index < 0) { SheerResponse.Alert("Item not found.", new string[0]); } else { variableValues.RemoveAt(index); SheerResponse.Remove(variationId); VariableValues = variableValues; SetControlsState(); } }
private static void RunGetPlaceholderRenderingsPipeline(NameValueCollection context, out List <Item> placeholderRenderings, out string dialogUrl) { Assert.IsNotNull(context, "context"); var deviceId = ShortID.DecodeID(WebUtil.GetFormValue("scDeviceID")); var placeholderRenderingsArgs = new GetPlaceholderRenderingsArgs(context["placeholder"], context["layout"], Client.ContentDatabase, deviceId) { OmitNonEditableRenderings = true }; if (!string.IsNullOrEmpty(context["renderingIds"])) { var list = context["renderingIds"].Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries).Select(ID.Parse).ToList(); placeholderRenderingsArgs.PredefinedRenderingIds = list; placeholderRenderingsArgs.Options.Title = "Select a replacement rendering"; placeholderRenderingsArgs.Options.Icon = "ApplicationsV2/32x32/replace2.png"; } CorePipeline.Run("getPlaceholderRenderings", placeholderRenderingsArgs); placeholderRenderings = placeholderRenderingsArgs.PlaceholderRenderings; dialogUrl = placeholderRenderingsArgs.DialogURL; }
protected void ChangeDisplayComponent(string variationId) { Assert.ArgumentNotNull(variationId, "variationId"); ID id = ShortID.DecodeID(variationId); List <VariableValueItemStub> variableValues = VariableValues; VariableValueItemStub stub = variableValues.Find(v => v.Id == id); if (stub != null) { stub.HideComponent = !stub.HideComponent; using (var writer = new HtmlTextWriter(new StringWriter())) { RenderContentControls(writer, stub); SheerResponse.SetOuterHtml(variationId + "_content", writer.InnerWriter.ToString()); } using (var writer2 = new HtmlTextWriter(new StringWriter())) { RenderComponentControls(writer2, stub); SheerResponse.SetOuterHtml(variationId + "_component", writer2.InnerWriter.ToString()); } VariableValues = variableValues; } }
/// <summary>Gets the tree view children.</summary> /// <returns>The get tree view children.</returns> /// <contract> /// <ensures condition="not null" /> /// </contract> private static string GetTreeViewChildren() { var queryString1 = WebUtil.GetQueryString("id"); var queryString2 = WebUtil.GetQueryString("la"); if (string.IsNullOrEmpty(queryString1)) { return(string.Empty); } var language = Language.Parse(queryString2); var folder = Client.ContentDatabase.GetItem(ShortID.DecodeID(queryString1), language); if (folder == null) { return(string.Empty); } var rootItem = folder.Database.GetRootItem(language); if (rootItem == null) { return(string.Empty); } return(GetTree(folder, rootItem).RenderChildNodes(folder.ID)); }
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 SetContent(ClientPipelineArgs args) { Predicate <VariableValueItemStub> match = null; Predicate <VariableValueItemStub> predicate2 = null; ID id; string str = args.Parameters["variationid"]; if (string.IsNullOrEmpty(str)) { SheerResponse.Alert("Item not found.", new string[0]); } else { id = ShortID.DecodeID(str); if (args.IsPostBack) { if (args.HasResult) { List <VariableValueItemStub> variableValues = VariableValues; if (match == null) { match = v => v.Id == id; } VariableValueItemStub stub = variableValues.Find(match); if (stub != null) { stub.Datasource = args.Result; var output = new HtmlTextWriter(new StringWriter()); RenderContentControls(output, stub); SheerResponse.SetOuterHtml(str + "_content", output.InnerWriter.ToString()); VariableValues = variableValues; } } } else { if (predicate2 == null) { predicate2 = v => v.Id == id; } VariableValueItemStub stub2 = VariableValues.Find(predicate2); if ((stub2 != null) && ((Rendering != null) && !string.IsNullOrEmpty(Rendering.ItemID))) { Item renderingItem = Client.ContentDatabase.GetItem(Rendering.ItemID); if (renderingItem == null) { SheerResponse.Alert("Item not found.", new string[0]); } else { //get current content item Item variantSourceItem = (ContextItemUri == null) ? null : Client.ContentDatabase.GetItem(ContextItemUri.ToDataUri()); if (variantSourceItem.IsNotNull()) { //use variant mapping functionality to find proper source MultiVariantProcessor processor = new MultiVariantProcessor(); IMultiVariantMapping mapping = processor.GetMapping(variantSourceItem.TemplateID.ToString(), Client.ContentDatabase); if (mapping != null) { //set mapping variantSourceItem = mapping.VariantSource(variantSourceItem); } } var args3 = new GetRenderingDatasourceArgs(renderingItem); args3.FallbackDatasourceRoots = new List <Item> { variantSourceItem }; args3.ContentLanguage = ((variantSourceItem != null) ? variantSourceItem.Language : null); args3.ContextItemPath = (variantSourceItem != null) ? variantSourceItem.Paths.FullPath : string.Empty; args3.ShowDialogIfDatasourceSetOnRenderingItem = true; args3.CurrentDatasource = (string.IsNullOrEmpty(stub2.Datasource) ? Rendering.Datasource : stub2.Datasource); GetRenderingDatasourceArgs args2 = args3; CorePipeline.Run("getRenderingDatasource", args2); if (string.IsNullOrEmpty(args2.DialogUrl)) { SheerResponse.Alert("An error ocurred.", new string[0]); } else { SheerResponse.ShowModalDialog(args2.DialogUrl, "460px", "460px", string.Empty, true); args.WaitForPostBack(); } } } } } }