Ejemplo n.º 1
0
        public IEnumerable <LayoutTemplatePart> GetTemplates(ContentsOrder orderBy = ContentsOrder.Published)
        {
            var query = _contentManager
                        .Query <LayoutTemplatePart>("OSTemplate")
                        .ForVersion(VersionOptions.Latest)
                        .WithQueryHints(new QueryHints().ExpandParts <TitlePart>());

            switch (orderBy)
            {
            case ContentsOrder.Modified:
                query.OrderByDescending <CommonPartRecord>(cr => cr.ModifiedUtc);
                break;

            case ContentsOrder.Published:
                query.OrderByDescending <CommonPartRecord>(cr => cr.PublishedUtc);
                break;

            case ContentsOrder.Created:
                query.OrderByDescending <CommonPartRecord>(cr => cr.CreatedUtc);
                break;
            }
            return(query.List());
        }
Ejemplo n.º 2
0
        private IContentQuery <ContentItem> GetListContentItemQuery(int containerId, string contentType, ContentsOrder orderBy)
        {
            List <string> containableTypes = GetContainableTypes().Select(ctd => ctd.Name).ToList();

            if (containableTypes.Count == 0)
            {
                // Force the name to be matched against empty and return no items in the query
                containableTypes.Add(string.Empty);
            }

            var query = _contentManager.Query(VersionOptions.Latest, containableTypes.ToArray());

            if (!string.IsNullOrEmpty(contentType))
            {
                var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(contentType);
                if (contentTypeDefinition == null)
                {
                    return(null);
                }
                query = query.ForType(contentType);
            }

            query = containerId == 0
                ? query.Join <CommonPartRecord>().Where(cr => cr.Container == null)
                : query.Join <CommonPartRecord>().Where(cr => cr.Container.Id == containerId);
            switch (orderBy)
            {
            case ContentsOrder.Modified:
                query = query.OrderByDescending <CommonPartRecord>(cr => cr.ModifiedUtc);
                break;

            case ContentsOrder.Published:
                query = query.OrderByDescending <CommonPartRecord>(cr => cr.PublishedUtc);
                break;

            case ContentsOrder.Created:
                query = query.OrderByDescending <CommonPartRecord>(cr => cr.CreatedUtc);
                break;
            }

            return(query);
        }
Ejemplo n.º 3
0
        private IContentQuery<ContentItem> GetListContentItemQuery(int containerId, string contentType, ContentsOrder orderBy) {
            List<string> containableTypes = GetContainableTypes().Select(ctd => ctd.Name).ToList();
            if (containableTypes.Count == 0) {
                // Force the name to be matched against empty and return no items in the query
                containableTypes.Add(string.Empty);
            }

            var query = _contentManager.Query(VersionOptions.Latest, containableTypes.ToArray());
            
            if (!string.IsNullOrEmpty(contentType)) {
                var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(contentType);
                if (contentTypeDefinition == null) {
                    return null;
                }
                query = query.ForType(contentType);
            }

            query = containerId == 0
                ? query.Join<CommonPartRecord>().Where(cr => cr.Container == null)
                : query.Join<CommonPartRecord>().Where(cr => cr.Container.Id == containerId);
            switch (orderBy) {
                case ContentsOrder.Modified:
                    query = query.OrderByDescending<CommonPartRecord>(cr => cr.ModifiedUtc);
                    break;
                case ContentsOrder.Published:
                    query = query.OrderByDescending<CommonPartRecord>(cr => cr.PublishedUtc);
                    break;
                case ContentsOrder.Created:
                    query = query.OrderByDescending<CommonPartRecord>(cr => cr.CreatedUtc);
                    break;
            }

            return query;
        }
Ejemplo n.º 4
0
        private IContentQuery<ContentItem> GetListContentItemQuery(int containerId, string contentType, ContentsOrder orderBy)
        {
            var query = _contentManager.Query(VersionOptions.Latest, GetContainableTypes().Select(ctd => ctd.Name).ToArray());

            if (!string.IsNullOrEmpty(contentType)) {
                var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(contentType);
                if (contentTypeDefinition == null) {
                    return null;
                }
                query = query.ForType(contentType);
            }

            query = containerId == 0
                ? query.Join<CommonPartRecord>().Where(cr => cr.Container == null)
                : query.Join<CommonPartRecord>().Where(cr => cr.Container.Id == containerId);

            switch (orderBy) {
                case ContentsOrder.Modified:
                    query = query.OrderByDescending<CommonPartRecord, DateTime?>(cr => cr.ModifiedUtc);
                    break;
                case ContentsOrder.Published:
                    query = query.OrderByDescending<CommonPartRecord, DateTime?>(cr => cr.PublishedUtc);
                    break;
                case ContentsOrder.Created:
                    query = query.OrderByDescending<CommonPartRecord, DateTime?>(cr => cr.CreatedUtc);
                    break;
            }
            return query;
        }
Ejemplo n.º 5
0
        private IContentQuery <ContentItem> GetListContentItemQuery(int containerId, string contentType, ContentsOrder orderBy)
        {
            var query = _contentManager.Query(VersionOptions.Latest, GetContainableTypes().Select(ctd => ctd.Name).ToArray());

            if (!string.IsNullOrEmpty(contentType))
            {
                var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(contentType);
                if (contentTypeDefinition == null)
                {
                    return(null);
                }
                query = query.ForType(contentType);
            }

            query = containerId == 0
                ? query.Join <CommonPartRecord>().Where(cr => cr.Container == null)
                : query.Join <CommonPartRecord>().Where(cr => cr.Container.Id == containerId);

            switch (orderBy)
            {
            case ContentsOrder.Modified:
                query = query.OrderByDescending <CommonPartRecord, DateTime?>(cr => cr.ModifiedUtc);
                break;

            case ContentsOrder.Published:
                query = query.OrderByDescending <CommonPartRecord, DateTime?>(cr => cr.PublishedUtc);
                break;

            case ContentsOrder.Created:
                query = query.OrderByDescending <CommonPartRecord, DateTime?>(cr => cr.CreatedUtc);
                break;
            }
            return(query);
        }