Beispiel #1
0
        private void AddTabs(Models.SimpleContentType docType, IContentType contentType)
        {
            if (docType.Tabs == null)
            {
                return;
            }

            foreach (var tab in docType.Tabs)
            {
                contentType.AddPropertyGroup(tab.Name);
                AddProperties(tab, contentType);
            }
        }
Beispiel #2
0
        private void CreateContentType(Models.SimpleContentType docType)
        {
            var contentType = GetContentType(docType);

            if (docType is ComposedContentType)
            {
                AddCompositions((ComposedContentType)docType, contentType);
            }

            AddTabs(docType, contentType);
            AddAllowedContentTypes(docType, contentType);
            AddTemplate(docType, contentType);

            _ContentTypeService.Save(contentType);
        }
Beispiel #3
0
        private IContentType GetContentType(Models.SimpleContentType docType)
        {
            var contentType = GetContentType(docType.Alias);

            if (contentType != null)
            {
                return(contentType);
            }

            return(new ContentType(GetContainerId(docType.ContainerName))
            {
                Name = docType.Name,
                Alias = docType.Alias,
                Description = docType.Description,
                Icon = docType.Icon,
                AllowedAsRoot = docType.AllowAtRoot
            });
        }
Beispiel #4
0
        private void AddAllowedContentTypes(Models.SimpleContentType docType, IContentType contentType)
        {
            if (docType.AllowedContentTypes == null)
            {
                return;
            }

            var sortOrder           = 0;
            var allowedContentTypes = new List <ContentTypeSort>();

            foreach (var alias in docType.AllowedContentTypes)
            {
                var allowedContentType = GetContentType(alias);
                allowedContentTypes.Add(new ContentTypeSort(allowedContentType.Id, sortOrder++));
            }

            contentType.AllowedContentTypes = allowedContentTypes;
        }
Beispiel #5
0
        private void AddTemplate(Models.SimpleContentType docType, IContentType contentType)
        {
            if (docType.Template == null)
            {
                return;
            }

            var template = _FileService.GetTemplate(docType.Template.Alias);

            if (template == null)
            {
                template = new Template(docType.Template.Name, docType.Template.Alias)
                {
                    Content = docType.Template.Html
                };

                _FileService.SaveTemplate(template);
            }

            contentType.AllowedTemplates = new List <ITemplate> {
                template
            };
            contentType.SetDefaultTemplate(template);
        }