Exemplo n.º 1
0
        public static void SortNodes(TreeNodeCollection nodes)
        {
            List <TreeNode> dirs  = new List <TreeNode>();
            List <TreeNode> files = new List <TreeNode>();

            foreach (TreeNode n in nodes)
            {
                if ((n.Tag as ProjectItem).IsDir)
                {
                    dirs.Add(n);
                }
                else
                {
                    files.Add(n);
                }
            }
            dirs.Sort(new Comparison <TreeNode>(delegate(TreeNode a, TreeNode b)
            {
                return(string.Compare((a.Tag as ProjectItem).Name, (b.Tag as ProjectItem).Name));
            }));
            files.Sort(new Comparison <TreeNode>(delegate(TreeNode a, TreeNode b)
            {
                return(string.Compare((a.Tag as ProjectItem).Name, (b.Tag as ProjectItem).Name));
            }));
            nodes.Clear();
            nodes.AddRange(dirs.ToArray());
            nodes.AddRange(files.ToArray());
        }
        static void FillNodes([NotNull] TreeNodeCollection nodes, [NotNull] string search, [NotNull] List <string> openedTypes, [NotNull] List <string> closedTypes, int maxItems, string separator)
        {
            if (openedTypes.Count > 0)
            {
                openedTypes = SearchUtil.FindAll(openedTypes, search);
            }
            TreeNode[] openedNodes;
            TreeNode[] closedNodes;
            if (maxItems > 0)
            {
                openedNodes = CreateClassNodes(search, openedTypes, maxItems);
                maxItems   -= openedTypes.Count;
                closedNodes = maxItems > 0 ? CreateClassNodes(search, SearchUtil.FindAll(closedTypes, search), maxItems) : new TreeNode[0];
            }
            else
            {
                openedNodes = CreateClassNodes(search, openedTypes);
                closedNodes = CreateClassNodes(search, SearchUtil.FindAll(closedTypes, search));
            }
            var hasOpenedMatches = openedNodes.Length > 0;
            var hasClosedMatches = closedNodes.Length > 0;

            if (hasOpenedMatches)
            {
                nodes.AddRange(openedNodes);
            }
            if (!string.IsNullOrEmpty(separator) && hasOpenedMatches && hasClosedMatches)
            {
                nodes.Add(separator);
            }
            if (hasClosedMatches)
            {
                nodes.AddRange(closedNodes);
            }
        }
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            if (!string.IsNullOrWhiteSpace(queryStrings.Get("startfolder")))
            {
                TreeNodeCollection tempTree = new TreeNodeCollection();

                var root = id == "-1" ? queryStrings.Get("startfolder") : id;
                if (id == "-1")
                {
                    var path     = IOHelper.MapPath("~/" + root.TrimStart('~', '/'));
                    var rootName = new DirectoryInfo(path).Name;
                    var rootNode = CreateTreeNode(root, "-1", queryStrings, rootName, "icon-folder", true);
                    tempTree.Add(rootNode);
                }
                else
                {
                    root = root.EnsureStartsWith("/");
                    tempTree.AddRange(AddFolders(root, queryStrings));
                    tempTree.AddRange(AddFiles(root, queryStrings));
                }
                return(tempTree);
            }

            return(AddFolders(id == "-1" ? "" : id, queryStrings));
        }
        protected override ActionResult <TreeNodeCollection> GetTreeNodes(string id, FormCollection queryStrings)
        {
            var nodes = new TreeNodeCollection();

            //get all blueprints
            var entities = _entityService.GetChildren(Constants.System.Root, UmbracoObjectTypes.DocumentBlueprint).ToArray();

            //check if we're rendering the root in which case we'll render the content types that have blueprints
            if (id == Constants.System.RootString)
            {
                //get all blueprint content types
                var contentTypeAliases = entities.Select(x => ((IContentEntitySlim)x).ContentTypeAlias).Distinct();
                //get the ids
                var contentTypeIds = _contentTypeService.GetAllContentTypeIds(contentTypeAliases.ToArray()).ToArray();

                //now get the entities ... it's a bit round about but still smaller queries than getting all document types
                var docTypeEntities = contentTypeIds.Length == 0
                    ? new IEntitySlim[0]
                    : _entityService.GetAll(UmbracoObjectTypes.DocumentType, contentTypeIds).ToArray();

                nodes.AddRange(docTypeEntities
                               .Select(entity =>
                {
                    var treeNode      = CreateTreeNode(entity, Constants.ObjectTypes.DocumentBlueprint, id, queryStrings, Constants.Icons.ContentType, true);
                    treeNode.Path     = $"-1,{entity.Id}";
                    treeNode.NodeType = "document-type-blueprints";
                    // TODO: This isn't the best way to ensure a no operation process for clicking a node but it works for now.
                    treeNode.AdditionalData["jsClickCallback"] = "javascript:void(0);";
                    return(treeNode);
                }));

                return(nodes);
            }

            if (!int.TryParse(id, NumberStyles.Integer, CultureInfo.InvariantCulture, out var intId))
            {
                return(nodes);
            }

            //Get the content type
            var ct = _contentTypeService.Get(intId);

            if (ct == null)
            {
                return(nodes);
            }

            var blueprintsForDocType = entities.Where(x => ct.Alias == ((IContentEntitySlim)x).ContentTypeAlias);

            nodes.AddRange(blueprintsForDocType
                           .Select(entity =>
            {
                var treeNode  = CreateTreeNode(entity, Constants.ObjectTypes.DocumentBlueprint, id, queryStrings, Constants.Icons.Blueprint, false);
                treeNode.Path = $"-1,{ct.Id},{entity.Id}";
                return(treeNode);
            }));

            return(nodes);
        }
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var intId = id.TryConvertTo <int>();

            if (intId == false)
            {
                throw new InvalidOperationException("Id must be an integer");
            }

            var nodes = new TreeNodeCollection();

            nodes.AddRange(
                Services.EntityService.GetChildren(intId.Result, UmbracoObjectTypes.DocumentTypeContainer)
                .OrderBy(entity => entity.Name)
                .Select(dt =>
            {
                var node      = CreateTreeNode(dt.Id.ToString(), id, queryStrings, dt.Name, "icon-folder", dt.HasChildren, "");
                node.Path     = dt.Path;
                node.NodeType = "container";
                // TODO: This isn't the best way to ensure a no operation process for clicking a node but it works for now.
                node.AdditionalData["jsClickCallback"] = "javascript:void(0);";
                return(node);
            }));

            //if the request is for folders only then just return
            if (queryStrings["foldersonly"].IsNullOrWhiteSpace() == false && queryStrings["foldersonly"] == "1")
            {
                return(nodes);
            }

            var children     = Services.EntityService.GetChildren(intId.Result, UmbracoObjectTypes.DocumentType).ToArray();
            var contentTypes = Services.ContentTypeService.GetAll(children.Select(c => c.Id).ToArray()).ToDictionary(c => c.Id);

            nodes.AddRange(
                children
                .OrderBy(entity => entity.Name)
                .Select(dt =>
            {
                // get the content type here so we can get the icon from it to use when we create the tree node
                // and we can enrich the result with content type data that's not available in the entity service output
                var contentType = contentTypes[dt.Id];

                // since 7.4+ child type creation is enabled by a config option. It defaults to on, but can be disabled if we decide to.
                // need this check to keep supporting sites where children have already been created.
                var hasChildren = dt.HasChildren;
                var node        = CreateTreeNode(dt, Constants.ObjectTypes.DocumentType, id, queryStrings, contentType?.Icon ?? Constants.Icons.ContentType, hasChildren);

                node.Path = dt.Path;

                // now we can enrich the result with content type data that's not available in the entity service output
                node.Alias = contentType.Alias;
                node.AdditionalData["isElement"] = contentType.IsElement;

                return(node);
            }));

            return(nodes);
        }
        protected virtual TreeNodeCollection PerformGetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var nodes = new TreeNodeCollection();

            var rootIdString    = Constants.System.Root.ToString(CultureInfo.InvariantCulture);
            var hasAccessToRoot = UserStartNodes.Contains(Constants.System.Root);

            var startNodeId = queryStrings.HasKey(TreeQueryStringParameters.StartNodeId)
                ? queryStrings.GetValue <string>(TreeQueryStringParameters.StartNodeId)
                : string.Empty;

            if (string.IsNullOrEmpty(startNodeId) == false && startNodeId != "undefined" && startNodeId != rootIdString)
            {
                // request has been made to render from a specific, non-root, start node
                id = startNodeId;

                // ensure that the user has access to that node, otherwise return the empty tree nodes collection
                // TODO: in the future we could return a validation statement so we can have some UI to notify the user they don't have access
                if (HasPathAccess(id, queryStrings) == false)
                {
                    Logger.Warn <ContentTreeControllerBase>("User {Username} does not have access to node with id {Id}", Security.CurrentUser.Username, id);
                    return(nodes);
                }

                // if the tree is rendered...
                // - in a dialog: render only the children of the specific start node, nothing to do
                // - in a section: if the current user's start nodes do not contain the root node, we need
                //   to include these start nodes in the tree too, to provide some context - i.e. change
                //   start node back to root node, and then GetChildEntities method will take care of the rest.
                if (IsDialog(queryStrings) == false && hasAccessToRoot == false)
                {
                    id = rootIdString;
                }
            }

            // get child entities - if id is root, but user's start nodes do not contain the
            // root node, this returns the start nodes instead of root's children
            var entities = GetChildEntities(id, queryStrings).ToList();

            nodes.AddRange(entities.Select(x => GetSingleTreeNodeWithAccessCheck(x, id, queryStrings)).Where(x => x != null));

            // if the user does not have access to the root node, what we have is the start nodes,
            // but to provide some context we also need to add their topmost nodes when they are not
            // topmost nodes themselves (level > 1).
            if (id == rootIdString && hasAccessToRoot == false)
            {
                var topNodeIds = entities.Where(x => x.Level > 1).Select(GetTopNodeId).Where(x => x != 0).Distinct().ToArray();
                if (topNodeIds.Length > 0)
                {
                    var topNodes = Services.EntityService.GetAll(UmbracoObjectType, topNodeIds.ToArray());
                    nodes.AddRange(topNodes.Select(x => GetSingleTreeNodeWithAccessCheck(x, id, queryStrings)).Where(x => x != null));
                }
            }

            return(nodes);
        }
