-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12139 from umbraco/v9/bugfix/track-media-items-pi…
…cked-as-macro-params Fix media tracking of items added via macro parameters in RTE and Grid
- Loading branch information
Showing
17 changed files
with
489 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/Umbraco.Core/Persistence/Repositories/IMacroWithAliasRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Umbraco.Cms.Core.Models; | ||
|
||
namespace Umbraco.Cms.Core.Persistence.Repositories | ||
{ | ||
[Obsolete("This interface will be merged with IMacroRepository in Umbraco 11")] | ||
public interface IMacroWithAliasRepository : IMacroRepository | ||
{ | ||
IMacro GetByAlias(string alias); | ||
|
||
IEnumerable<IMacro> GetAllByAlias(string[] aliases); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...Umbraco.Core/PropertyEditors/ParameterEditors/MultiplePickerParamateterValueEditorBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Umbraco.Cms.Core.IO; | ||
using Umbraco.Cms.Core.Models; | ||
using Umbraco.Cms.Core.Models.Editors; | ||
using Umbraco.Cms.Core.Serialization; | ||
using Umbraco.Cms.Core.Services; | ||
using Umbraco.Cms.Core.Strings; | ||
|
||
namespace Umbraco.Cms.Core.PropertyEditors.ParameterEditors | ||
{ | ||
internal abstract class MultiplePickerParamateterValueEditorBase : DataValueEditor, IDataValueReference | ||
{ | ||
private readonly IEntityService _entityService; | ||
|
||
public MultiplePickerParamateterValueEditorBase( | ||
ILocalizedTextService localizedTextService, | ||
IShortStringHelper shortStringHelper, | ||
IJsonSerializer jsonSerializer, | ||
IIOHelper ioHelper, | ||
DataEditorAttribute attribute, | ||
IEntityService entityService) | ||
: base(localizedTextService, shortStringHelper, jsonSerializer, ioHelper, attribute) | ||
{ | ||
_entityService = entityService; | ||
} | ||
|
||
public abstract string UdiEntityType { get; } | ||
public abstract UmbracoObjectTypes UmbracoObjectType { get; } | ||
public IEnumerable<UmbracoEntityReference> GetReferences(object value) | ||
{ | ||
var asString = value is string str ? str : value?.ToString(); | ||
|
||
if (string.IsNullOrEmpty(asString)) | ||
{ | ||
yield break; | ||
} | ||
|
||
foreach (var udiStr in asString.Split(',')) | ||
{ | ||
if (UdiParser.TryParse(udiStr, out Udi udi)) | ||
{ | ||
yield return new UmbracoEntityReference(udi); | ||
} | ||
|
||
// this is needed to support the legacy case when the multiple media picker parameter editor stores ints not udis | ||
if (int.TryParse(udiStr, out var id)) | ||
{ | ||
Attempt<Guid> guidAttempt = _entityService.GetKey(id, UmbracoObjectType); | ||
Guid guid = guidAttempt.Success ? guidAttempt.Result : Guid.Empty; | ||
|
||
if (guid != Guid.Empty) | ||
{ | ||
yield return new UmbracoEntityReference(new GuidUdi(Constants.UdiEntityType.Media, guid)); | ||
} | ||
|
||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Umbraco.Cms.Core.Models; | ||
|
||
namespace Umbraco.Cms.Core.Services | ||
{ | ||
[Obsolete("This interface will be merged with IMacroService in Umbraco 11")] | ||
public interface IMacroWithAliasService : IMacroService | ||
{ | ||
/// <summary> | ||
/// Gets a list of available <see cref="IMacro"/> objects by alias. | ||
/// </summary> | ||
/// <param name="aliases">Optional array of aliases to limit the results</param> | ||
/// <returns>An enumerable list of <see cref="IMacro"/> objects</returns> | ||
IEnumerable<IMacro> GetAll(params string[] aliases); | ||
} | ||
} |
1 change: 0 additions & 1 deletion
1
src/Umbraco.Infrastructure/DependencyInjection/UmbracoBuilder.Repositories.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.