Merge branch 'v8/dev' into v8/bugfix/contentquery-search
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user