Exemplo n.º 7
0
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var nodes = new TreeNodeCollection();

            //get all blueprints
            var entities = Services.EntityService.GetChildren(Constants.System.Root, UmbracoObjectTypes.DocumentBlueprint).ToArray();

            //check if we're rendering the root in which case we'll render the content types that have blueprints
            if (id == Constants.System.Root.ToInvariantString())
            {
                //get all blueprint content types
                var contentTypeAliases = entities.Select(x => ((UmbracoEntity)x).ContentTypeAlias).Distinct();
                //get the ids
                var contentTypeIds = Services.ContentTypeService.GetAllContentTypeIds(contentTypeAliases.ToArray()).ToArray();

                //now get the entities ... it's a bit round about but still smaller queries than getting all document types
                var docTypeEntities = contentTypeIds.Length == 0
                    ? new IUmbracoEntity[0]
                    : Services.EntityService.GetAll(UmbracoObjectTypes.DocumentType, contentTypeIds).ToArray();

                nodes.AddRange(docTypeEntities
                               .Select(entity =>
                {
                    var treeNode      = CreateTreeNode(entity, Constants.ObjectTypes.DocumentBlueprintGuid, id, queryStrings, "icon-item-arrangement", true);
                    treeNode.Path     = string.Format("-1,{0}", entity.Id);
                    treeNode.NodeType = "document-type-blueprints";
                    //TODO: This isn't the best way to ensure a noop process for clicking a node but it works for now.
                    treeNode.AdditionalData["jsClickCallback"] = "javascript:void(0);";
                    return(treeNode);
                }));

                return(nodes);
            }
            else
            {
                var intId = id.TryConvertTo <int>();
                //Get the content type
                var ct = Services.ContentTypeService.GetContentType(intId.Result);
                if (ct == null)
                {
                    return(nodes);
                }

                var blueprintsForDocType = entities.Where(x => ct.Alias == ((UmbracoEntity)x).ContentTypeAlias);
                nodes.AddRange(blueprintsForDocType
                               .Select(entity =>
                {
                    var treeNode  = CreateTreeNode(entity, Constants.ObjectTypes.DocumentBlueprintGuid, id, queryStrings, "icon-blueprint", false);
                    treeNode.Path = string.Format("-1,{0},{1}", ct.Id, entity.Id);
                    return(treeNode);
                }));
            }

            return(nodes);
        }
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var nodes = new TreeNodeCollection();

            if (id == Constants.System.Root.ToInvariantString())
            {
                //list out all the letters
                for (var i = 97; i < 123; i++)
                {
                    var charString = ((char) i).ToString(CultureInfo.InvariantCulture);
                    var folder = CreateTreeNode(charString, id, queryStrings, charString, "icon-folder-close", true);
                    folder.NodeType = "member-folder";
                    nodes.Add(folder);
                }
                //list out 'Others' if the membership provider is umbraco
                if (Membership.Provider.Name == Constants.Conventions.Member.UmbracoMemberProviderName)
                {
                    var folder = CreateTreeNode("others", id, queryStrings, "Others", "icon-folder-close", true);
                    folder.NodeType = "member-folder";
                    nodes.Add(folder);
                }
            }
            else
            {
                //if it is a letter
                if (id.Length == 1 && char.IsLower(id, 0))
                {
                    if (Membership.Provider.Name == Constants.Conventions.Member.UmbracoMemberProviderName)
                    {
                        //get the members from our member data layer
                        nodes.AddRange(
                            Member.getMemberFromFirstLetter(id.ToCharArray()[0])
                                        .Select(m => CreateTreeNode(m.UniqueId.ToString("N"), id, queryStrings, m.Text, "icon-user")));
                    }
                    else
                    {
                        //get the members from the provider
                        int total;
                        nodes.AddRange(
                            FindUsersByName(char.Parse(id)).Cast<MembershipUser>()
                                      .Select(m => CreateTreeNode(GetNodeIdForCustomProvider(m.ProviderUserKey), id, queryStrings, m.UserName, "icon-user")));
                    }
                }
                else if (id == "others")
                {
                    //others will only show up when in umbraco membership mode
                    nodes.AddRange(
                        Member.getAllOtherMembers()
                                    .Select(m => CreateTreeNode(m.Id.ToInvariantString(), id, queryStrings, m.Text, "icon-user")));
                }
            }
            return nodes;
        }
    protected override ActionResult <TreeNodeCollection> GetTreeNodes(string id, FormCollection queryStrings)
    {
        if (!int.TryParse(id, NumberStyles.Integer, CultureInfo.InvariantCulture, out var intId))
        {
            throw new InvalidOperationException("Id must be an integer");
        }

        var nodes = new TreeNodeCollection();

        //Folders first
        nodes.AddRange(
            _entityService.GetChildren(intId, UmbracoObjectTypes.DataTypeContainer)
            .OrderBy(entity => entity.Name)
            .Select(dt =>
        {
            TreeNode node = CreateTreeNode(dt, Constants.ObjectTypes.DataType, id, queryStrings,
                                           Constants.Icons.Folder, dt.HasChildren);
            node.Path     = dt.Path;
            node.NodeType = "container";
            // TODO: This isn't the best way to ensure a no operation process for clicking a node but it works for now.
            node.AdditionalData["jsClickCallback"] = "javascript:void(0);";
            return(node);
        }));

        //if the request is for folders only then just return
        if (queryStrings["foldersonly"].ToString().IsNullOrWhiteSpace() == false && queryStrings["foldersonly"] == "1")
        {
            return(nodes);
        }

        //System ListView nodes
        IEnumerable <int> systemListViewDataTypeIds = GetNonDeletableSystemListViewDataTypeIds();

        IEntitySlim[] children  = _entityService.GetChildren(intId, UmbracoObjectTypes.DataType).ToArray();
        var           dataTypes = _dataTypeService.GetAll(children.Select(c => c.Id).ToArray()).ToDictionary(dt => dt.Id);

        nodes.AddRange(
            children
            .OrderBy(entity => entity.Name)
            .Select(dt =>
        {
            IDataType dataType = dataTypes[dt.Id];
            TreeNode node      = CreateTreeNode(dt.Id.ToInvariantString(), id, queryStrings, dt.Name,
                                                dataType.Editor?.Icon, false);
            node.Path = dt.Path;
            return(node);
        })
            );

        return(nodes);
    }
