Merge branch 'temp8' into temp8-U4-11173
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using AutoMapper;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using ContentVariation = Umbraco.Core.Models.ContentVariation;
|
||||
@@ -13,7 +14,12 @@ namespace Umbraco.Web.Models.Mapping
|
||||
public string Resolve(IContent source, ContentItemDisplay destination, string destMember, ResolutionContext context)
|
||||
{
|
||||
var culture = context.GetCulture();
|
||||
return source.GetName(culture);
|
||||
if (culture != null && source.ContentType.Variations.Has(ContentVariation.CultureNeutral))
|
||||
{
|
||||
//return the culture name being requested
|
||||
return source.GetName(culture);
|
||||
}
|
||||
return source.Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Linq;
|
||||
using AutoMapper;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
@@ -13,7 +14,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
/// </summary>
|
||||
internal class ContentMapperProfile : Profile
|
||||
{
|
||||
public ContentMapperProfile(IUserService userService, ILocalizedTextService textService, IContentService contentService, IContentTypeService contentTypeService, IDataTypeService dataTypeService, ILocalizationService localizationService)
|
||||
public ContentMapperProfile(IUserService userService, ILocalizedTextService textService, IContentService contentService, IContentTypeService contentTypeService, IDataTypeService dataTypeService, ILocalizationService localizationService, ILogger logger)
|
||||
{
|
||||
// create, capture, cache
|
||||
var contentOwnerResolver = new OwnerResolver<IContent>(userService);
|
||||
@@ -24,7 +25,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
var contentTypeBasicResolver = new ContentTypeBasicResolver<IContent, ContentItemDisplay>();
|
||||
var contentTreeNodeUrlResolver = new ContentTreeNodeUrlResolver<IContent, ContentTreeController>();
|
||||
var defaultTemplateResolver = new DefaultTemplateResolver();
|
||||
var contentUrlResolver = new ContentUrlResolver();
|
||||
var contentUrlResolver = new ContentUrlResolver(textService, contentService, logger);
|
||||
var variantResolver = new ContentItemDisplayVariationResolver(localizationService);
|
||||
|
||||
//FROM IContent TO ContentItemDisplay
|
||||
|
||||
@@ -163,7 +163,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
.ForMember(dest => dest.PropertyEditorAlias, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.DeleteDate, opt => opt.Ignore())
|
||||
|
||||
.ForMember(dto => dto.Variations, opt => opt.Ignore()) // fixme - change when UI supports it!
|
||||
.ForMember(dto => dto.Variations, opt => opt.ResolveUsing<PropertyTypeVariationsResolver>())
|
||||
|
||||
//only map if it is actually set
|
||||
.ForMember(dest => dest.Id, opt => opt.Condition(source => source.Id > 0))
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System.Linq;
|
||||
using AutoMapper;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Routing;
|
||||
|
||||
@@ -8,13 +10,24 @@ namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
internal class ContentUrlResolver : IValueResolver<IContent, ContentItemDisplay, string[]>
|
||||
{
|
||||
private readonly ILocalizedTextService _textService;
|
||||
private readonly IContentService _contentService;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public ContentUrlResolver(ILocalizedTextService textService, IContentService contentService, ILogger logger)
|
||||
{
|
||||
_textService = textService;
|
||||
_contentService = contentService;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public string[] Resolve(IContent source, ContentItemDisplay destination, string[] destMember, ResolutionContext context)
|
||||
{
|
||||
var umbracoContext = context.GetUmbracoContext(throwIfMissing: false);
|
||||
|
||||
var urls = umbracoContext == null
|
||||
? new[] {"Cannot generate urls without a current Umbraco Context"}
|
||||
: source.GetContentUrls(umbracoContext).ToArray();
|
||||
: source.GetContentUrls(umbracoContext.UrlProvider, _textService, _contentService, _logger).ToArray();
|
||||
|
||||
return urls;
|
||||
}
|
||||
|
||||
@@ -220,7 +220,8 @@ namespace Umbraco.Web.Models.Mapping
|
||||
DataTypeId = p.DataTypeId,
|
||||
SortOrder = p.SortOrder,
|
||||
ContentTypeId = contentType.Id,
|
||||
ContentTypeName = contentType.Name
|
||||
ContentTypeName = contentType.Name,
|
||||
AllowCultureVariant = p.Variations.HasFlag(Core.Models.ContentVariation.CultureNeutral)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
using AutoMapper;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using ContentVariation = Umbraco.Core.Models.ContentVariation;
|
||||
|
||||
namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
internal class PropertyTypeVariationsResolver: IValueResolver<PropertyTypeBasic, PropertyType, ContentVariation>
|
||||
{
|
||||
public ContentVariation Resolve(PropertyTypeBasic source, PropertyType destination, ContentVariation destMember, ResolutionContext context)
|
||||
{
|
||||
//this will always be the case, a content type will always be allowed to be invariant
|
||||
var result = ContentVariation.InvariantNeutral;
|
||||
|
||||
if (source.AllowCultureVariant)
|
||||
{
|
||||
result |= ContentVariation.CultureNeutral;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,15 +2,23 @@
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web.Composing;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Routing;
|
||||
|
||||
namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
internal class RedirectUrlMapperProfile : Profile
|
||||
{
|
||||
private readonly UrlProvider _urlProvider;
|
||||
|
||||
public RedirectUrlMapperProfile(UrlProvider urlProvider)
|
||||
{
|
||||
_urlProvider = urlProvider;
|
||||
}
|
||||
|
||||
public RedirectUrlMapperProfile()
|
||||
{
|
||||
CreateMap<IRedirectUrl, ContentRedirectUrl>()
|
||||
.ForMember(x => x.OriginalUrl, expression => expression.MapFrom(item => Current.UmbracoContext.UrlProvider.GetUrlFromRoute(item.ContentId, item.Url)))
|
||||
.ForMember(x => x.OriginalUrl, expression => expression.MapFrom(item => _urlProvider.GetUrlFromRoute(item.ContentId, item.Url, null)))
|
||||
.ForMember(x => x.DestinationUrl, expression => expression.Ignore())
|
||||
.ForMember(x => x.RedirectId, expression => expression.MapFrom(item => item.Key));
|
||||
}
|
||||
|
||||
@@ -47,7 +47,6 @@ namespace Umbraco.Web.Models.Mapping
|
||||
.ForMember(detail => detail.TourData, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.SessionTimeout, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.EmailConfirmedDate, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.UserType, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.InvitedDate, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.SecurityStamp, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Avatar, opt => opt.Ignore())
|
||||
@@ -79,7 +78,6 @@ namespace Umbraco.Web.Models.Mapping
|
||||
.ForMember(detail => detail.TourData, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.StartContentIds, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.StartMediaIds, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.UserType, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Language, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Username, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.PasswordQuestion, opt => opt.Ignore())
|
||||
@@ -332,26 +330,6 @@ namespace Umbraco.Web.Models.Mapping
|
||||
var groups = user.Groups.ToArray();
|
||||
detail.UserGroups = user.Groups.Select(x => x.Alias).ToArray();
|
||||
|
||||
if (groups.Length == 0)
|
||||
{
|
||||
//In backwards compatibility land, a user type cannot be null! so we need to return a fake one.
|
||||
detail.UserType = "temp";
|
||||
}
|
||||
else
|
||||
{
|
||||
var builtIns = new[] { Constants.Security.AdminGroupAlias, "writer", "editor", Constants.Security.TranslatorGroupAlias };
|
||||
var foundBuiltIn = groups.FirstOrDefault(x => builtIns.Contains(x.Alias));
|
||||
if (foundBuiltIn != null)
|
||||
{
|
||||
detail.UserType = foundBuiltIn.Alias;
|
||||
}
|
||||
else
|
||||
{
|
||||
//otherwise return the first
|
||||
detail.UserType = groups[0].Alias;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
CreateMap<IProfile, ContentEditing.UserProfile>()
|
||||
|
||||
Reference in New Issue
Block a user