Gets the IsSensitive property mapped to the display object and changes the property output to show that the field contains sensitive data. Refactors the TabsAndPropertiesResolver and simplifies it a lot which also allows us to pass in an UmbracoContext which we'll need in order to determine a user's rights, etc... Refactors how the TreeNodeUrls are mapped and they now use a proper mapper. This now means we do much less in AfterMap
This commit is contained in:
34
src/Umbraco.Web/Models/Mapping/ContentTreeNodeUrlResolver.cs
Normal file
34
src/Umbraco.Web/Models/Mapping/ContentTreeNodeUrlResolver.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System.Web.Mvc;
|
||||
using AutoMapper;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web.Trees;
|
||||
|
||||
namespace Umbraco.Web.Models.Mapping
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the tree node url for the content or media
|
||||
/// </summary>
|
||||
internal class ContentTreeNodeUrlResolver<TSource, TController> : IValueResolver
|
||||
where TSource : IContentBase
|
||||
where TController : ContentTreeControllerBase
|
||||
{
|
||||
|
||||
public ResolutionResult Resolve(ResolutionResult source)
|
||||
{
|
||||
return source.New(ResolveCore(source, (TSource)source.Value), typeof(string));
|
||||
}
|
||||
|
||||
private string ResolveCore(ResolutionResult res, TSource source)
|
||||
{
|
||||
var umbCtx = res.GetUmbracoContext();
|
||||
//map the tree node url
|
||||
if (umbCtx != null)
|
||||
{
|
||||
var urlHelper = new UrlHelper(umbCtx.HttpContext.Request.RequestContext);
|
||||
var url = urlHelper.GetUmbracoApiService<TController>(controller => controller.GetTreeNode(source.Key.ToString("N"), null));
|
||||
return url;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user