Exemplo n.º 10
0
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var intId = id.TryConvertTo <int>();

            if (intId == false)
            {
                throw new InvalidOperationException("Id must be an integer");
            }

            var nodes = new TreeNodeCollection();

            //Folders first
            nodes.AddRange(
                Services.EntityService.GetChildren(intId.Result, UmbracoObjectTypes.DataTypeContainer)
                .OrderBy(entity => entity.Name)
                .Select(dt =>
            {
                var node      = CreateTreeNode(dt, Constants.ObjectTypes.DataType, id, queryStrings, "icon-folder", dt.HasChildren);
                node.Path     = dt.Path;
                node.NodeType = "container";
                // TODO: This isn't the best way to ensure a no operation process for clicking a node but it works for now.
                node.AdditionalData["jsClickCallback"] = "javascript:void(0);";
                return(node);
            }));

            //if the request is for folders only then just return
            if (queryStrings["foldersonly"].IsNullOrWhiteSpace() == false && queryStrings["foldersonly"] == "1")
            {
                return(nodes);
            }

            //System ListView nodes
            var systemListViewDataTypeIds = GetNonDeletableSystemListViewDataTypeIds();

            var children  = Services.EntityService.GetChildren(intId.Result, UmbracoObjectTypes.DataType).ToArray();
            var dataTypes = Services.DataTypeService.GetAll(children.Select(c => c.Id).ToArray()).ToDictionary(dt => dt.Id);

            nodes.AddRange(
                children
                .OrderBy(entity => entity.Name)
                .Select(dt =>
            {
                var dataType = dataTypes[dt.Id];
                var node     = CreateTreeNode(dt.Id.ToInvariantString(), id, queryStrings, dt.Name, dataType.Editor.Icon, false);
                node.Path    = dt.Path;
                return(node);
            })
                );

            return(nodes);
        }
