Пример #1
0
 public ContentBlocksMapper(IEntityService entityService,
                            IContentTypeService contentTypeService,
                            IDataTypeService dataTypeService,
                            IContentBlockDefinitionRepository definitionRepository)
     : base(entityService, contentTypeService, dataTypeService)
 {
     this.definitionRepository = definitionRepository;
 }
Пример #2
0
 public ExampleComponent(
     IContentBlockDefinitionRepository definitions,
     PropertyEditorCollection propertyEditors,
     IDataTypeService dataTypeService,
     IContentTypeService contentTypeService)
 {
     _definitions        = definitions;
     _propertyEditors    = propertyEditors;
     _dataTypeService    = dataTypeService;
     _contentTypeService = contentTypeService;
 }
Пример #3
0
        public ExampleComponent(
            IContentBlockDefinitionRepository definitions,
            PropertyEditorCollection propertyEditors,
            IDataTypeService dataTypeService,
            IContentTypeService contentTypeService,
            IContentBlockCategoryRepository categoryRepository,
            IContentBlocksPresetRepository presetRepository


            )
        {
            _definitions        = definitions;
            _propertyEditors    = propertyEditors;
            _dataTypeService    = dataTypeService;
            _contentTypeService = contentTypeService;
            _categoryRepository = categoryRepository;
            _presetRepository   = presetRepository;
        }
 public PerplexContentBlocksComponent(IContentBlockDefinitionRepository definitions)
 {
     _definitions = definitions;
     _demoContentBlockCategory = new DemoContentBlockCategory();
 }
Пример #5
0
 public ContentBlockRenderer(IContentBlockDefinitionRepository definitionRepository, IPreviewModeProvider previewModeProvider)
 {
     _definitionRepository = definitionRepository;
     _isPreview            = previewModeProvider.IsPreviewMode;
 }
 public PerplexComponent(IContentBlockDefinitionRepository definitions)
 {
     _definitions = definitions;
 }
Пример #7
0
 public ContentBlocksDefinitionApiController(IContentBlockDefinitionRepository definitionRepository, IContentBlockCategoryRepository categoryRepository)
 {
     _definitionRepository = definitionRepository;
     _categoryRepository   = categoryRepository;
 }
Пример #8
0
 public ContentBlocksConfiguration(IContentBlockDefinitionRepository definitions, IContentBlockCategoryRepository categories)
 {
     _definitions = definitions;
     _categories  = categories;
 }
        public override object ConvertIntermediateToObject(IPublishedElement owner, IPublishedPropertyType propertyType, PropertyCacheLevel referenceCacheLevel, object inter, bool preview)
        {
            ContentBlocksModelValue modelValue = _deserializer.Deserialize(inter?.ToString());

            if (modelValue == null)
            {
                return(Rendering.ContentBlocks.Empty);
            }

            var config = propertyType.DataType.ConfigurationAs <ContentBlocksConfiguration>();

            var header = config.Structure.HasFlag(Structure.Header)
                ? createViewModel(modelValue.Header)
                : null;

            var blocks = config.Structure.HasFlag(Structure.Blocks)
                ? modelValue.Blocks.Select(createViewModel).Where(rm => rm != null).ToList()
                : Enumerable.Empty <IContentBlockViewModel>();

            return(new Rendering.ContentBlocks
            {
                Header = header,
                Blocks = blocks
            });

            IContentBlockViewModel createViewModel(ContentBlockModelValue block)
            {
                if (block == null || block.IsDisabled)
                {
                    return(null);
                }

                IContentBlockDefinitionRepository definitionRepository = Current.Factory.GetInstance <IContentBlockDefinitionRepository>();

                if (definitionRepository == null)
                {
                    return(null);
                }

                IContentBlockDefinition definition = definitionRepository.GetById(block.DefinitionId);

                if (definition == null || definition.Layouts == null || definition.Layouts.Any() == false)
                {
                    return(null);
                }

                IContentBlockLayout layout = definition.Layouts.FirstOrDefault(l => l.Id == block.LayoutId);

                if (layout == null)
                {
                    return(null);
                }

                IPublishedElement content = _nestedContentSingleValueConverter.ConvertIntermediateToObject(owner, propertyType, referenceCacheLevel, block?.Content?.ToString(), preview) as IPublishedElement;

                if (content == null)
                {
                    return(null);
                }

                var contentType = content.GetType();
                var genericViewModelFactoryType = typeof(IContentBlockViewModelFactory <>).MakeGenericType(new[] { contentType });
                var viewModelFactory            = Current.Factory.GetInstance(genericViewModelFactoryType) as IContentBlockViewModelFactory;

                if (viewModelFactory == null)
                {
                    return(null);
                }

                return(viewModelFactory.Create(content, block.Id, block.DefinitionId, block.LayoutId));
            }
        }