mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-19 17:51:45 +08:00
Framework: Fixing that TemplateFilterForPart should be able to identify an editor group name with spaces (#7683)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Orchard.Utility.Extensions;
|
||||
|
||||
namespace Orchard.ContentManagement.Handlers {
|
||||
public class TemplateFilterForPart<TPart> : TemplateFilterBase<ContentPart> where TPart : ContentPart, new() {
|
||||
@@ -35,7 +36,7 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
}
|
||||
|
||||
protected override void BuildEditorShape(BuildEditorContext context, ContentPart part) {
|
||||
if (!string.Equals(_groupId, context.GroupId, StringComparison.OrdinalIgnoreCase))
|
||||
if (!_groupId.SafeNameEquals(context.GroupId, StringComparison.OrdinalIgnoreCase))
|
||||
return;
|
||||
|
||||
var templatePart = part.As<TPart>();
|
||||
@@ -44,7 +45,7 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
}
|
||||
|
||||
protected override void UpdateEditorShape(UpdateEditorContext context, ContentPart part) {
|
||||
if (!string.Equals(_groupId, context.GroupId, StringComparison.OrdinalIgnoreCase))
|
||||
if (!_groupId.SafeNameEquals(context.GroupId, StringComparison.OrdinalIgnoreCase))
|
||||
return;
|
||||
|
||||
var templatePart = part.As<TPart>();
|
||||
|
||||
@@ -190,6 +190,18 @@ namespace Orchard.Utility.Extensions {
|
||||
return name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares two strings after converting them to valid technical names.
|
||||
/// </summary>
|
||||
public static bool SafeNameEquals(this string name, string otherName) =>
|
||||
name.ToSafeName() == otherName.ToSafeName();
|
||||
|
||||
/// <summary>
|
||||
/// Compares two strings using a string comparison option after converting them to valid technical names.
|
||||
/// </summary>
|
||||
public static bool SafeNameEquals(this string name, string otherName, StringComparison comparisonType) =>
|
||||
string.Equals(name.ToSafeName(), otherName.ToSafeName(), comparisonType);
|
||||
|
||||
/// <summary>
|
||||
/// Generates a valid Html name.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user