Merge branch 'v8/dev' into v8/bugfix/contentquery-search

This commit is contained in:
Ronald Barendse
2019-11-15 09:49:50 +01:00
committed by GitHub
53 changed files with 5060 additions and 4649 deletions

View File

@@ -1,9 +1,13 @@
using Examine;
using System;
using Examine;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using Umbraco.Core;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.PropertyEditors;
using Umbraco.Core.PropertyEditors.ValueConverters;
using Umbraco.Core.Services;
using Umbraco.Core.Strings;
@@ -13,14 +17,16 @@ namespace Umbraco.Examine
{
private readonly UrlSegmentProviderCollection _urlSegmentProviders;
private readonly IUserService _userService;
private readonly ILogger _logger;
public MediaValueSetBuilder(PropertyEditorCollection propertyEditors,
UrlSegmentProviderCollection urlSegmentProviders,
IUserService userService)
IUserService userService, ILogger logger)
: base(propertyEditors, false)
{
_urlSegmentProviders = urlSegmentProviders;
_userService = userService;
_logger = logger;
}
/// <inheritdoc />
@@ -29,6 +35,42 @@ namespace Umbraco.Examine
foreach (var m in media)
{
var urlValue = m.GetUrlSegment(_urlSegmentProviders);
var umbracoFilePath = string.Empty;
var umbracoFile = string.Empty;
var umbracoFileSource = m.GetValue<string>(Constants.Conventions.Media.File);
if (umbracoFileSource.DetectIsJson())
{
ImageCropperValue cropper = null;
try
{
cropper = JsonConvert.DeserializeObject<ImageCropperValue>(
m.GetValue<string>(Constants.Conventions.Media.File));
}
catch (Exception ex)
{
_logger.Error<MediaValueSetBuilder>(ex, $"Could not Deserialize ImageCropperValue for item with key {m.Key} ");
}
if (cropper != null)
{
umbracoFilePath = cropper.Src;
}
}
else
{
umbracoFilePath = umbracoFileSource;
}
if (!string.IsNullOrEmpty(umbracoFilePath))
{
// intentional dummy Uri
var uri = new Uri("https://localhost/" + umbracoFilePath);
umbracoFile = uri.Segments.Last();
}
var values = new Dictionary<string, IEnumerable<object>>
{
{"icon", m.ContentType.Icon?.Yield() ?? Enumerable.Empty<string>()},
@@ -44,7 +86,8 @@ namespace Umbraco.Examine
{"urlName", urlValue?.Yield() ?? Enumerable.Empty<string>()},
{"path", m.Path?.Yield() ?? Enumerable.Empty<string>()},
{"nodeType", m.ContentType.Id.ToString().Yield() },
{"creatorName", (m.GetCreatorProfile(_userService)?.Name ?? "??").Yield()}
{"creatorName", (m.GetCreatorProfile(_userService)?.Name ?? "??").Yield()},
{UmbracoExamineIndex.UmbracoFileFieldName, umbracoFile.Yield()}
};
foreach (var property in m.Properties)

View File

@@ -32,6 +32,7 @@ namespace Umbraco.Examine
/// </summary>
public const string IndexPathFieldName = SpecialFieldPrefix + "Path";
public const string NodeKeyFieldName = SpecialFieldPrefix + "Key";
public const string UmbracoFileFieldName = "umbracoFileSrc";
public const string IconFieldName = SpecialFieldPrefix + "Icon";
public const string PublishedFieldName = SpecialFieldPrefix + "Published";