public override ItemList GetItemsInZone(ContentItem parentItem, string zoneName) { if(zoneName.EndsWith("None")) return new ItemList(); if (zoneName.EndsWith("All")) return parentItem.GetChildren(new DelegateFilter(ci => ci.ZoneName != null)); return parentItem.GetChildren(zoneName); }
public override System.Collections.Generic.IEnumerable<ContentItem> GetParts(ContentItem belowParentItem, string inZoneNamed, string filteredForInterface) { if(inZoneNamed.EndsWith("None")) return new ItemList(); if (inZoneNamed.EndsWith("All")) return belowParentItem.GetChildren(new DelegateFilter(ci => ci.ZoneName != null)); return belowParentItem.GetChildren(inZoneNamed); }
public override ItemList GetItemsInZone(ContentItem parentItem, string zoneName) { if (zoneName.EndsWith("None")) { return(new ItemList()); } if (zoneName.EndsWith("All")) { return(parentItem.GetChildren(new DelegateFilter(ci => ci.ZoneName != null))); } return(parentItem.GetChildren(zoneName)); }
public override System.Collections.Generic.IEnumerable <ContentItem> GetParts(ContentItem belowParentItem, string inZoneNamed, string filteredForInterface) { if (inZoneNamed.EndsWith("None")) { return(new ItemList()); } if (inZoneNamed.EndsWith("All")) { return(belowParentItem.GetChildren(new DelegateFilter(ci => ci.ZoneName != null))); } return(belowParentItem.GetChildren(inZoneNamed)); }
protected virtual IEnumerable<ContentItem> GetChildren(ContentItem currentItem) { IEnumerable<ContentItem> children = currentItem.GetChildren(); if (Filter != null) children = Filter(children); return children; }
private void BuildControlHierarchy(ContentItem currentItem, ContentItem startPage) { if (currentItem == null) { currentItem = startPage; } ItemList children = currentItem.GetChildren(); if (children.Count > 0) { currentItem = children[0]; } IEnumerable <ContentItem> ancestors = GetAncestors(currentItem, startPage); ContentItem startingPoint = GetStartingPoint(); if (startingPoint != null) { ItemHierarchyNavigator navigator; if (BranchMode) { navigator = new ItemHierarchyNavigator(new BranchHierarchyBuilder(currentItem, startingPoint), Filters); } else { navigator = new ItemHierarchyNavigator(new TreeHierarchyBuilder(startingPoint, MaxLevels), Filters); } if (navigator.Current != null) { AddControlsRecursive(this, navigator, CurrentPage, ancestors); } } }
public IEnumerable <ContentItem> GetChildren(string path) { foreach (var pair in UploadFolderPaths) { if (pair.ParentPath.Equals(path, StringComparison.InvariantCultureIgnoreCase)) { yield return(CreateDirectory(pair)); } else if (path.StartsWith(pair.Path, StringComparison.InvariantCultureIgnoreCase)) { ContentItem dir = CreateDirectory(pair); var subdirPath = path.Substring(pair.Path.Length); if (subdirPath != "") { dir = dir.GetChild(subdirPath); } if (dir != null) { foreach (var child in dir.GetChildren(new NullFilter())) { yield return(child); } } } } }
public bool HasChildren(string path) { foreach (var pair in UploadFolderPaths) { if (pair.ParentPath.Equals(path, StringComparison.InvariantCultureIgnoreCase)) { return(true); } if (pair.Path.Equals(path, StringComparison.InvariantCultureIgnoreCase)) { return(true); } if (path.StartsWith(pair.Path, StringComparison.InvariantCultureIgnoreCase)) { ContentItem dir = CreateDirectory(pair); var remaining = path.Substring(pair.Path.Length); if (!string.IsNullOrEmpty(remaining)) { dir = dir.GetChild(remaining); } if (dir != null) { return(dir.GetChildren().Any()); } } } return(false); }
protected void AddReferencesRecursive(ContentItem current, ItemList referrers) { referrers.AddRange(Find.Items.Where.Detail().Eq(Item).Select()); foreach (ContentItem child in current.GetChildren()) { AddReferencesRecursive(child, referrers); } }
private void ApplyRolesRecursive(ContentItem item) { ApplyRoles(item); foreach (ContentItem child in item.GetChildren()) { ApplyRolesRecursive(child); } }
private static N2.Collections.ItemList GetChildren(ContentItem parentItem) { N2.Collections.ItemFilter trashFilter = new N2.Collections.TypeFilter(true, typeof(N2.Edit.Trash.TrashContainerItem)); N2.Collections.ItemFilter folderFilter = new N2.Collections.TypeFilter(true, typeof(FolderItem)); N2.Collections.ItemFilter imageFilter = new N2.Collections.TypeFilter(true, typeof(ImageItem)); return parentItem.GetChildren(trashFilter, folderFilter, imageFilter); }
private Collections.ItemList GetAllItems() { if (allItems == null && parentItem != null) { allItems = parentItem.GetChildren(); } return(allItems); }
public IEnumerable <ContentItem> Children(ContentItem item, ItemFilter filter = null) { if (item == null) { return(Enumerable.Empty <ContentItem>()); } return(item.GetChildren(filter ?? DefaultFilter())); }
public static IList <T> GetCrossLinks <T>(this ContentItem contentItem, string childZoneName) where T : ContentItem { var children = contentItem.GetChildren( new ZoneFilter(childZoneName), new AccessFilter(), new CrossLinkFilter <T>()); return(children.Select(c => (T)c.GetDetail("ContentItem")).ToList()); }
protected void AddReferencesRecursive(ContentItem current, ItemList referrers) { referrers.AddRange(Content.Search.Repository.Find(Parameter.Equal(null, Item).Detail())); //Find.Items.Where.Detail().Eq(Item).Select()); foreach (ContentItem child in current.GetChildren()) { AddReferencesRecursive(child, referrers); } }
/// <summary>Retrieves content items added to a zone of the parnet item.</summary> /// <param name="parentItem">The item whose items to get.</param> /// <param name="zoneName">The zone in which the items should be contained.</param> /// <returns>A list of items in the zone.</returns> public virtual ItemList GetItemsInZone(ContentItem parentItem, string zoneName) { if (parentItem == null) { return(new ItemList()); } return(parentItem.GetChildren(zoneName)); }
public override void UpdateEditor(ContentItem item, Control editor) { TextBox tb = (TextBox)editor; tb.Text = string.Empty; foreach (ContentItem child in item.GetChildren()) { tb.Text += child.Title + Environment.NewLine; } }
/// <summary>Children of a given item.</summary> /// <param name="parent"></param> /// <param name="filter"></param> /// <returns></returns> public IEnumerable <ContentItem> Children(ContentItem parent, ItemFilter filter = null) { if (parent == null) { return(Enumerable.Empty <ContentItem>()); } TryMasterVersion(ref parent); return(parent.GetChildren(filter ?? DefaultFilter)); }
/// <summary> /// Builds up the entire site tree recursively, adding items to the list /// </summary> /// <param name="list">This should be an empty list</param> /// <param name="parent">This should be called using the root item</param> private void RecurseTree(IList <ContentItem> list, ContentItem parent) { // TODO: add caching? foreach (var item in parent.GetChildren()) { if (item.Visible && item.IsPage) // TODO make this a setting { list.Add(item); RecurseTree(list, item); } } }
/// <summary>Gets the children of the given item for the given user interface.</summary> /// <param name="parent">The item whose children to get.</param> /// <param name="userInterface">The interface where the children are displayed.</param> /// <returns>An enumeration of the children.</returns> public virtual IEnumerable<ContentItem> GetChildren(ContentItem parent, string userInterface) { foreach (var child in parent.GetChildren(new AccessFilter(WebContext.User, Security))) { yield return child; } if (Interfaces.Managing == userInterface) { foreach (var child in NodeFactory.GetChildren(parent.Path)) { yield return child; } } }
/// <summary>Gets the children of the given item for the given user interface.</summary> /// <param name="parent">The item whose children to get.</param> /// <param name="userInterface">The interface where the children are displayed.</param> /// <returns>An enumeration of the children.</returns> public virtual IEnumerable <ContentItem> GetChildren(ContentItem parent, string userInterface) { foreach (var child in parent.GetChildren(new AccessFilter(WebContext.User, Security))) { yield return(child); } if (Interfaces.Managing == userInterface) { foreach (var child in NodeFactory.GetChildren(parent.Path)) { yield return(child); } } }
public override SiteMapNodeCollection GetChildNodes(SiteMapNode node) { SiteMapNodeCollection nodes = new SiteMapNodeCollection(); ContentItem item = (node != null) ? Context.Persister.Get(int.Parse(node.Key)) : null; // Add published nodes that are pages if (item != null) { foreach (ContentItem child in item.GetChildren(GetFilter())) { nodes.Add(Convert(child)); } } return(nodes); }
private static IEnumerable GetFiles(ContentItem contentItem, FileType fileType) { IEnumerable<ContentItem> files = contentItem.GetChildren().Pages().Published().Authorized(Operations.Read); switch (fileType) { case FileType.Image : files = files.Where(f => f is FileSystem.Images.Image); break; } return files.Select(ci => new { name = ci.Title, url = GetUrl(fileType, ci), imageUrl = GetImageUrl(ci) }); }
private void BuildControlHierarchy(ContentItem currentItem, ContentItem startPage) { if (currentItem == null) { currentItem = startPage; } ItemList children = currentItem.GetChildren(); if (children.Count > 0) { currentItem = children[0]; } IEnumerable <ContentItem> ancestors = GetAncestors(currentItem, startPage); ContentItem startingPoint = GetStartingPoint(); if (startingPoint != null) { HierarchyBuilder builder = null; if (BranchMode) { builder = new BranchHierarchyBuilder(currentItem, startingPoint); } else { builder = new TreeHierarchyBuilder(startingPoint, MaxLevels); } HierarchyNode <ContentItem> node = builder.Children(Filters).Build(); if (node.Current != null) { AddControlsRecursive(this, node, CurrentItem, ancestors); } } }
protected void AddReferencesRecursive(ContentItem current, List<ContentItem> referrers) { referrers.AddRange(Context.Finder.QueryItems().Where(ci => ci.Details.OfType<LinkProperty>().Any(ld => ld.LinkedItem == current))); foreach (ContentItem child in current.GetChildren()) AddReferencesRecursive(child, referrers); }
private IEnumerable<ContentItem> GetChildren(ContentItem ancestorItem) { return (from x in ancestorItem.GetChildren() where x.IsPage && (menuPart.MenuShowInvisible || x.Visible) && x.IsPublished() && x.ID != Content.Current.Page.ID select x).ToArray(); }
private static IEnumerable <StartPage> GetTranslations(ContentItem currentPage) { return(currentPage.GetChildren().OfType <StartPage>()); }
/// <summary> /// Builds up the entire site tree recursively, adding items to the list /// </summary> /// <param name="list">This should be an empty list</param> /// <param name="parent">This should be called using the root item</param> private static void RecurseTree(IList<ContentItem> list, ContentItem parent) { // TODO: add caching? foreach (var item in parent.GetChildren().Visible().Pages()) { list.Add(item); RecurseTree(list, item); } }
/// <summary>Returns true when an item has children.</summary> /// <param name="filter">The filter to apply.</param> /// <param name="parent">The item whose childrens existence is to be determined.</param> /// <returns>True when there are children.</returns> public virtual bool HasChildren(ContentItem parent, ItemFilter filter) { return parent.GetChildren(filter).Count > 0; }
IHierarchicalEnumerable IHierarchyData.GetChildren() { return(item.GetChildren()); }
public override IHierarchicalEnumerable Select() { return(parentItem != null?parentItem.GetChildren() : null); }
public IEnumerable<ContentItem> Children(ContentItem item, ItemFilter filter = null) { if (item == null) return Enumerable.Empty<ContentItem>(); return item.GetChildren(filter ?? DefaultFilter()); }
/// <summary>Retrieves content items added to a zone of the parnet item.</summary> /// <param name="parentItem">The item whose items to get.</param> /// <param name="zoneName">The zone in which the items should be contained.</param> /// <returns>A list of items in the zone.</returns> public virtual ItemList GetItemsInZone(ContentItem parentItem, string zoneName) { if(parentItem == null) return new ItemList(); return parentItem.GetChildren(zoneName); }
/// <summary> /// Builds up the entire site tree recursively, adding items to the list /// </summary> /// <param name="list">This should be an empty list</param> /// <param name="parent">This should be called using the root item</param> private void RecurseTree(IList<ContentItem> list, ContentItem parent) { // TODO: add caching? foreach (var item in parent.GetChildren()) { if (item.Visible && item.IsPage) // TODO make this a setting { list.Add(item); RecurseTree(list, item); } } }
private static bool SitemapRecursive(ContentItem contentItem, StringBuilder sb) { var childItems = contentItem.GetChildren().Visible(); bool foundSomething = false; StringBuilder sbInner = new StringBuilder(); if (childItems.Any()) { sbInner.Append("<ul>"); foreach (ContentItem childItem in childItems) { ISitemapAppearance appearance = childItem as ISitemapAppearance; //the appearance != null bit means that by default items won't show as links bool visible = childItem.Visible && (childItem.IsPage || (appearance != null && appearance.VisibleInSitemap)); if (visible) { sbInner.Append("<li>"); sbInner.AppendFormat("<a href=\"{0}\">{1}</a>", childItem.Url, childItem.Title); foundSomething = true; //something has been found on this tree path, but still possibility of dead ends, so start again! StringBuilder sbInnerFurther = new StringBuilder(); SitemapRecursive(childItem, sbInnerFurther); sbInner.Append(sbInnerFurther.ToString()); sbInner.Append("</li>"); } else { //nothing found yet, so don't add anything but keep checking - progress so far needs to be saved to the new stringbuilder StringBuilder sbInnerFurther = new StringBuilder(); sbInnerFurther.Append("<li>"); sbInnerFurther.Append(childItem.Title); //this will return if something is found further down the tree foundSomething = SitemapRecursive(childItem, sbInnerFurther); //only add this level if something was found! if (foundSomething) sbInner.Append(sbInnerFurther.ToString() + "</li>"); } } sbInner.Append("</ul>"); } //only append to the final string, if at somepoint a link has been hit, otherwise, you'll end up with loads of titles for no reason if (foundSomething) sb.Append(sbInner.ToString()); return foundSomething; }
/// <summary>Children of a given item.</summary> /// <param name="parent"></param> /// <param name="filter"></param> /// <returns></returns> public IEnumerable<ContentItem> Children(ContentItem parent, ItemFilter filter = null) { if (parent == null) return Enumerable.Empty<ContentItem>(); UseMasterVersion(ref parent); return parent.GetChildren(filter ?? DefaultFilter); }
protected virtual void UpdateParts(ContentItem target, ContentItem source) { List<string> keysTarget = new List<string>(target.GetChildren(new Collections.PartFilter()).Keys); List<string> keysSource = new List<string>(source.GetChildren(new Collections.PartFilter()).Keys); System.Collections.Generic.Dictionary<int, ContentItem> toCopy = new System.Collections.Generic.Dictionary<int, ContentItem>(); bool bDelete = true; bool bAdd = true; foreach (string keyTarget in keysTarget) { ContentItem childTarget = target.Children[keyTarget]; foreach (string keySource in keysSource) { ContentItem childSource = source.Children[keySource]; if (childSource.TranslationKey == childTarget.TranslationKey) { UpdateContentItem(childTarget, childSource); childTarget.SortOrder = childSource.SortOrder; bDelete = false; } } if (bDelete) { _persister.Delete(childTarget); //N2.Context.Current.Resolve<N2.Edit.Trash.ITrashHandler>().Purge(childTarget); } else bDelete = true; } keysTarget = new List<string>(target.GetChildren(new Collections.PartFilter()).Keys); foreach (string keySource in keysSource) { ContentItem childSource = source.Children[keySource]; foreach (string keyTarget in keysTarget) { ContentItem childTarget = target.Children[keyTarget]; if (childSource.TranslationKey == childTarget.TranslationKey) { bAdd = false; } } if (bAdd) { childSource.ID = 0; childSource.Parent = null; toCopy.Add(source.Children.IndexOf(childSource), childSource); } else bAdd = true; } ContentItem copyChild; foreach (int key in toCopy.Keys) { if (toCopy.TryGetValue(key, out copyChild)) { copyChild.InsertAt(target, key); } } }
private IEnumerable <ContentItem> GetChildren(ContentItem ancestorItem) { return((from x in ancestorItem.GetChildren() where x.IsPage && (menuPart.MenuShowInvisible || x.Visible) && x.IsPublished() && x.ID != Content.Current.Page.ID select x).ToArray()); }
/// <summary>Returns true when an item has children.</summary> /// <param name="filter">The filter to apply.</param> /// <param name="parent">The item whose childrens existence is to be determined.</param> /// <returns>True when there are children.</returns> public virtual bool HasChildren(ContentItem parent, ItemFilter filter) { return(parent.GetChildren(filter).Count > 0); }
private static IEnumerable<StartPage> GetTranslations(ContentItem currentPage) { return currentPage.GetChildren().OfType<StartPage>(); }
private void ApplyRulesRecursive(ContentItem item, IEnumerable<string> allowedOperations) { // Only apply the rules if the current user has permission to administer this item. if (Engine.SecurityManager.IsAuthorized(item, User, Operations.Administer)) ApplyRules(item, allowedOperations); // Apply recursively. ContentItem[] children = item.GetChildren().ToArray(); foreach (ContentItem child in children) ApplyRulesRecursive(child, allowedOperations); }
public IEnumerable<ContentItem> Children(ContentItem item, ItemFilter filter = null) { return item.GetChildren(filter ?? new NavigationFilter()); }
private static IEnumerable<WidgetContentItem> GetWidgets(ContentItem item) { return item.GetChildren<WidgetContentItem>().Authorized(Operations.Read); }