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);
        }
예제 #2
0
        /// <summary>
        /// Gets a blueprint specified on a rule.
        /// </summary>
        /// <param name="rule">The rule in which the blueprint is specified</param>
        /// <returns>Null if the blueprint is not found</returns>
        private IContent GetBlueprint(AutoNodeRule rule)
        {
            if (string.IsNullOrEmpty(rule.Blueprint))
            {
                return(null);
            }
            var contentTypeId = _cts.GetAllContentTypeIds(new string[] { rule.DocTypeAliasToCreate }).FirstOrDefault();

            if (contentTypeId <= 0)
            {
                return(null);
            }
            var bps = _cs.GetBlueprintsForContentTypes(contentTypeId);

            if (bps == null || bps.Count() == 0)
            {
                return(null);
            }
            var bp = bps.Where(x => x.Name == rule.Blueprint).FirstOrDefault();

            return(bp);
        }
예제 #3
0
 public bool MembershipInstalled()
 {
     return(_contenttypeservice.GetAllContentTypeIds(new string[] { "forumAuthHolder" }).Any());
 }