protected override ListItem[] GetListItems() { ParameterCollection query = new ParameterCollection(); if (!ShowUnpublish) { query &= Parameter.Equal("State", ContentState.Published); } if (ListItemsBelowCurrentStartPageOnly) { var selection = new SelectionUtility(HttpContext.Current, Engine); ContentItem item = selection.SelectedItem; var startPage = Find.ClosestOf <IStartPage>(item); if (startPage == null) { return new ListItem[] { } } ; //No startpage found. Return empty list. if (startPage.VersionOf.HasValue) { startPage = startPage.VersionOf.Value; } query &= Parameter.Below(startPage); } if (LinkedType != null && LinkedType != typeof(ContentItem)) { query &= Parameter.TypeEqual(LinkedType); } if (ExcludedType != null) { query &= Parameter.TypeNotIn(Engine.Definitions.GetDefinitions().Where(d => ExcludedType.IsAssignableFrom(d.ItemType)).Select(d => d.Discriminator).ToArray()); } if (!Is(EditableItemSelectionFilter.Pages)) { query &= Parameter.IsNotNull("ZoneName"); } if (!Is(EditableItemSelectionFilter.Parts)) { query &= Parameter.IsNull("ZoneName"); } var items = Engine.Content.Search.Repository.Select(query, "ID", "Title"); var listItems = items.Select(row => new ListItem((string)row["Title"], row["ID"].ToString())).ToList(); if (Required) { listItems.Insert(0, new ListItem("- Select -", "0")); } return(listItems.ToArray()); }
protected override ListItem[] GetListItems() { ParameterCollection query = Parameter.Equal("State", ContentState.Published); if (LinkedType != null && LinkedType != typeof(ContentItem)) { query &= Parameter.TypeEqual(LinkedType); } if (ExcludedType != null) { query &= Parameter.TypeNotIn(Engine.Definitions.GetDefinitions().Where(d => ExcludedType.IsAssignableFrom(d.ItemType)).Select(d => d.Discriminator).ToArray()); } if (!Is(EditableItemSelectionFilter.Pages)) { query &= Parameter.IsNotNull("ZoneName"); } if (!Is(EditableItemSelectionFilter.Parts)) { query &= Parameter.IsNull("ZoneName"); } var items = Engine.Content.Search.Repository.Select(query, "ID", "Title"); return(items.Select(row => new ListItem((string)row["Title"], row["ID"].ToString())) .ToArray()); }