Exemplo n.º 11
0
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var intId = id.TryConvertTo <int>();

            if (intId == false)
            {
                throw new InvalidOperationException("Id must be an integer");
            }

            var nodes = new TreeNodeCollection();

            //Folders first
            nodes.AddRange(
                Services.EntityService.GetChildren(intId.Result, UmbracoObjectTypes.DataTypeContainer)
                .OrderBy(entity => entity.Name)
                .Select(dt =>
            {
                var node      = CreateTreeNode(dt, Constants.ObjectTypes.DataTypeGuid, id, queryStrings, "icon-folder", dt.HasChildren());
                node.Path     = dt.Path;
                node.NodeType = "container";
                //TODO: This isn't the best way to ensure a noop process for clicking a node but it works for now.
                node.AdditionalData["jsClickCallback"] = "javascript:void(0);";
                return(node);
            }));

            //if the request is for folders only then just return
            if (queryStrings["foldersonly"].IsNullOrWhiteSpace() == false && queryStrings["foldersonly"] == "1")
            {
                return(nodes);
            }

            //Normal nodes
            var sysIds = GetSystemIds();

            nodes.AddRange(
                Services.EntityService.GetChildren(intId.Result, UmbracoObjectTypes.DataType)
                .OrderBy(entity => entity.Name)
                .Select(dt =>
            {
                var node  = CreateTreeNode(dt.Id.ToInvariantString(), id, queryStrings, dt.Name, "icon-autofill", false);
                node.Path = dt.Path;
                if (sysIds.Contains(dt.Id))
                {
                    node.Icon = "icon-thumbnail-list";
                }
                return(node);
            }));

            return(nodes);
        }
Exemplo n.º 12
0
    protected override ActionResult <TreeNodeCollection> GetTreeNodes(string id, FormCollection queryStrings)
    {
        if (!int.TryParse(id, NumberStyles.Integer, CultureInfo.InvariantCulture, out var intId))
        {
            throw new InvalidOperationException("Id must be an integer");
        }

        var nodes = new TreeNodeCollection();

        nodes.AddRange(
            _entityService.GetChildren(intId, UmbracoObjectTypes.MediaTypeContainer)
            .OrderBy(entity => entity.Name)
            .Select(dt =>
        {
            TreeNode node = CreateTreeNode(dt.Id.ToString(), id, queryStrings, dt.Name, Constants.Icons.Folder,
                                           dt.HasChildren, "");
            node.Path     = dt.Path;
            node.NodeType = "container";
            // TODO: This isn't the best way to ensure a no operation process for clicking a node but it works for now.
            node.AdditionalData["jsClickCallback"] = "javascript:void(0);";
            return(node);
        }));

        // if the request is for folders only then just return
        if (queryStrings["foldersonly"].ToString().IsNullOrWhiteSpace() == false &&
            queryStrings["foldersonly"].ToString() == "1")
        {
            return(nodes);
        }

        IEnumerable <IMediaType> mediaTypes = _mediaTypeService.GetAll();

        nodes.AddRange(
            _entityService.GetChildren(intId, UmbracoObjectTypes.MediaType)
            .OrderBy(entity => entity.Name)
            .Select(dt =>
        {
            // since 7.4+ child type creation is enabled by a config option. It defaults to on, but can be disabled if we decide to.
            // need this check to keep supporting sites where children have already been created.
            var hasChildren = dt.HasChildren;
            IMediaType?mt   = mediaTypes.FirstOrDefault(x => x.Id == dt.Id);
            TreeNode node   = CreateTreeNode(dt, Constants.ObjectTypes.MediaType, id, queryStrings,
                                             mt?.Icon ?? Constants.Icons.MediaType, hasChildren);

            node.Path = dt.Path;
            return(node);
        }));

        return(nodes);
    }
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var nodes = new TreeNodeCollection();

            string[] rootNodes = { "Maps", "Data" };
            var      ts        = Services.TextService;

            if (id == Constants.System.Root.ToInvariantString())
            {
                foreach (var rootNode in rootNodes)
                {
                    var icon  = "icon-map";
                    var title = ts.Localize("ncmb/maps");
                    if (rootNode == "Data")
                    {
                        icon  = "icon-settings";
                        title = ts.Localize("ncmb/data");
                    }

                    var hasChildren = false;
                    if (rootNode == "Maps")
                    {
                        var mapsItems = Db.ExecuteScalar <int>("SELECT COUNT(Id) FROM " + StaticHelper.GetMapsTableName());
                        hasChildren = mapsItems > 0;
                    }
                    else if (rootNode == "Data")
                    {
                        var dataItems = Db.ExecuteScalar <int>("SELECT COUNT(Id) FROM " + StaticHelper.GetDataTableName());
                        hasChildren = dataItems > 0;
                    }


                    var node = CreateTreeNode(rootNode, "-1", queryStrings, title, icon, hasChildren);

                    nodes.Add(node);
                }
            }
            else if (id == rootNodes[0])
            {
                var mapsItems = Db.Query <NovicellMapBuilderMapsModel>("SELECT * FROM " + StaticHelper.GetMapsTableName()).ToList();
                nodes.AddRange(mapsItems.Select(item => CreateTreeNode("map-" + item.Id.ToString(), rootNodes[0], queryStrings, item.Name, "icon-map-marker")));
            }
            else if (id == rootNodes[1])
            {
                var dataItems = Db.Query <NovicellMapBuilderDataModel>("SELECT * FROM " + StaticHelper.GetDataTableName()).ToList();
                nodes.AddRange(dataItems.Select(item => CreateTreeNode("data-" + item.Id.ToString(), rootNodes[1], queryStrings, item.Name, "icon-server-alt")));
            }

            return(nodes);
        }
