Beispiel #1
0
        // no MapAll - take care
        private void Map(IContentType source, DocumentTypeDisplay target, MapperContext context)
        {
            MapTypeToDisplayBase <DocumentTypeDisplay, PropertyTypeDisplay>(source, target);

            target.AllowCultureVariant = source.VariesByCulture();
            target.AllowSegmentVariant = source.VariesBySegment();
            target.ContentApps         = _commonMapper.GetContentApps(source);

            //sync templates
            target.AllowedTemplates = context.MapEnumerable <ITemplate, EntityBasic>(source.AllowedTemplates);

            if (source.DefaultTemplate != null)
            {
                target.DefaultTemplate = context.Map <EntityBasic>(source.DefaultTemplate);
            }

            //default listview
            target.ListViewEditorName = Constants.Conventions.DataTypes.ListViewPrefix + "Content";

            if (string.IsNullOrEmpty(source.Alias))
            {
                return;
            }

            var name = Constants.Conventions.DataTypes.ListViewPrefix + source.Alias;

            if (_dataTypeService.GetDataType(name) != null)
            {
                target.ListViewEditorName = name;
            }
        }
Beispiel #2
0
        // no MapAll - take care
        private void Map(IContentType source, DocumentTypeDisplay target, MapperContext context)
        {
            MapTypeToDisplayBase <DocumentTypeDisplay, PropertyTypeDisplay>(source, target);

            if (source is IContentTypeWithHistoryCleanup sourceWithHistoryCleanup)
            {
                target.HistoryCleanup = new HistoryCleanupViewModel
                {
                    PreventCleanup = sourceWithHistoryCleanup.HistoryCleanup.PreventCleanup,
                    KeepAllVersionsNewerThanDays =
                        sourceWithHistoryCleanup.HistoryCleanup.KeepAllVersionsNewerThanDays,
                    KeepLatestVersionPerDayForDays =
                        sourceWithHistoryCleanup.HistoryCleanup.KeepLatestVersionPerDayForDays,
                    GlobalKeepAllVersionsNewerThanDays =
                        _contentSettings.ContentVersionCleanupPolicy.KeepAllVersionsNewerThanDays,
                    GlobalKeepLatestVersionPerDayForDays =
                        _contentSettings.ContentVersionCleanupPolicy.KeepLatestVersionPerDayForDays,
                    GlobalEnableCleanup = _contentSettings.ContentVersionCleanupPolicy.EnableCleanup
                };
            }


            target.AllowCultureVariant = source.VariesByCulture();
            target.AllowSegmentVariant = source.VariesBySegment();
            target.ContentApps         = _commonMapper.GetContentApps(source);

            //sync templates
            target.AllowedTemplates = context.MapEnumerable <ITemplate, EntityBasic>(source.AllowedTemplates);

            if (source.DefaultTemplate != null)
            {
                target.DefaultTemplate = context.Map <EntityBasic>(source.DefaultTemplate);
            }

            //default listview
            target.ListViewEditorName = Constants.Conventions.DataTypes.ListViewPrefix + "Content";

            if (string.IsNullOrEmpty(source.Alias))
            {
                return;
            }

            var name = Constants.Conventions.DataTypes.ListViewPrefix + source.Alias;

            if (_dataTypeService.GetDataType(name) != null)
            {
                target.ListViewEditorName = name;
            }
        }
        // Umbraco.Code.MapAll -Icon -Trashed -Alias
        private void Map(IDictionaryItem source, DictionaryDisplay target, MapperContext context)
        {
            target.Id       = source.Id;
            target.Key      = source.Key;
            target.Name     = source.ItemKey;
            target.ParentId = source.ParentId ?? Guid.Empty;
            target.Udi      = Udi.Create(Constants.UdiEntityType.DictionaryItem, source.Key);
            target.ContentApps.AddRange(_commonMapper.GetContentApps(source));

            // build up the path to make it possible to set active item in tree
            // TODO: check if there is a better way
            if (source.ParentId.HasValue)
            {
                var ids = new List <int> {
                    -1
                };
                var parentIds = new List <int>();
                GetParentId(source.ParentId.Value, _localizationService, parentIds);
                parentIds.Reverse();
                ids.AddRange(parentIds);
                ids.Add(source.Id);
                target.Path = string.Join(",", ids);
            }
            else
            {
                target.Path = "-1," + source.Id;
            }

            // add all languages and  the translations
            foreach (var lang in _localizationService.GetAllLanguages())
            {
                var langId      = lang.Id;
                var translation = source.Translations.FirstOrDefault(x => x.LanguageId == langId);

                target.Translations.Add(new DictionaryTranslationDisplay
                {
                    IsoCode     = lang.IsoCode,
                    DisplayName = lang.CultureInfo.DisplayName,
                    Translation = (translation != null) ? translation.Value : string.Empty,
                    LanguageId  = lang.Id
                });
            }
        }