Merge branch 'temp8' into temp8-contexts

This commit is contained in:
Shannon
2019-02-15 12:55:17 +11:00
314 changed files with 2474 additions and 6078 deletions

View File

@@ -88,6 +88,9 @@ namespace Umbraco.Web.Models
[DataMember(Name = "author")]
public string Author { get; set; }
[DataMember(Name = "contributors")]
public IList<string> Contributors { get; set; }
[DataMember(Name = "iconUrl")]
public string IconUrl { get; set; }
}

View File

@@ -1,7 +1,10 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using AutoMapper;
using Umbraco.Core.Models;
using Umbraco.Core.Models.ContentEditing;
using Umbraco.Core.Services;
using Umbraco.Web.ContentApps;
using Umbraco.Web.Models.ContentEditing;
@@ -12,15 +15,29 @@ namespace Umbraco.Web.Models.Mapping
internal class ContentAppResolver : IValueResolver<IContent, ContentItemDisplay, IEnumerable<ContentApp>>
{
private readonly ContentAppFactoryCollection _contentAppDefinitions;
private readonly ILocalizedTextService _localizedTextService;
public ContentAppResolver(ContentAppFactoryCollection contentAppDefinitions)
public ContentAppResolver(ContentAppFactoryCollection contentAppDefinitions, ILocalizedTextService localizedTextService)
{
_contentAppDefinitions = contentAppDefinitions;
_localizedTextService = localizedTextService;
}
public IEnumerable<ContentApp> Resolve(IContent source, ContentItemDisplay destination, IEnumerable<ContentApp> destMember, ResolutionContext context)
{
return _contentAppDefinitions.GetContentAppsFor(source);
var apps = _contentAppDefinitions.GetContentAppsFor(source).ToArray();
// localize content app names
foreach (var app in apps)
{
var localizedAppName = _localizedTextService.Localize($"apps/{app.Alias}");
if (localizedAppName.Equals($"[{app.Alias}]", StringComparison.OrdinalIgnoreCase) == false)
{
app.Name = localizedAppName;
}
}
return apps;
}
}
}

View File

@@ -24,7 +24,8 @@ namespace Umbraco.Web.Models.Mapping
IContentService contentService,
IContentTypeService contentTypeService,
IContentTypeBaseServiceProvider contentTypeBaseServiceProvider,
ILocalizationService localizationService)
ILocalizationService localizationService,
ILocalizedTextService localizedTextService)
{
// create, capture, cache
var contentOwnerResolver = new OwnerResolver<IContent>(userService);
@@ -32,7 +33,7 @@ namespace Umbraco.Web.Models.Mapping
var actionButtonsResolver = new ActionButtonsResolver(userService, contentService);
var childOfListViewResolver = new ContentChildOfListViewResolver(contentService, contentTypeService);
var contentTypeBasicResolver = new ContentTypeBasicResolver<IContent, ContentItemDisplay>(contentTypeBaseServiceProvider);
var allowedTemplatesResolver = new AllowedTemplatesResolver(contentTypeService);
var allowedTemplatesResolver = new AllowedTemplatesResolver(contentTypeService, localizedTextService);
var defaultTemplateResolver = new DefaultTemplateResolver();
var variantResolver = new ContentVariantResolver(localizationService);
var schedPublishReleaseDateResolver = new ScheduledPublishDateResolver(ContentScheduleAction.Release);
@@ -47,7 +48,7 @@ namespace Umbraco.Web.Models.Mapping
.ForMember(dest => dest.ContentApps, opt => opt.MapFrom(contentAppResolver))
.ForMember(dest => dest.Icon, opt => opt.MapFrom(src => src.ContentType.Icon))
.ForMember(dest => dest.ContentTypeAlias, opt => opt.MapFrom(src => src.ContentType.Alias))
.ForMember(dest => dest.ContentTypeName, opt => opt.MapFrom(src => src.ContentType.Name))
.ForMember(dest => dest.ContentTypeName, opt => opt.MapFrom(src => localizedTextService.UmbracoDictionaryTranslate(src.ContentType.Name)))
.ForMember(dest => dest.IsContainer, opt => opt.MapFrom(src => src.ContentType.IsContainer))
.ForMember(dest => dest.IsElement, opt => opt.MapFrom(src => src.ContentType.IsElement))
.ForMember(dest => dest.IsBlueprint, opt => opt.MapFrom(src => src.Blueprint))
@@ -146,10 +147,12 @@ namespace Umbraco.Web.Models.Mapping
private class AllowedTemplatesResolver : IValueResolver<IContent, ContentItemDisplay, IDictionary<string, string>>
{
private readonly IContentTypeService _contentTypeService;
private readonly ILocalizedTextService _localizedTextService;
public AllowedTemplatesResolver(IContentTypeService contentTypeService)
public AllowedTemplatesResolver(IContentTypeService contentTypeService, ILocalizedTextService localizedTextService)
{
_contentTypeService = contentTypeService;
_localizedTextService = localizedTextService;
}
public IDictionary<string, string> Resolve(IContent source, ContentItemDisplay destination, IDictionary<string, string> destMember, ResolutionContext context)
@@ -158,7 +161,7 @@ namespace Umbraco.Web.Models.Mapping
return contentType.AllowedTemplates
.Where(t => t.Alias.IsNullOrWhiteSpace() == false && t.Name.IsNullOrWhiteSpace() == false)
.ToDictionary(t => t.Alias, t => t.Name);
.ToDictionary(t => t.Alias, t => _localizedTextService.UmbracoDictionaryTranslate(t.Name));
}
}
}