Exemplo n.º 14
0
        private void ExpandTreeNodes(TreeNodeCollection nodes, string dir)
        {
            var r = pvf.ExpandPath(new ExpandPathRequest()
            {
                Path = dir
            });

            var listfiles = r.Infos.Where(p => p.Fileid >= 0).Select(p => new TreeNode()
            {
                Text = p.Name,
                Name = $"{dir}/{p.Name}",
                Tag  = p.Fileid
            }).ToArray();
            var list = r.Infos.Where(p => p.Fileid < 0).Select(p => new TreeNode()
            {
                Text = p.Name,
                Name = $"{dir}/{p.Name}",
                Tag  = p.Fileid,
            }).ToArray();

            foreach (var item in list)
            {
                item.Nodes.Add(new TreeNode()); //空Item用于显示+号,展开前要移除此项
            }

            if (list.Length == 0 && listfiles.Length != 0)
            {
                //只有文件
                nodes.AddRange(listfiles);  //文件直接添加
            }
            else if (list.Length != 0 && listfiles.Length == 0)
            {
                //只有目录
                nodes.AddRange(list);
            }
            else if (list.Length != 0 && listfiles.Length != 0)
            {
                //有文件有目录
                nodes.Add(new TreeNode("/", listfiles)
                {
                    Tag = -2, Name = dir
                });                                                                 //文件放入/,并且路径设置为与父节点相同
                nodes.AddRange(list);
            }
            else
            {
                //没有文件和目录,不会发生这情况
            }
        }
 static void FillNodes([NotNull] TreeNodeCollection nodes, [NotNull] ICollection <string> types)
 {
     if (types.Count > 0)
     {
         nodes.AddRange(types.Select(it => NodeFactory.CreateTreeNode(TypeToClassModel[it])).ToArray());
     }
 }
        /// <summary>
        /// Called by the ASP.NET MVC framework after the action method executes.
        /// </summary>
        /// <param name="filterContext">The filter context.</param>
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            base.OnActionExecuted(filterContext);

            if (filterContext.Result is RebelTreeResult)
            {
                var treeResult = (RebelTreeResult)filterContext.Result;

                var nodeCollection = new TreeNodeCollection();
                nodeCollection.AddRange(treeResult.NodeCollection);

                foreach (var node in nodeCollection)
                {
                    var menuActions = node.MenuActions.ToList();
                    foreach (var menuAction in menuActions)
                    {
                        var attributes = menuAction.Metadata.ComponentType.GetCustomAttributes(typeof(RebelAuthorizeAttribute), true);
                        if (attributes.Length > 0)
                        {
                            var authorized = attributes.Aggregate(false, (current, attribute) => current || ((RebelAuthorizeAttribute)attribute).IsAuthorized(filterContext.HttpContext, node.HiveId));
                            if (!authorized)
                                node.MenuActions.Remove(menuAction);
                        }
                    }
                }

                filterContext.Result = new RebelTreeResult(nodeCollection, filterContext.Controller.ControllerContext);
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// The method called to render the contents of the tree structure
        /// </summary>
        /// <param name="id"></param>
        /// <param name="queryStrings">
        /// All of the query string parameters passed from jsTree
        /// </param>
        /// <remarks>
        /// We are allowing an arbitrary number of query strings to be pased in so that developers are able to persist custom data from the front-end
        /// to the back end to be used in the query for model data.
        /// </remarks>
        protected override ActionResult <TreeNodeCollection> GetTreeNodes(string id, FormCollection queryStrings)
        {
            var nodes = new TreeNodeCollection();

            var found = id == Constants.System.RootString
                ? _fileService.GetTemplates(-1)
                : _fileService.GetTemplates(int.Parse(id, CultureInfo.InvariantCulture));

            if (found is not null)
            {
                nodes.AddRange(found.Select(template => CreateTreeNode(
                                                template.Id.ToString(CultureInfo.InvariantCulture),
                                                // TODO: Fix parent ID stuff for templates
                                                "-1",
                                                queryStrings,
                                                template.Name,
                                                template.IsMasterTemplate ? "icon-newspaper" : "icon-newspaper-alt",
                                                template.IsMasterTemplate,
                                                null,
                                                Udi.Create(ObjectTypes.GetUdiType(Constants.ObjectTypes.TemplateType), template.Key)
                                                )));
            }

            return(nodes);
        }
Exemplo n.º 18
0
    private void sortD(TreeNodeCollection nodes)
    {
        sortDic = addDic(nodes);
        sortDic.Sort(
            delegate(KeyValuePair <int, int> firstPair,
                     KeyValuePair <int, int> nextPair)
        {
            return(firstPair.Key >= nextPair.Key ? 1 : -1);
        }
            );
        int i = 0;

        TreeNode[] tmpnodes = new TreeNode[nodes.Count];
        //nodes.Add("End");
        foreach (KeyValuePair <int, int> kvp in sortDic)
        {
            //TreeNode tmpnode = nodes[kvp.Value];
            //tmpnodes.Add(tmpnode);
            tmpnodes[i] = nodes[kvp.Value];
            //nodes.Remove(nodes[kvp.Value]);
            //nodes.Add(nodes[kvp.Value]);
            i++;
            //nodes.RemoveAt(kvp.Value);
        }
        nodes.Clear();
        i = nodes.Count;
        //for (int j = 0; j < i / 2; j++)
        //{
        //    nodes.RemoveAt(0);
        //}
        nodes.AddRange(tmpnodes);
        //tmpnodes.Clear();
    }
        private TreeNodeCollection AddFolders(string parent, FormDataCollection queryStrings)
        {
            var pickerApiController = new FileSystemPickerApiController();

            var filter = queryStrings.Get("filter").Split(',').Select(a => a.Trim().EnsureStartsWith(".")).ToArray();

            var treeNodeCollection = new TreeNodeCollection();

            var startFolderName = queryStrings.Get("startfolder");

            var startFolderPath = startFolderName.TrimStart(new char[] { '~', '/' }).EnsureStartsWith("~/");

            IEnumerable <TreeNode> treeNodeList = pickerApiController.GetFolders(parent, filter)
                                                  .Select(dir => CreateTreeNode(String.Format("{0}{1}", startFolderName, dir.FullName.Replace(IOHelper.MapPath(startFolderPath), "").Replace("\\", "/")),
                                                                                parent, queryStrings, dir.Name,
                                                                                "icon-folder", true));

            //filter[0] == "." ?
            //            dir.EnumerateDirectories().Any() || pickerApiController.GetFiles(dir.FullName.Replace(IOHelper.MapPath("~"), "").Replace("\\", "/"), filter).Any() :
            //            pickerApiController.GetFiles(dir.FullName.Replace(IOHelper.MapPath("~"), "").Replace("\\", "/"), filter).Any())

            treeNodeCollection.AddRange(treeNodeList);


            return(treeNodeCollection);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Рекурсивная сортировка веток TreeView.
        /// </summary>
        /// <param name="rootNodes">Коллекция веток подлежащая сортировке</param>
        private static void SortTreeNodes(
            TreeNodeCollection rootNodes,
            IComparer <TreeNode> comparer)
        {
            int count = rootNodes.Count;

            if (count == 0)
            {
                return;
            }

            // Копируем содержимое коллекции подветок в массив,
            // сортируем этот массв, очищаем коллекцию и копируем
            // подвекти обратно в коллекцию.
            TreeNode[] nodeArray = new TreeNode[count];
            rootNodes.CopyTo(nodeArray, 0);
            Array.Sort <TreeNode>(nodeArray, comparer);
            rootNodes.Clear();
            rootNodes.AddRange(nodeArray);

            // Сортируем все подветки
            foreach (TreeNode node in nodeArray)
            {
                SortTreeNodes(node.Nodes, comparer);
            }
        }
Exemplo n.º 21
0
        public void AddNodes(TreeNodeCollection treeNodeCollection, NodeData data)
        {
            List <TreeNode> treeNodes = new List <TreeNode>();
            XmlElement      node      = findNodeChildren(data.NodeName) as XmlElement; // First look for <children>

            if (node == null)
            {
                node = findNodeGet(data.NodeName) as XmlElement;                // Then look for <get> (might be a search node)
            }
            if (node != null)
            {
                addNodes(treeNodes, data, node.ChildNodes);
            }
            treeNodeCollection.Clear();
            treeNodeCollection.AddRange(treeNodes.ToArray());
            data.Loaded = true;

            foreach (TreeNode treeNode in treeNodes)
            {
                NodeData nodeData = treeNode.Tag as NodeData;
                if (nodeData.Expand)
                {
                    treeNode.Expand();
                }
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// The get tree nodes.
        /// </summary>
        /// <param name="id">
        /// The id.
        /// </param>
        /// <param name="queryStrings">
        /// The query strings.
        /// </param>
        /// <returns>
        /// The <see cref="TreeNodeCollection"/>.
        /// </returns>
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var collection  = new TreeNodeCollection();
            var backoffice  = MerchelloConfiguration.Current.BackOffice;
            var currentTree = _rootTrees.FirstOrDefault(x => x.Id == id && x.Visible);
            var splitId     = new SplitRoutePath(id);

            collection.AddRange(
                currentTree != null
                    ? _collectiontrees.Contains(splitId.CollectionId) ?

                this.GetTreeNodesForCollections(splitId.CollectionId, MakeCollectionRoutePathId(splitId.CollectionId, splitId.CollectionKey), queryStrings)

                            :
                currentTree.SubTree.GetTrees().Where(x => x.Visible)
                .Select(tree => GetTreeNodeFromConfigurationElement(tree, queryStrings, currentTree))

                    :
                _collectiontrees.Contains(splitId.CollectionId) ?

                this.GetTreeNodesForCollections(splitId.CollectionId, MakeCollectionRoutePathId(splitId.CollectionId, splitId.CollectionKey), queryStrings, false) :

                backoffice.GetTrees().Where(x => x.Visible)
                .Select(tree => GetTreeNodeFromConfigurationElement(tree, queryStrings)));

            return(collection);
        }
Exemplo n.º 23
0
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var nodes = new TreeNodeCollection();

            nodes.AddRange(GetTreeNodesFromService(id, queryStrings));
            return(nodes);
        }
Exemplo n.º 24
0
        private void AppendRoots(TreeNodeCollection nodes, ToolStripItemCollection items)
        {
            List <TreeNode> list = new List <TreeNode>();

            foreach (ToolStripItem item in items)
            {
                ToolStripMenuItem submenu = item as ToolStripMenuItem;

                if (submenu != null)
                {
                    TreeNode node = new TreeNode();
                    node.Text       = submenu.Text;
                    node.Tag        = submenu;
                    node.ImageIndex = node.SelectedImageIndex = submenu.HasDropDownItems ? 0 : 1;

                    if (submenu.HasDropDownItems)
                    {
                        node.Nodes.Add(new TreeNode("dummy"));
                    }

                    list.Add(node);
                }
            }

            nodes.AddRange(list.ToArray());
        }
 /// <summary>
 /// Gets the tree nodes for the given id
 /// </summary>
 /// <param name="id"></param>
 /// <param name="queryStrings"></param>
 /// <returns></returns>
 /// <remarks>
 /// If the content item is a container node then we will not return anything
 /// </remarks>
 protected override TreeNodeCollection PerformGetTreeNodes(string id, FormDataCollection queryStrings)
 {
     var nodes = new TreeNodeCollection();
     var entities = GetChildEntities(id);
     nodes.AddRange(entities.Select(entity => GetSingleTreeNode(entity, id, queryStrings)).Where(node => node != null));            
     return nodes;
 }
 /// <summary>Refreshes the specified nodes.</summary>
 /// <param name="nodes">The nodes.</param>
 private void RefreshNodes(TreeNodeCollection nodes)
 {
     TreeNode[] dest = new TreeNode[nodes.Count];
     nodes.CopyTo(dest, 0);
     nodes.Clear();
     nodes.AddRange(dest);
 }
Exemplo n.º 27
0
        /// <summary>
        /// </summary>
        /// <exception cref="T:System.ArgumentNullException">
        /// <paramref name="collectionToSort"/> is <see langword="null"/>.
        /// <paramref name="comparerToUse"/> is <see langword="null"/>.
        /// </exception>
        public void Sort <T>(TreeNodeCollection collectionToSort, IComparer <T> comparerToUse) where T : TreeNode
        {
            if (collectionToSort == null)
            {
                throw new ArgumentNullException("collectionToSort");
            }

            if (comparerToUse == null)
            {
                throw new ArgumentNullException("comparerToUse");
            }

            int nodesCount = collectionToSort.Count;

            if (nodesCount == 0)
            {
                return;
            }

            T[] nodes = new T[nodesCount];

            for (int i = 0; i < nodesCount; i++)
            {
                nodes[i] = (T)collectionToSort[i];
            }

            Array.Sort <T>(nodes, comparerToUse);
            collectionToSort.Clear();
            collectionToSort.AddRange(nodes);

            foreach (T treeNode in nodes)
            {
                this.Sort(treeNode.Nodes, comparerToUse);
            }
        }
Exemplo n.º 28
0
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var nodes = new TreeNodeCollection();

            if (id == Constants.System.Root.ToInvariantString())
            {
                nodes.Add(
                    CreateTreeNode(Constants.Conventions.MemberTypes.AllMembersListId, id, queryStrings, Services.TextService.Localize("member/allMembers"), "icon-users", true,
                                   queryStrings.GetValue <string>("application") + TreeAlias.EnsureStartsWith('/') + "/list/" + Constants.Conventions.MemberTypes.AllMembersListId));

                if (_isUmbracoProvider)
                {
                    nodes.AddRange(Services.MemberTypeService.GetAll()
                                   .Select(memberType =>
                                           CreateTreeNode(memberType.Alias, id, queryStrings, memberType.Name, "icon-users", true,
                                                          queryStrings.GetValue <string>("application") + TreeAlias.EnsureStartsWith('/') + "/list/" + memberType.Alias)));
                }
            }

            //There is no menu for any of these nodes
            nodes.ForEach(x => x.MenuUrl = null);
            //All nodes are containers
            nodes.ForEach(x => x.AdditionalData.Add("isContainer", true));

            return(nodes);
        }
Exemplo n.º 29
0
        /// <summary>
        /// Called by the ASP.NET MVC framework after the action method executes.
        /// </summary>
        /// <param name="filterContext">The filter context.</param>
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            base.OnActionExecuted(filterContext);

            if (filterContext.Result is UmbracoTreeResult)
            {
                var treeResult = (UmbracoTreeResult)filterContext.Result;

                var nodeCollection = new TreeNodeCollection();
                nodeCollection.AddRange(treeResult.NodeCollection);

                foreach (var node in nodeCollection)
                {
                    var menuActions = node.MenuActions.ToList();
                    foreach (var menuAction in menuActions)
                    {
                        var attributes = menuAction.Metadata.ComponentType.GetCustomAttributes(typeof(UmbracoAuthorizeAttribute), true);
                        if (attributes.Length > 0)
                        {
                            var authorized = attributes.Aggregate(false, (current, attribute) => current || ((UmbracoAuthorizeAttribute)attribute).IsAuthorized(filterContext.HttpContext, node.HiveId));
                            if (!authorized)
                            {
                                node.MenuActions.Remove(menuAction);
                            }
                        }
                    }
                }

                filterContext.Result = new UmbracoTreeResult(nodeCollection, filterContext.Controller.ControllerContext);
            }
        }
