// Methods public void Execute(XElement element, string name, UrlString parameters, string value) { Assert.ArgumentNotNull(element, "element"); Assert.ArgumentNotNull(name, "name"); Assert.ArgumentNotNull(parameters, "parameters"); Assert.ArgumentNotNull(value, "value"); SelectItemOptions options = new SelectItemOptions(); if (!string.IsNullOrEmpty(value)) { Item item = Client.ContentDatabase.GetItem(value); if (item != null) { options.SelectedItem = item; } } string str = parameters["root"]; if (!string.IsNullOrEmpty(str)) { Item item2 = Client.ContentDatabase.GetItem(str); if (item2 != null) { options.Root = item2; } } string str2 = parameters["selection"]; if (!string.IsNullOrEmpty(str2)) { options.IncludeTemplatesForSelection = SelectItemOptions.GetTemplateList(str2.Split(new char[] { '|' })); } string str3 = parameters["display"]; if (!string.IsNullOrEmpty(str3)) { options.IncludeTemplatesForDisplay = SelectItemOptions.GetTemplateList(str3.Split(new char[] { '|' })); } options.Title = "Select Item"; options.Text = "Select the item to use in this rule."; options.Icon = "People/16x16/cube_blue.png"; SheerResponse.ShowModalDialog(options.ToUrlString().ToString(), true); }
protected void AddItem(ClientPipelineArgs args) { if (args.IsPostBack) { if (args.HasResult) { SetModified(); LastSelectedItemID = args.Result; SheerResponse.Eval("window.frames['{0}_frame'].window.scVisualList.addItem('{1}');".FormatWith(ID, args.Result)); } } else { var source = new UrlString(StringUtil.GetString(Source, "/sitecore/media library")).Path; Item lastSelectedItem = null; if (!string.IsNullOrEmpty(LastSelectedItemID)) { lastSelectedItem = Client.ContentDatabase.GetItem(LastSelectedItemID); } if (source.Contains("/sitecore/media library")) { var options = new MediaBrowserOptions(); if (source.StartsWith("~")) { options.Root = Client.GetItemNotNull(ItemIDs.MediaLibraryRoot); options.SelectedItem = Client.GetItemNotNull(source.Substring(1)); } else { options.Root = Client.GetItemNotNull(source); } if (lastSelectedItem != null && lastSelectedItem.Parent.Paths.IsDescendantOf(options.Root)) { options.SelectedItem = lastSelectedItem.Parent; } SheerResponse.ShowModalDialog(options.ToUrlString().ToString(), true); } else { var options = new SelectItemOptions { Title = "Please Select an Item", Text = "Select an item to add", Icon = "Applications/32x32/star_green.png" }; if (source.StartsWith("~")) { options.Root = Client.GetItemNotNull(ItemIDs.ContentRoot); options.SelectedItem = Client.GetItemNotNull(source.Substring(1)); } else { options.Root = Client.GetItemNotNull(source); } if (lastSelectedItem != null && lastSelectedItem.Paths.IsDescendantOf(options.Root)) { options.SelectedItem = lastSelectedItem; } SheerResponse.ShowModalDialog(options.ToUrlString().ToString(), true); } args.WaitForPostBack(); } }