Exemplo n.º 30
0
        /// <summary>
        /// The method called to render the contents of the tree structure
        /// </summary>
        /// <param name="id">The id of the tree item</param>
        /// <param name="queryStrings">
        /// All of the query string parameters passed from jsTree
        /// </param>
        /// <remarks>
        /// We are allowing an arbitrary number of query strings to be passed in so that developers are able to persist custom data from the front-end
        /// to the back end to be used in the query for model data.
        /// </remarks>
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var intId = id.TryConvertTo <int>();

            if (intId == false)
            {
                throw new InvalidOperationException("Id must be an integer");
            }

            var nodes = new TreeNodeCollection();

            Func <IDictionaryItem, string> ItemSort() => item => item.ItemKey;

            if (id == Constants.System.RootString)
            {
                nodes.AddRange(
                    Services.LocalizationService.GetRootDictionaryItems().OrderBy(ItemSort()).Select(
                        x => CreateTreeNode(
                            x.Id.ToInvariantString(),
                            id,
                            queryStrings,
                            x.ItemKey,
                            Constants.Icons.Dictionary,
                            Services.LocalizationService.GetDictionaryItemChildren(x.Key).Any())));
            }
            else
            {
                // maybe we should use the guid as URL param to avoid the extra call for getting dictionary item
                var parentDictionary = Services.LocalizationService.GetDictionaryItemById(intId.Result);
                if (parentDictionary == null)
                {
                    return(nodes);
                }

                nodes.AddRange(Services.LocalizationService.GetDictionaryItemChildren(parentDictionary.Key).ToList().OrderBy(ItemSort()).Select(
                                   x => CreateTreeNode(
                                       x.Id.ToInvariantString(),
                                       id,
                                       queryStrings,
                                       x.ItemKey,
                                       Constants.Icons.Dictionary,
                                       Services.LocalizationService.GetDictionaryItemChildren(x.Key).Any())));
            }

            return(nodes);
        }
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var nodes = new TreeNodeCollection();

            nodes.AddRange(_getNodes(id, queryStrings));

            return nodes;
        }
Exemplo n.º 32
0
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var nodes = new TreeNodeCollection();

            nodes.AddRange(_repository.GetAll().Select(contactForm => CreateTreeNode(contactForm.Id.ToString(), "-1", queryStrings, contactForm.Name)));

            return(nodes);
        }
Exemplo n.º 33
0
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var intId = id.TryConvertTo <int>();

            if (intId == false)
            {
                throw new InvalidOperationException("Id must be an integer");
            }

            var nodes = new TreeNodeCollection();

            nodes.AddRange(
                Services.EntityService.GetChildren(intId.Result, UmbracoObjectTypes.DocumentTypeContainer)
                .OrderBy(entity => entity.Name)
                .Select(dt =>
            {
                var node      = CreateTreeNode(dt.Id.ToString(), id, queryStrings, dt.Name, "icon-folder", dt.HasChildren, "");
                node.Path     = dt.Path;
                node.NodeType = "container";
                // TODO: This isn't the best way to ensure a no operation process for clicking a node but it works for now.
                node.AdditionalData["jsClickCallback"] = "javascript:void(0);";
                return(node);
            }));

            //if the request is for folders only then just return
            if (queryStrings["foldersonly"].IsNullOrWhiteSpace() == false && queryStrings["foldersonly"] == "1")
            {
                return(nodes);
            }

            nodes.AddRange(
                Services.EntityService.GetChildren(intId.Result, UmbracoObjectTypes.DocumentType)
                .OrderBy(entity => entity.Name)
                .Select(dt =>
            {
                // since 7.4+ child type creation is enabled by a config option. It defaults to on, but can be disabled if we decide to.
                // need this check to keep supporting sites where children have already been created.
                var hasChildren = dt.HasChildren;
                var node        = CreateTreeNode(dt, Constants.ObjectTypes.DocumentType, id, queryStrings, "icon-item-arrangement", hasChildren);

                node.Path = dt.Path;
                return(node);
            }));

            return(nodes);
        }
Exemplo n.º 34
0
 //The Sort method is called for each node level sorting the child nodes
 public void Sort(TreeNodeCollection collection)
 {
     TreeNode[] nodes = new TreeNode[collection.Count];
     collection.CopyTo(nodes, 0);
     Array.Sort(nodes, new TreeNodeComparer());
     collection.Clear();
     collection.AddRange(nodes);
 }
        private TreeNodeCollection AddFolders(string parent, FormDataCollection queryStrings)
        {
            var pickerApiController = new FilePickerApiController();

            var filter = queryStrings.Get("filter").Split(',').Select(a => a.Trim().EnsureStartsWith(".")).ToArray();

            var treeNodeCollection = new TreeNodeCollection();
            treeNodeCollection.AddRange(pickerApiController.GetFolders(parent,filter)
                .Select(dir => CreateTreeNode(dir.FullName.Replace(IOHelper.MapPath("~"), "").Replace("\\", "/"),
                    "~/" + parent, queryStrings, dir.Name,
                    "icon-folder", filter[0]=="." ? dir.EnumerateDirectories().Any() || pickerApiController.GetFiles(dir.FullName.Replace(IOHelper.MapPath("~"), "").Replace("\\", "/"), filter).Any() : pickerApiController.GetFiles(dir.FullName.Replace(IOHelper.MapPath("~"), "").Replace("\\", "/"), filter).Any())));

            return treeNodeCollection;
        }
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var nodes = new TreeNodeCollection();
            const string activeIcon = "icon-timer color-green";
            const string disabledIcon = "icon-timer color-red";

            var schedules = _schedulerApi.GetAllSchedules();
            nodes.AddRange(
                schedules.Select(s =>
                    CreateTreeNode(
                        s.Id.ToString(),
                        Constants.System.Root.ToString(),
                        queryStrings,
                        s.Name,
                        s.Disabled ? disabledIcon : activeIcon)));

            return nodes;
        }
        private TreeNodeCollection AddFiles(string folder, FormDataCollection queryStrings)
        {
            var pickerApiController = new FilePickerApiController();
            //var str = queryStrings.Get("startfolder");

            if (string.IsNullOrWhiteSpace(folder))
                return null;

            var filter = queryStrings.Get("filter").Split(',').Select(a=>a.Trim().EnsureStartsWith(".")).ToArray();

            var path = IOHelper.MapPath(folder);
            var rootPath = IOHelper.MapPath(queryStrings.Get("startfolder"));
            var treeNodeCollection = new TreeNodeCollection();
            treeNodeCollection.AddRange(pickerApiController.GetFiles(folder, filter)
                .Select(file => CreateTreeNode(file.FullName.Replace(rootPath, "").Replace("\\", "/"),
                    path, queryStrings, file.Name, "icon-document", false)));

            return treeNodeCollection;
        }
Exemplo n.º 38
0
        /// <summary>
        /// The get tree nodes.
        /// </summary>
        /// <param name="id">
        /// The id.
        /// </param>
        /// <param name="queryStrings">
        /// The query strings.
        /// </param>
        /// <returns>
        /// The <see cref="TreeNodeCollection"/>.
        /// </returns>
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var collection = new TreeNodeCollection();

            var backoffice = MerchelloConfiguration.Current.BackOffice;

            var rootTrees = backoffice.GetTrees().Where(x => x.Visible);

            var currentTree = rootTrees.FirstOrDefault(x => x.Id == id && x.Visible);

            collection.AddRange(
                currentTree != null
                    ? currentTree.SubTree.GetTrees().Where(x => x.Visible)
                            .Select(tree => GetTreeNodeFromConfigurationElement(tree, queryStrings, currentTree))
                    : backoffice.GetTrees().Where(x => x.Visible)
                            .Select(tree => GetTreeNodeFromConfigurationElement(tree, queryStrings)));

            return collection;
        }
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            //we only support one tree level for data types
            if (id != Constants.System.Root.ToInvariantString())
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            var collection = new TreeNodeCollection();
            collection.AddRange(
                Services.DataTypeService.GetAllDataTypeDefinitions()
                        .OrderBy(x => x.Name)
                        .Select(dt =>
                                CreateTreeNode(
                                    dt.Id.ToInvariantString(),
                                    id,
                                    queryStrings,
                                    dt.Name,
                                    "icon-autofill",
                                    false)));
            return collection;
        }
Exemplo n.º 40
0
        /// <summary>
        /// The get tree nodes.
        /// </summary>
        /// <param name="id">
        /// The id.
        /// </param>
        /// <param name="queryStrings">
        /// The query strings.
        /// </param>
        /// <returns>
        /// The <see cref="TreeNodeCollection"/>.
        /// </returns>
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var collection = new TreeNodeCollection();
            var backoffice = MerchelloConfiguration.Current.BackOffice;
            var currentTree = _rootTrees.FirstOrDefault(x => x.Id == id && x.Visible);
            var splitId = new SplitRoutePath(id);

            collection.AddRange(
                currentTree != null
                    ? currentTree.Id == "reports" ?
                        GetAttributeDefinedTrees(queryStrings) :

                        _collectiontrees.Contains(splitId.CollectionId) ?

                        this.GetTreeNodesForCollections(splitId.CollectionId, MakeCollectionRoutePathId(splitId.CollectionId, splitId.CollectionKey), queryStrings)

                            :
                        currentTree.SubTree.GetTrees().Where(x => x.Visible)
                            .Select(tree => GetTreeNodeFromConfigurationElement(tree, queryStrings, currentTree))

                    :
                    _collectiontrees.Contains(splitId.CollectionId) ?

                    this.GetTreeNodesForCollections(splitId.CollectionId, MakeCollectionRoutePathId(splitId.CollectionId, splitId.CollectionKey), queryStrings, false) :

                    backoffice.GetTrees().Where(x => x.Visible)
                            .Select(tree => GetTreeNodeFromConfigurationElement(tree, queryStrings)));

            return collection;
        }