diff --git a/src/OrchardCore.Modules/OrchardCore.AdminDashboard/Controllers/DashboardController.cs b/src/OrchardCore.Modules/OrchardCore.AdminDashboard/Controllers/DashboardController.cs index b8886ecb912..28e9b7a653a 100644 --- a/src/OrchardCore.Modules/OrchardCore.AdminDashboard/Controllers/DashboardController.cs +++ b/src/OrchardCore.Modules/OrchardCore.AdminDashboard/Controllers/DashboardController.cs @@ -15,7 +15,7 @@ using OrchardCore.ContentManagement; using OrchardCore.ContentManagement.Display; using OrchardCore.ContentManagement.Metadata; -using OrchardCore.ContentManagement.Metadata.Settings; +using OrchardCore.ContentManagement.Metadata.Models; using OrchardCore.Contents; using OrchardCore.DisplayManagement; using OrchardCore.DisplayManagement.ModelBinding; @@ -109,9 +109,7 @@ public async Task Manage() var dashboardCreatable = new List(); var widgetContentTypes = _contentDefinitionManager.ListTypeDefinitions() - .Where(t => - !string.IsNullOrEmpty(t.GetSettings().Stereotype) && - t.GetSettings().Stereotype.Contains("DashboardWidget")) + .Where(t => t.TryGetStereotype(out var stereotype) && stereotype.Contains("DashboardWidget")) .OrderBy(x => x.DisplayName); foreach (var ctd in widgetContentTypes) { diff --git a/src/OrchardCore.Modules/OrchardCore.ContentFields/Controllers/ContentPickerAdminController.cs b/src/OrchardCore.Modules/OrchardCore.ContentFields/Controllers/ContentPickerAdminController.cs index fbf69ba483b..130e1aca694 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentFields/Controllers/ContentPickerAdminController.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentFields/Controllers/ContentPickerAdminController.cs @@ -9,7 +9,6 @@ using OrchardCore.ContentManagement; using OrchardCore.ContentManagement.Metadata; using OrchardCore.ContentManagement.Metadata.Models; -using OrchardCore.ContentManagement.Metadata.Settings; namespace OrchardCore.ContentFields.Controllers { @@ -61,9 +60,9 @@ public async Task SearchContentItems(string part, string field, s contentTypes = _contentDefinitionManager.ListTypeDefinitions() .Where(contentType => { - var stereotype = contentType.GetSettings().Stereotype; + var hasStereotype = contentType.TryGetStereotype(out var stereotype); - return !String.IsNullOrEmpty(stereotype) && fieldSettings.DisplayedStereotypes.Contains(stereotype); + return hasStereotype && fieldSettings.DisplayedStereotypes.Contains(stereotype); }).Select(contentType => contentType.Name) .ToArray(); } diff --git a/src/OrchardCore.Modules/OrchardCore.ContentFields/Services/DefaultContentPickerResultProvider.cs b/src/OrchardCore.Modules/OrchardCore.ContentFields/Services/DefaultContentPickerResultProvider.cs index e01b09efac0..29699dc7ddd 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentFields/Services/DefaultContentPickerResultProvider.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentFields/Services/DefaultContentPickerResultProvider.cs @@ -3,7 +3,7 @@ using System.Threading.Tasks; using OrchardCore.ContentManagement; using OrchardCore.ContentManagement.Metadata; -using OrchardCore.ContentManagement.Metadata.Settings; +using OrchardCore.ContentManagement.Metadata.Models; using OrchardCore.ContentManagement.Records; using YesSql; using YesSql.Services; @@ -32,7 +32,7 @@ public async Task> Search(ContentPickerSearchCo { contentTypes = _contentDefinitionManager .ListTypeDefinitions() - .Where(x => string.IsNullOrEmpty(x.GetSettings().Stereotype)) + .Where(x => !x.HasStereotype()) .Select(x => x.Name) .AsEnumerable(); } diff --git a/src/OrchardCore.Modules/OrchardCore.ContentTypes/Views/Shared/DisplayTemplates/EditTypeViewModel.cshtml b/src/OrchardCore.Modules/OrchardCore.ContentTypes/Views/Shared/DisplayTemplates/EditTypeViewModel.cshtml index 116df9b1974..a0fdc1f3d76 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentTypes/Views/Shared/DisplayTemplates/EditTypeViewModel.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.ContentTypes/Views/Shared/DisplayTemplates/EditTypeViewModel.cshtml @@ -9,7 +9,7 @@ @Model.Name - @if (!string.IsNullOrWhiteSpace(settings.Stereotype)) + @if (!String.IsNullOrWhiteSpace(settings.Stereotype)) { @settings.Stereotype } @@ -24,7 +24,7 @@ -@if (!string.IsNullOrWhiteSpace(settings.Description)) +@if (!String.IsNullOrWhiteSpace(settings.Description)) {
diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/AdminMenu.cs b/src/OrchardCore.Modules/OrchardCore.Contents/AdminMenu.cs index def596cae8c..f8e6f5ffe03 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/AdminMenu.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/AdminMenu.cs @@ -8,7 +8,7 @@ using OrchardCore.Admin.Models; using OrchardCore.ContentManagement; using OrchardCore.ContentManagement.Metadata; -using OrchardCore.ContentManagement.Metadata.Settings; +using OrchardCore.ContentManagement.Metadata.Models; using OrchardCore.Contents.Controllers; using OrchardCore.Contents.Security; using OrchardCore.Entities; @@ -56,7 +56,7 @@ public async Task BuildNavigationAsync(string name, NavigationBuilder builder) } var contentTypeDefinitions = _contentDefinitionManager.ListTypeDefinitions().OrderBy(d => d.Name); - var contentTypes = contentTypeDefinitions.Where(ctd => ctd.GetSettings().Creatable).OrderBy(ctd => ctd.DisplayName); + var contentTypes = contentTypeDefinitions.Where(ctd => ctd.IsCreatable()).OrderBy(ctd => ctd.DisplayName); await builder.AddAsync(S["Content"], NavigationConstants.AdminMenuContentPosition, async content => { content.AddClass("content").Id("content"); diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/AdminNodes/ContentTypesAdminNodeDriver.cs b/src/OrchardCore.Modules/OrchardCore.Contents/AdminNodes/ContentTypesAdminNodeDriver.cs index b7ad1552270..5af6bfb8168 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/AdminNodes/ContentTypesAdminNodeDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/AdminNodes/ContentTypesAdminNodeDriver.cs @@ -2,7 +2,7 @@ using System.Linq; using System.Threading.Tasks; using OrchardCore.ContentManagement.Metadata; -using OrchardCore.ContentManagement.Metadata.Settings; +using OrchardCore.ContentManagement.Metadata.Models; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.DisplayManagement.ModelBinding; using OrchardCore.DisplayManagement.Views; @@ -29,7 +29,7 @@ public override IDisplayResult Display(ContentTypesAdminNode treeNode) public override IDisplayResult Edit(ContentTypesAdminNode treeNode) { var listable = _contentDefinitionManager.ListTypeDefinitions() - .Where(ctd => ctd.GetSettings().Listable) + .Where(ctd => ctd.IsListable()) .OrderBy(ctd => ctd.DisplayName).ToList(); var entries = listable.Select(x => new ContentTypeEntryViewModel diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/AdminNodes/ContentTypesAdminNodeNavigationBuilder.cs b/src/OrchardCore.Modules/OrchardCore.Contents/AdminNodes/ContentTypesAdminNodeNavigationBuilder.cs index 86483e43b43..77cb80bd737 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/AdminNodes/ContentTypesAdminNodeNavigationBuilder.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/AdminNodes/ContentTypesAdminNodeNavigationBuilder.cs @@ -9,7 +9,6 @@ using OrchardCore.AdminMenu.Services; using OrchardCore.ContentManagement.Metadata; using OrchardCore.ContentManagement.Metadata.Models; -using OrchardCore.ContentManagement.Metadata.Settings; using OrchardCore.Contents.Security; using OrchardCore.Navigation; @@ -86,7 +85,7 @@ public async Task BuildNavigationAsync(MenuItem menuItem, NavigationBuilder buil private IEnumerable GetContentTypesToShow(ContentTypesAdminNode node) { var typesToShow = _contentDefinitionManager.ListTypeDefinitions() - .Where(ctd => ctd.GetSettings().Listable); + .Where(ctd => ctd.IsListable()); if (!node.ShowAll) { @@ -98,7 +97,7 @@ private IEnumerable GetContentTypesToShow(ContentTypesAdm return typesToShow.OrderBy(t => t.DisplayName); } - private List GetIconClasses(ContentTypeDefinition contentType, ContentTypesAdminNode node) + private static List GetIconClasses(ContentTypeDefinition contentType, ContentTypesAdminNode node) { if (node.ShowAll) { @@ -114,12 +113,12 @@ private List GetIconClasses(ContentTypeDefinition contentType, ContentTy } } - private List AddPrefixToClasses(string unprefixed) + private static List AddPrefixToClasses(string unprefixed) { return unprefixed?.Split(' ') .ToList() .Select(c => "icon-class-" + c) - .ToList() + .ToList() ?? new List(); } } diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Controllers/AdminController.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Controllers/AdminController.cs index c70ed533130..6aa35286e74 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Controllers/AdminController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Controllers/AdminController.cs @@ -15,7 +15,6 @@ using OrchardCore.ContentManagement.Display; using OrchardCore.ContentManagement.Metadata; using OrchardCore.ContentManagement.Metadata.Models; -using OrchardCore.ContentManagement.Metadata.Settings; using OrchardCore.ContentManagement.Records; using OrchardCore.Contents.Services; using OrchardCore.Contents.ViewModels; @@ -91,7 +90,7 @@ public async Task List( string contentTypeId = "") { var contentTypeDefinitions = _contentDefinitionManager.ListTypeDefinitions() - .Where(ctd => IsCreatable(ctd)) + .Where(ctd => ctd.IsCreatable()) .OrderBy(ctd => ctd.DisplayName); if (!await _authorizationService.AuthorizeContentTypeDefinitionsAsync(User, CommonPermissions.ViewContent, contentTypeDefinitions, _contentManager)) @@ -126,7 +125,7 @@ public async Task List( var creatableList = new List(); // Allows non creatable types to be created by another admin page. - if (IsCreatable(contentTypeDefinition) || options.CanCreateSelectedContentType) + if (contentTypeDefinition.IsCreatable() || options.CanCreateSelectedContentType) { var contentItem = await CreateContentItemForOwnedByCurrentAsync(contentTypeDefinition.Name); @@ -148,7 +147,7 @@ public async Task List( { var contentItem = await CreateContentItemForOwnedByCurrentAsync(contentTypeDefinition.Name); - if (IsCreatable(contentTypeDefinition) && await IsAuthorizedAsync(CommonPermissions.EditContent, contentItem)) + if (contentTypeDefinition.IsCreatable() && await IsAuthorizedAsync(CommonPermissions.EditContent, contentItem)) { creatableList.Add(new SelectListItem(contentTypeDefinition.DisplayName, contentTypeDefinition.Name)); } @@ -194,7 +193,7 @@ public async Task List( foreach (var ctd in _contentDefinitionManager.ListTypeDefinitions()) { - if (!ctd.GetSettings().Listable) + if (!ctd.IsListable()) { continue; } @@ -722,11 +721,6 @@ public async Task Unpublish(string contentItemId, string returnUr return Url.IsLocalUrl(returnUrl) ? (IActionResult)this.LocalRedirect(returnUrl, true) : RedirectToAction(nameof(List)); } - private static bool IsCreatable(ContentTypeDefinition contentTypeDefinition) - { - return contentTypeDefinition.GetSettings().Creatable; - } - private async Task CreateContentItemForOwnedByCurrentAsync(string contentType) { var contentItem = await _contentManager.NewAsync(contentType); diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Drivers/ContentsDriver.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Drivers/ContentsDriver.cs index c9026a907d6..c2b96e21fe9 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Drivers/ContentsDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Drivers/ContentsDriver.cs @@ -6,7 +6,7 @@ using OrchardCore.ContentManagement.Display.ContentDisplay; using OrchardCore.ContentManagement.Display.ViewModels; using OrchardCore.ContentManagement.Metadata; -using OrchardCore.ContentManagement.Metadata.Settings; +using OrchardCore.ContentManagement.Metadata.Models; using OrchardCore.DisplayManagement.ModelBinding; using OrchardCore.DisplayManagement.Views; @@ -44,14 +44,9 @@ public override IDisplayResult Display(ContentItem contentItem, IUpdateModel upd { contentsMetadataShape.Displaying(ctx => { - var stereotype = ""; - var settings = contentTypeDefinition?.GetSettings(); - if (settings != null) - { - stereotype = settings.Stereotype; - } + var hasStereotype = contentTypeDefinition.TryGetStereotype(out var stereotype); - if (!String.IsNullOrEmpty(stereotype) && !String.Equals("Content", stereotype, StringComparison.OrdinalIgnoreCase)) + if (hasStereotype && !String.Equals("Content", stereotype, StringComparison.OrdinalIgnoreCase)) { ctx.Shape.Metadata.Alternates.Add($"{stereotype}__ContentsMetadata"); } @@ -62,12 +57,11 @@ public override IDisplayResult Display(ContentItem contentItem, IUpdateModel upd { ctx.Shape.Metadata.Alternates.Add($"ContentsMetadata_{ctx.Shape.Metadata.DisplayType}"); - if (!String.IsNullOrEmpty(stereotype) && !String.Equals("Content", stereotype, StringComparison.OrdinalIgnoreCase)) + if (hasStereotype && !String.Equals("Content", stereotype, StringComparison.OrdinalIgnoreCase)) { ctx.Shape.Metadata.Alternates.Add($"{stereotype}_{displayType}__ContentsMetadata"); } } - }); results.Add(contentsMetadataShape); @@ -113,7 +107,7 @@ public override IDisplayResult Edit(ContentItem contentItem, IUpdateModel update results.Add(Dynamic("Content_SaveDraftButton").Location("Actions:20") .RenderWhen(async () => { - if (contentTypeDefinition.GetSettings().Draftable && + if (contentTypeDefinition.IsDraftable() && await _authorizationService.AuthorizeAsync(context.User, CommonPermissions.EditContent, contentItem)) { return true; diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Security/ContentTypePermissions.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Security/ContentTypePermissions.cs index 458b46db9e8..e0ce9bab255 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Security/ContentTypePermissions.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Security/ContentTypePermissions.cs @@ -2,7 +2,7 @@ using System.Linq; using System.Threading.Tasks; using OrchardCore.ContentManagement.Metadata; -using OrchardCore.ContentManagement.Metadata.Settings; +using OrchardCore.ContentManagement.Metadata.Models; using OrchardCore.Security.Permissions; namespace OrchardCore.Contents.Security @@ -20,7 +20,7 @@ public Task> GetPermissionsAsync() { // manage rights only for Securable types var securableTypes = _contentDefinitionManager.ListTypeDefinitions() - .Where(ctd => ctd.GetSettings().Securable); + .Where(ctd => ctd.IsSecurable()); var result = new List(); diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Services/DefaultContentsAdminListFilterProvider.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Services/DefaultContentsAdminListFilterProvider.cs index 2a27692389d..30982f21697 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Services/DefaultContentsAdminListFilterProvider.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Services/DefaultContentsAdminListFilterProvider.cs @@ -9,7 +9,6 @@ using OrchardCore.ContentManagement; using OrchardCore.ContentManagement.Metadata; using OrchardCore.ContentManagement.Metadata.Models; -using OrchardCore.ContentManagement.Metadata.Settings; using OrchardCore.ContentManagement.Records; using OrchardCore.Contents.Security; using OrchardCore.Contents.ViewModels; @@ -168,7 +167,7 @@ public void Build(QueryEngineBuilder builder) foreach (var ctd in contentDefinitionManager.ListTypeDefinitions()) { - if (!ctd.GetSettings().Listable) + if (!ctd.IsListable()) { continue; } diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/ViewComponents/SelectContentTypesViewComponent.cs b/src/OrchardCore.Modules/OrchardCore.Contents/ViewComponents/SelectContentTypesViewComponent.cs index 5fec1fa1922..e2a77f828e7 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/ViewComponents/SelectContentTypesViewComponent.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/ViewComponents/SelectContentTypesViewComponent.cs @@ -3,7 +3,7 @@ using System.Linq; using Microsoft.AspNetCore.Mvc; using OrchardCore.ContentManagement.Metadata; -using OrchardCore.ContentManagement.Metadata.Settings; +using OrchardCore.ContentManagement.Metadata.Models; using OrchardCore.Contents.ViewModels; namespace OrchardCore.Contents.ViewComponents @@ -21,7 +21,7 @@ public IViewComponentResult Invoke(IEnumerable selectedContentTypes, str { if (selectedContentTypes == null) { - selectedContentTypes = new string[0]; + selectedContentTypes = Array.Empty(); } var contentTypes = ContentTypeSelection.Build(_contentDefinitionManager, selectedContentTypes); @@ -29,7 +29,7 @@ public IViewComponentResult Invoke(IEnumerable selectedContentTypes, str if (!String.IsNullOrEmpty(stereotype)) { contentTypes = contentTypes - .Where(x => x.ContentTypeDefinition.GetSettings().Stereotype == stereotype) + .Where(x => x.ContentTypeDefinition.GetStereotype() == stereotype) .ToArray(); } diff --git a/src/OrchardCore.Modules/OrchardCore.CustomSettings/Services/CustomSettingsService.cs b/src/OrchardCore.Modules/OrchardCore.CustomSettings/Services/CustomSettingsService.cs index 2cb3ef1a9da..6be5708738b 100644 --- a/src/OrchardCore.Modules/OrchardCore.CustomSettings/Services/CustomSettingsService.cs +++ b/src/OrchardCore.Modules/OrchardCore.CustomSettings/Services/CustomSettingsService.cs @@ -8,7 +8,6 @@ using OrchardCore.ContentManagement; using OrchardCore.ContentManagement.Metadata; using OrchardCore.ContentManagement.Metadata.Models; -using OrchardCore.ContentManagement.Metadata.Settings; using OrchardCore.Settings; namespace OrchardCore.CustomSettings.Services @@ -37,7 +36,7 @@ public CustomSettingsService( _settingsTypes = new Lazy>( () => _contentDefinitionManager .ListTypeDefinitions() - .Where(x => x.GetSettings().Stereotype == "CustomSettings") + .Where(x => x.GetStereotype() == "CustomSettings") .ToDictionary(x => x.Name)); } diff --git a/src/OrchardCore.Modules/OrchardCore.Flows/Controllers/AdminController.cs b/src/OrchardCore.Modules/OrchardCore.Flows/Controllers/AdminController.cs index 1a4bf139b62..f752b6ab487 100644 --- a/src/OrchardCore.Modules/OrchardCore.Flows/Controllers/AdminController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Flows/Controllers/AdminController.cs @@ -7,7 +7,6 @@ using OrchardCore.ContentManagement.Display; using OrchardCore.ContentManagement.Metadata; using OrchardCore.ContentManagement.Metadata.Models; -using OrchardCore.ContentManagement.Metadata.Settings; using OrchardCore.DisplayManagement; using OrchardCore.DisplayManagement.ModelBinding; using OrchardCore.Flows.Models; @@ -112,12 +111,12 @@ private IEnumerable GetContainedContentTypes(string conte if (settings == null || settings.ContainedContentTypes == null || !settings.ContainedContentTypes.Any()) { - return _contentDefinitionManager.ListTypeDefinitions().Where(t => t.GetSettings().Stereotype == "Widget"); + return _contentDefinitionManager.ListTypeDefinitions().Where(t => t.GetStereotype() == "Widget"); } return settings.ContainedContentTypes .Select(contentType => _contentDefinitionManager.GetTypeDefinition(contentType)) - .Where(t => t != null && t.GetSettings().Stereotype == "Widget"); + .Where(t => t != null && t.GetStereotype() == "Widget"); } } } diff --git a/src/OrchardCore.Modules/OrchardCore.Flows/Drivers/BagPartDisplayDriver.cs b/src/OrchardCore.Modules/OrchardCore.Flows/Drivers/BagPartDisplayDriver.cs index 822a1bd2a88..8b202974e3d 100644 --- a/src/OrchardCore.Modules/OrchardCore.Flows/Drivers/BagPartDisplayDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Flows/Drivers/BagPartDisplayDriver.cs @@ -218,7 +218,7 @@ private async Task> GetContainedContentTypesA if (settings.ContainedStereotypes != null && settings.ContainedStereotypes.Length > 0) { contentTypes = _contentDefinitionManager.ListTypeDefinitions() - .Where(contentType => contentType.HasStereotype() && settings.ContainedStereotypes.Contains(contentType.GetStereotypeOrDefault(), StringComparer.OrdinalIgnoreCase)); + .Where(contentType => contentType.HasStereotype() && settings.ContainedStereotypes.Contains(contentType.GetStereotype(), StringComparer.OrdinalIgnoreCase)); } else if (settings.ContainedContentTypes != null && settings.ContainedContentTypes.Length > 0) { diff --git a/src/OrchardCore.Modules/OrchardCore.Flows/Drivers/FlowPartDisplayDriver.cs b/src/OrchardCore.Modules/OrchardCore.Flows/Drivers/FlowPartDisplayDriver.cs index afa0977a1dc..58e74d7f80a 100644 --- a/src/OrchardCore.Modules/OrchardCore.Flows/Drivers/FlowPartDisplayDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Flows/Drivers/FlowPartDisplayDriver.cs @@ -11,7 +11,6 @@ using OrchardCore.ContentManagement.Display.Models; using OrchardCore.ContentManagement.Metadata; using OrchardCore.ContentManagement.Metadata.Models; -using OrchardCore.ContentManagement.Metadata.Settings; using OrchardCore.DisplayManagement.Notify; using OrchardCore.DisplayManagement.Views; using OrchardCore.Flows.Models; @@ -134,12 +133,12 @@ private IEnumerable GetContainedContentTypes(ContentTypeP if (settings.ContainedContentTypes == null || !settings.ContainedContentTypes.Any()) { - return _contentDefinitionManager.ListTypeDefinitions().Where(t => t.GetSettings().Stereotype == "Widget"); + return _contentDefinitionManager.ListTypeDefinitions().Where(t => t.GetStereotype() == "Widget"); } return settings.ContainedContentTypes .Select(contentType => _contentDefinitionManager.GetTypeDefinition(contentType)) - .Where(t => t != null && t.GetSettings().Stereotype == "Widget"); + .Where(t => t != null && t.GetStereotype() == "Widget"); } } } diff --git a/src/OrchardCore.Modules/OrchardCore.Flows/GraphQL/FlowMetadataContentTypeBuilder.cs b/src/OrchardCore.Modules/OrchardCore.Flows/GraphQL/FlowMetadataContentTypeBuilder.cs index a611887578f..0f00e82d58c 100644 --- a/src/OrchardCore.Modules/OrchardCore.Flows/GraphQL/FlowMetadataContentTypeBuilder.cs +++ b/src/OrchardCore.Modules/OrchardCore.Flows/GraphQL/FlowMetadataContentTypeBuilder.cs @@ -2,7 +2,6 @@ using OrchardCore.ContentManagement; using OrchardCore.ContentManagement.GraphQL.Queries.Types; using OrchardCore.ContentManagement.Metadata.Models; -using OrchardCore.ContentManagement.Metadata.Settings; using OrchardCore.Flows.Models; namespace OrchardCore.Flows.GraphQL @@ -11,9 +10,10 @@ public class FlowMetadataContentTypeBuilder : IContentTypeBuilder { public void Build(FieldType contentQuery, ContentTypeDefinition contentTypeDefinition, ContentItemType contentItemType) { - var settings = contentTypeDefinition.GetSettings(); - - if (settings.Stereotype != "Widget") return; + if (contentTypeDefinition.GetStereotype() != "Widget") + { + return; + } contentItemType.Field( "metadata", diff --git a/src/OrchardCore.Modules/OrchardCore.Flows/Settings/FlowPartSettingsDisplayDriver.cs b/src/OrchardCore.Modules/OrchardCore.Flows/Settings/FlowPartSettingsDisplayDriver.cs index dfaf9a22a20..680a3ca5e48 100644 --- a/src/OrchardCore.Modules/OrchardCore.Flows/Settings/FlowPartSettingsDisplayDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Flows/Settings/FlowPartSettingsDisplayDriver.cs @@ -4,7 +4,6 @@ using Microsoft.Extensions.Localization; using OrchardCore.ContentManagement.Metadata; using OrchardCore.ContentManagement.Metadata.Models; -using OrchardCore.ContentManagement.Metadata.Settings; using OrchardCore.ContentTypes.Editors; using OrchardCore.DisplayManagement.ModelBinding; using OrchardCore.DisplayManagement.Views; @@ -34,7 +33,7 @@ public override IDisplayResult Edit(ContentTypePartDefinition contentTypePartDef model.ContainedContentTypes = model.FlowPartSettings.ContainedContentTypes; model.ContentTypes = new NameValueCollection(); - foreach (var contentTypeDefinition in _contentDefinitionManager.ListTypeDefinitions().Where(t => t.GetSettings().Stereotype == "Widget")) + foreach (var contentTypeDefinition in _contentDefinitionManager.ListTypeDefinitions().Where(t => t.GetStereotype() == "Widget")) { model.ContentTypes.Add(contentTypeDefinition.Name, contentTypeDefinition.DisplayName); } diff --git a/src/OrchardCore.Modules/OrchardCore.Layers/Views/Admin/Index.cshtml b/src/OrchardCore.Modules/OrchardCore.Layers/Views/Admin/Index.cshtml index c353bb92bcd..96418f0da06 100644 --- a/src/OrchardCore.Modules/OrchardCore.Layers/Views/Admin/Index.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Layers/Views/Admin/Index.cshtml @@ -1,6 +1,7 @@ @using System.Globalization; @using OrchardCore.ContentManagement.Metadata.Settings; @using OrchardCore.Layers.Drivers +@using OrchardCore.ContentManagement.Metadata.Models @model OrchardCore.Layers.ViewModels.LayersIndexViewModel @inject IContentManager ContentManager @@ -8,7 +9,7 @@ @inject OrchardCore.ContentManagement.Display.IContentItemDisplayManager ContentItemDisplayManager @{ - var widgetContentTypes = ContentDefinitionManager.ListTypeDefinitions().Where(t => t.GetSettings().Stereotype == "Widget"); + var widgetContentTypes = ContentDefinitionManager.ListTypeDefinitions().Where(t => t.GetStereotype() == "Widget"); } @@ -52,17 +53,17 @@ maxPosition = Math.Max(maxPosition, (double)contentItemSummary.ContentItem.Content.LayerMetadata.Position); -
  • -
    +
  • +
    @await DisplayAsync(contentItemSummary) -
    - -
  • +
    + + } @@ -86,9 +87,9 @@ createRoute["LayerMetadata.Zone"] = zone; createRoute["LayerMetadata.Position"] = maxPosition + 1; @type.DisplayName + data-widget-type="@type.Name" + data-zone="@zone" + href="@Url.Action((string)createRoute["Action"], (string)createRoute["controller"], createRoute)">@type.DisplayName }
    @@ -155,7 +156,7 @@ handle: ".properties", cursor: "move", connectWith: '.list-group', - stop: function (event, ui) { + stop: function(event, ui) { var newZone = ui.item.closest('.layer-zone').data("zone"); var metadata = ui.item.find('.layer-metadata') var currentPosition = Number(metadata.data("position")); @@ -191,24 +192,24 @@ var antiforgerytoken = $("[name='__RequestVerificationToken']").val(); $.post(url, { "__RequestVerificationToken": antiforgerytoken }) - .done(function () { + .done(function() { console.log('done'); $('#layer-undo-message').removeClass("d-none"); $('#layer-undo-message-contentItemId').val(contentItemId); $('#layer-undo-message-position').val(currentPosition); $('#layer-undo-message-zone').val(currentZone); }) - .fail(function () { + .fail(function() { console.log('failed'); $('#layer-undo-message').addClass("d-none"); }) - ; + ; } }); - $('.layer-check').on('click', function () { + $('.layer-check').on('click', function() { $('.list-group-item').removeClass('list-group-item-success'); - $('.layer-check:checked').each(function () { + $('.layer-check:checked').each(function() { var layer = $(this).val(); $('[data-layer="' + layer + '"]').closest('.list-group-item').addClass('list-group-item-success'); }); diff --git a/src/OrchardCore.Modules/OrchardCore.Menu/Controllers/AdminController.cs b/src/OrchardCore.Modules/OrchardCore.Menu/Controllers/AdminController.cs index c17bd91ad3a..5e98ab35b99 100644 --- a/src/OrchardCore.Modules/OrchardCore.Menu/Controllers/AdminController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Menu/Controllers/AdminController.cs @@ -7,7 +7,7 @@ using OrchardCore.ContentManagement; using OrchardCore.ContentManagement.Display; using OrchardCore.ContentManagement.Metadata; -using OrchardCore.ContentManagement.Metadata.Settings; +using OrchardCore.ContentManagement.Metadata.Models; using OrchardCore.DisplayManagement.ModelBinding; using OrchardCore.DisplayManagement.Notify; using OrchardCore.Menu.Models; @@ -81,7 +81,7 @@ public async Task CreatePost(string id, string menuContentItemId, var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition("Menu"); - if (!contentTypeDefinition.GetSettings().Draftable) + if (!contentTypeDefinition.IsDraftable()) { menu = await _contentManager.GetAsync(menuContentItemId, VersionOptions.Latest); } @@ -186,7 +186,7 @@ public async Task EditPost(string menuContentItemId, string menuI var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition("Menu"); - if (!contentTypeDefinition.GetSettings().Draftable) + if (!contentTypeDefinition.IsDraftable()) { menu = await _contentManager.GetAsync(menuContentItemId, VersionOptions.Latest); } @@ -252,7 +252,7 @@ public async Task Delete(string menuContentItemId, string menuIte var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition("Menu"); - if (!contentTypeDefinition.GetSettings().Draftable) + if (!contentTypeDefinition.IsDraftable()) { menu = await _contentManager.GetAsync(menuContentItemId, VersionOptions.Latest); } diff --git a/src/OrchardCore.Modules/OrchardCore.Menu/Drivers/MenuPartDisplayDriver.cs b/src/OrchardCore.Modules/OrchardCore.Menu/Drivers/MenuPartDisplayDriver.cs index a5f83c55ca4..2df5e2b8e86 100644 --- a/src/OrchardCore.Modules/OrchardCore.Menu/Drivers/MenuPartDisplayDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Menu/Drivers/MenuPartDisplayDriver.cs @@ -8,7 +8,7 @@ using OrchardCore.ContentManagement; using OrchardCore.ContentManagement.Display.ContentDisplay; using OrchardCore.ContentManagement.Metadata; -using OrchardCore.ContentManagement.Metadata.Settings; +using OrchardCore.ContentManagement.Metadata.Models; using OrchardCore.DisplayManagement.ModelBinding; using OrchardCore.DisplayManagement.Notify; using OrchardCore.DisplayManagement.Views; @@ -41,7 +41,7 @@ public override IDisplayResult Edit(MenuPart part) { return Initialize("MenuPart_Edit", async model => { - var menuItemContentTypes = _contentDefinitionManager.ListTypeDefinitions().Where(t => t.GetSettings().Stereotype == "MenuItem"); + var menuItemContentTypes = _contentDefinitionManager.ListTypeDefinitions().Where(t => t.GetStereotype() == "MenuItem"); var notify = false; foreach (var menuItem in part.ContentItem.As().MenuItems) diff --git a/src/OrchardCore.Modules/OrchardCore.Menu/GraphQL/MenuItemContentTypeBuilder.cs b/src/OrchardCore.Modules/OrchardCore.Menu/GraphQL/MenuItemContentTypeBuilder.cs index ca3a3471284..6f2ec541b5b 100644 --- a/src/OrchardCore.Modules/OrchardCore.Menu/GraphQL/MenuItemContentTypeBuilder.cs +++ b/src/OrchardCore.Modules/OrchardCore.Menu/GraphQL/MenuItemContentTypeBuilder.cs @@ -3,7 +3,6 @@ using OrchardCore.ContentManagement.GraphQL; using OrchardCore.ContentManagement.GraphQL.Queries.Types; using OrchardCore.ContentManagement.Metadata.Models; -using OrchardCore.ContentManagement.Metadata.Settings; using OrchardCore.Menu.Models; namespace OrchardCore.Menu.GraphQL @@ -12,9 +11,10 @@ public class MenuItemContentTypeBuilder : IContentTypeBuilder { public void Build(FieldType contentQuery, ContentTypeDefinition contentTypeDefinition, ContentItemType contentItemType) { - var settings = contentTypeDefinition.GetSettings(); - - if (settings.Stereotype != "MenuItem") return; + if (contentTypeDefinition.GetStereotype() != "MenuItem") + { + return; + } contentItemType.Field( nameof(MenuItemsListPart).ToFieldName(), diff --git a/src/OrchardCore.Modules/OrchardCore.Taxonomies/Controllers/AdminController.cs b/src/OrchardCore.Modules/OrchardCore.Taxonomies/Controllers/AdminController.cs index 29744534ba8..d35658a6f31 100644 --- a/src/OrchardCore.Modules/OrchardCore.Taxonomies/Controllers/AdminController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Taxonomies/Controllers/AdminController.cs @@ -7,7 +7,7 @@ using OrchardCore.ContentManagement; using OrchardCore.ContentManagement.Display; using OrchardCore.ContentManagement.Metadata; -using OrchardCore.ContentManagement.Metadata.Settings; +using OrchardCore.ContentManagement.Metadata.Models; using OrchardCore.DisplayManagement.ModelBinding; using OrchardCore.DisplayManagement.Notify; using OrchardCore.Taxonomies.Models; @@ -83,7 +83,7 @@ public async Task CreatePost(string id, string taxonomyContentIte var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition("Taxonomy"); - if (!contentTypeDefinition.GetSettings().Draftable) + if (!contentTypeDefinition.IsDraftable()) { taxonomy = await _contentManager.GetAsync(taxonomyContentItemId, VersionOptions.Latest); } @@ -190,7 +190,7 @@ public async Task EditPost(string taxonomyContentItemId, string t var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition("Taxonomy"); - if (!contentTypeDefinition.GetSettings().Draftable) + if (!contentTypeDefinition.IsDraftable()) { taxonomy = await _contentManager.GetAsync(taxonomyContentItemId, VersionOptions.Latest); } @@ -259,7 +259,7 @@ public async Task Delete(string taxonomyContentItemId, string tax var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition("Taxonomy"); - if (!contentTypeDefinition.GetSettings().Draftable) + if (!contentTypeDefinition.IsDraftable()) { taxonomy = await _contentManager.GetAsync(taxonomyContentItemId, VersionOptions.Latest); } diff --git a/src/OrchardCore.Modules/OrchardCore.Taxonomies/Controllers/TagController.cs b/src/OrchardCore.Modules/OrchardCore.Taxonomies/Controllers/TagController.cs index 5e103027984..4627cc5167e 100644 --- a/src/OrchardCore.Modules/OrchardCore.Taxonomies/Controllers/TagController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Taxonomies/Controllers/TagController.cs @@ -8,7 +8,7 @@ using OrchardCore.ContentManagement; using OrchardCore.ContentManagement.Handlers; using OrchardCore.ContentManagement.Metadata; -using OrchardCore.ContentManagement.Metadata.Settings; +using OrchardCore.ContentManagement.Metadata.Models; using OrchardCore.DisplayManagement.ModelBinding; using OrchardCore.Modules; using OrchardCore.Taxonomies.Models; @@ -52,19 +52,16 @@ public async Task CreatePost(string taxonomyContentItemId, string return Unauthorized(); } - ContentItem taxonomy; - var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition("Taxonomy"); + var versionOption = VersionOptions.Latest; - if (!contentTypeDefinition.GetSettings().Draftable) + if (contentTypeDefinition.IsDraftable()) { - taxonomy = await _contentManager.GetAsync(taxonomyContentItemId, VersionOptions.Latest); - } - else - { - taxonomy = await _contentManager.GetAsync(taxonomyContentItemId, VersionOptions.DraftRequired); + versionOption = VersionOptions.DraftRequired; } + var taxonomy = await _contentManager.GetAsync(taxonomyContentItemId, versionOption); + if (taxonomy == null) { return NotFound(); @@ -94,7 +91,7 @@ public async Task CreatePost(string taxonomyContentItemId, string taxonomy.Alter(part => part.Terms.Add(contentItem)); // Auto publish draftable taxonomies when creating a new tag term. - if (contentTypeDefinition.GetSettings().Draftable) + if (contentTypeDefinition.IsDraftable()) { await _contentManager.PublishAsync(taxonomy); } diff --git a/src/OrchardCore.Modules/OrchardCore.Taxonomies/Views/TaxonomyPart.Edit.cshtml b/src/OrchardCore.Modules/OrchardCore.Taxonomies/Views/TaxonomyPart.Edit.cshtml index d554a7ba83d..4ea23b0db11 100644 --- a/src/OrchardCore.Modules/OrchardCore.Taxonomies/Views/TaxonomyPart.Edit.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Taxonomies/Views/TaxonomyPart.Edit.cshtml @@ -3,8 +3,8 @@ @inject OrchardCore.ContentManagement.Display.IContentItemDisplayManager ContentItemDisplayManager @inject OrchardCore.DisplayManagement.ModelBinding.IUpdateModelAccessor ModelUpdaterAccessor @inject OrchardCore.ContentManagement.Metadata.IContentDefinitionManager ContentDefinitionManager -@using OrchardCore.ContentManagement.Metadata.Settings; - +@using OrchardCore.ContentManagement.Metadata.Settings +@using OrchardCore.ContentManagement.Metadata.Models @* This template is used to render the editor for a Taxonomy content item. It render the hierarchy of the terms. @@ -17,11 +17,11 @@ @{ var updater = ModelUpdaterAccessor.ModelUpdater; var canAddTerm = Model.TaxonomyPart.ContentItem.Id != 0; - var termContentTypes = ContentDefinitionManager.ListTypeDefinitions().Where(t => String.IsNullOrEmpty(t.GetSettings().Stereotype)).OrderBy(x => x.DisplayName); + var termContentTypes = ContentDefinitionManager.ListTypeDefinitions().Where(t => !t.HasStereotype()).OrderBy(x => x.DisplayName); var index = 0; }
    - + @@ -33,7 +33,6 @@ @if (termContentType != null) { div.menu-item-title', - relocate: function () { + relocate: function() { confirmLeave = true; $('#@Html.IdFor(m => m.Hierarchy)').attr('value', JSON.stringify($('#menu').nestedSortable('toHierarchy'))); } }); - window.onbeforeunload = function () { + window.onbeforeunload = function() { if (confirmLeave) { return $('#msg-leave').text(); } } - $('#menu').closest("form").on('submit', function (e) { + $('#menu').closest("form").on('submit', function(e) { confirmLeave = false; - window.onbeforeunload = function () { }; + window.onbeforeunload = function() { }; }); }); diff --git a/src/OrchardCore.Modules/OrchardCore.Templates/Settings/TemplateContentTypeDefinitionDriver.cs b/src/OrchardCore.Modules/OrchardCore.Templates/Settings/TemplateContentTypeDefinitionDriver.cs index 1ae8597a5fd..1b04ed128ca 100644 --- a/src/OrchardCore.Modules/OrchardCore.Templates/Settings/TemplateContentTypeDefinitionDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Templates/Settings/TemplateContentTypeDefinitionDriver.cs @@ -1,6 +1,5 @@ using Microsoft.Extensions.Localization; using OrchardCore.ContentManagement.Metadata.Models; -using OrchardCore.ContentManagement.Metadata.Settings; using OrchardCore.ContentTypes.Editors; using OrchardCore.DisplayManagement.Views; using OrchardCore.Templates.ViewModels; @@ -20,9 +19,7 @@ public override IDisplayResult Edit(ContentTypeDefinition contentTypeDefinition) { return Initialize("TemplateSettings", model => { - var stereotype = contentTypeDefinition.GetSettings().Stereotype; - - if (string.IsNullOrWhiteSpace(stereotype)) + if (!contentTypeDefinition.TryGetStereotype(out var stereotype)) { stereotype = "Content"; } diff --git a/src/OrchardCore.Modules/OrchardCore.Users/CustomUserSettingsPermissions.cs b/src/OrchardCore.Modules/OrchardCore.Users/CustomUserSettingsPermissions.cs index 79193016e08..3244386a091 100644 --- a/src/OrchardCore.Modules/OrchardCore.Users/CustomUserSettingsPermissions.cs +++ b/src/OrchardCore.Modules/OrchardCore.Users/CustomUserSettingsPermissions.cs @@ -4,7 +4,6 @@ using System.Threading.Tasks; using OrchardCore.ContentManagement.Metadata; using OrchardCore.ContentManagement.Metadata.Models; -using OrchardCore.ContentManagement.Metadata.Settings; using OrchardCore.Security.Permissions; namespace OrchardCore.Users @@ -23,7 +22,7 @@ public CustomUserSettingsPermissions(IContentDefinitionManager contentDefinition public Task> GetPermissionsAsync() => Task.FromResult(_contentDefinitionManager.ListTypeDefinitions() - .Where(x => x.GetSettings().Stereotype == "CustomUserSettings") + .Where(x => x.GetStereotype() == "CustomUserSettings") .Select(type => CreatePermissionForType(type))); public IEnumerable GetDefaultStereotypes() => Enumerable.Empty(); diff --git a/src/OrchardCore.Modules/OrchardCore.Users/Drivers/CustomUserSettingsDisplayDriver.cs b/src/OrchardCore.Modules/OrchardCore.Users/Drivers/CustomUserSettingsDisplayDriver.cs index 7fc9d47d973..424c5e22699 100644 --- a/src/OrchardCore.Modules/OrchardCore.Users/Drivers/CustomUserSettingsDisplayDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.Users/Drivers/CustomUserSettingsDisplayDriver.cs @@ -9,7 +9,6 @@ using OrchardCore.ContentManagement.Display; using OrchardCore.ContentManagement.Metadata; using OrchardCore.ContentManagement.Metadata.Models; -using OrchardCore.ContentManagement.Metadata.Settings; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.DisplayManagement.Views; using OrchardCore.Users.Models; @@ -88,7 +87,7 @@ public override async Task UpdateAsync(User user, UpdateEditorCo private IEnumerable GetContentTypeDefinitions() => _contentDefinitionManager .ListTypeDefinitions() - .Where(x => x.GetSettings().Stereotype == "CustomUserSettings"); + .Where(x => x.GetStereotype() == "CustomUserSettings"); private async Task GetUserSettingsAsync(User user, ContentTypeDefinition settingsType, Action isNew = null) { diff --git a/src/OrchardCore.Modules/OrchardCore.Widgets/Views/ContentCard-WidgetsListPart.Edit.cshtml b/src/OrchardCore.Modules/OrchardCore.Widgets/Views/ContentCard-WidgetsListPart.Edit.cshtml index 2c9937a307e..eef24fbdcd4 100644 --- a/src/OrchardCore.Modules/OrchardCore.Widgets/Views/ContentCard-WidgetsListPart.Edit.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Widgets/Views/ContentCard-WidgetsListPart.Edit.cshtml @@ -1,11 +1,11 @@ @using OrchardCore.ContentManagement.Metadata.Settings; @using OrchardCore.Localization - +@using OrchardCore.ContentManagement.Metadata.Models @inject OrchardCore.ContentManagement.Metadata.IContentDefinitionManager ContentDefinitionManager @{ var contentType = ContentDefinitionManager.GetTypeDefinition((string)Model.ContentItem.ContentType).DisplayName; - var widgetContentTypes = ContentDefinitionManager.ListTypeDefinitions().Where(t => t.GetSettings().Stereotype == "Widget"); + var widgetContentTypes = ContentDefinitionManager.ListTypeDefinitions().Where(t => t.GetStereotype() == "Widget"); }
    @@ -27,18 +27,20 @@ } diff --git a/src/OrchardCore.Modules/OrchardCore.Widgets/Views/WidgetsListPart.Edit.cshtml b/src/OrchardCore.Modules/OrchardCore.Widgets/Views/WidgetsListPart.Edit.cshtml index 2319b0ca6cd..cf4483b58ec 100644 --- a/src/OrchardCore.Modules/OrchardCore.Widgets/Views/WidgetsListPart.Edit.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Widgets/Views/WidgetsListPart.Edit.cshtml @@ -2,6 +2,7 @@ @using OrchardCore.Mvc.Utilities; @using OrchardCore.Widgets.Models; @using OrchardCore.Widgets.ViewModels; +@using OrchardCore.ContentManagement.Metadata.Models; @model WidgetsListPartEditViewModel @@ -11,7 +12,7 @@ @{ var htmlFieldPrefix = ViewContext.ViewData.TemplateInfo.HtmlFieldPrefix; - var widgetContentTypes = ContentDefinitionManager.ListTypeDefinitions().Where(t => t.GetSettings().Stereotype == "Widget"); + var widgetContentTypes = ContentDefinitionManager.ListTypeDefinitions().Where(t => t.GetStereotype() == "Widget"); var parentContentType = Model.WidgetsListPart.ContentItem.ContentType; string partName = ((dynamic)Model).Metadata.Name; } @@ -23,13 +24,13 @@ { var widgetTemplatePlaceholderId = Guid.NewGuid().ToString("n"); -
    -
    +
    +
    @zone -
    -
    -
    -
    +
    +
    +
    +
    @if (Model.WidgetsListPart.Widgets.ContainsKey(zone)) { @@ -38,125 +39,124 @@ { //Create a Card Shape dynamic contentCard = await New.ContentCard( - //For Updater - CollectionShape: Model, - //Shape Specific - CollectionShapeType: nameof(WidgetsListPart), - ContentItem: widget, - BuildEditor: true, - ParentContentType: parentContentType, - CollectionPartName: partName, - //WidgetListPart Specific - ZoneValue: zone, - //Card Specific Properties - TargetId: widgetTemplatePlaceholderId, - Inline: false, - CanMove: true, - CanDelete: true, - //Input hidden - //Prefixes - HtmlFieldPrefix: htmlFieldPrefix, - PrefixValue: htmlFieldPrefix + '-' + zone + '-' + (index++).ToString(), - PrefixesId: Html.IdFor(x => x.Prefixes), - PrefixesName: Html.NameFor(x => x.Prefixes), - //Content Types - ContentTypesId: Html.IdFor(x => x.ContentTypes), - ContentTypesName: Html.NameFor(x => x.ContentTypes), - //Content Items - ContentItemsId: Html.IdFor(x => x.ContentItems), - ContentItemsName: Html.NameFor(x => x.ContentItems), - //Zone - ZonesId: Html.IdFor(x => x.Zones), - ZonesName: Html.NameFor(x => x.Zones) + //For Updater + CollectionShape: Model, + //Shape Specific + CollectionShapeType: nameof(WidgetsListPart), + ContentItem: widget, + BuildEditor: true, + ParentContentType: parentContentType, + CollectionPartName: partName, + //WidgetListPart Specific + ZoneValue: zone, + //Card Specific Properties + TargetId: widgetTemplatePlaceholderId, + Inline: false, + CanMove: true, + CanDelete: true, + //Input hidden + //Prefixes + HtmlFieldPrefix: htmlFieldPrefix, + PrefixValue: htmlFieldPrefix + '-' + zone + '-' + (index++).ToString(), + PrefixesId: Html.IdFor(x => x.Prefixes), + PrefixesName: Html.NameFor(x => x.Prefixes), + //Content Types + ContentTypesId: Html.IdFor(x => x.ContentTypes), + ContentTypesName: Html.NameFor(x => x.ContentTypes), + //Content Items + ContentItemsId: Html.IdFor(x => x.ContentItems), + ContentItemsName: Html.NameFor(x => x.ContentItems), + //Zone + ZonesId: Html.IdFor(x => x.Zones), + ZonesName: Html.NameFor(x => x.Zones) ); @await DisplayAsync(contentCard) } } - -
    -
    -
    -
    - - +
    +
    +
    + +
    -
    } @if (Context.Items["WidgetsListPart.Edit"] == null) @@ -169,9 +169,9 @@ await DisplayAsync(await ContentItemDisplayManager.BuildEditorAsync(contentItem, Model.Updater, true, "", Guid.NewGuid().ToString("n"))); } - - + + }
    diff --git a/src/OrchardCore/OrchardCore.ContentManagement.Abstractions/Metadata/Models/ContentTypeExtensions.cs b/src/OrchardCore/OrchardCore.ContentManagement.Abstractions/Metadata/Models/ContentTypeExtensions.cs index 266bba21d26..8b12fc147fb 100644 --- a/src/OrchardCore/OrchardCore.ContentManagement.Abstractions/Metadata/Models/ContentTypeExtensions.cs +++ b/src/OrchardCore/OrchardCore.ContentManagement.Abstractions/Metadata/Models/ContentTypeExtensions.cs @@ -5,12 +5,19 @@ namespace OrchardCore.ContentManagement.Metadata.Models; public static class ContentTypeExtensions { + public static bool TryGetStereotype(this ContentTypeDefinition contentTypeDefinition, out string stereotype) + { + stereotype = contentTypeDefinition.GetStereotype(); + + return !String.IsNullOrWhiteSpace(stereotype); + } + public static bool HasStereotype(this ContentTypeDefinition contentTypeDefinition) { - return !String.IsNullOrEmpty(contentTypeDefinition.GetStereotypeOrDefault()); + return !String.IsNullOrEmpty(contentTypeDefinition.GetStereotype()); } - public static string GetStereotypeOrDefault(this ContentTypeDefinition contentTypeDefinition) + public static string GetStereotype(this ContentTypeDefinition contentTypeDefinition) { return contentTypeDefinition.GetSettings().Stereotype; } @@ -42,7 +49,7 @@ public static bool IsSecurable(this ContentTypeDefinition contentTypeDefinition) public static bool HasDescription(this ContentTypeDefinition contentTypeDefinition) { - return !String.IsNullOrEmpty(contentTypeDefinition.GetSettings().Description); + return !String.IsNullOrWhiteSpace(contentTypeDefinition.GetSettings().Description); } public static string GetDescription(this ContentTypeDefinition contentTypeDefinition) diff --git a/src/OrchardCore/OrchardCore.ContentManagement.Display/ContentDisplay/ContentItemDisplayCoordinator.cs b/src/OrchardCore/OrchardCore.ContentManagement.Display/ContentDisplay/ContentItemDisplayCoordinator.cs index c0a467a8624..408a7f30a8a 100644 --- a/src/OrchardCore/OrchardCore.ContentManagement.Display/ContentDisplay/ContentItemDisplayCoordinator.cs +++ b/src/OrchardCore/OrchardCore.ContentManagement.Display/ContentDisplay/ContentItemDisplayCoordinator.cs @@ -67,8 +67,7 @@ public async Task BuildDisplayAsync(ContentItem contentItem, BuildDisplayContext } } - var settings = contentTypeDefinition?.GetSettings(); - var stereotype = settings?.Stereotype ?? String.Empty; + var hasStereotype = contentTypeDefinition.TryGetStereotype(out var stereotype); foreach (var contentTypePartDefinition in contentTypeDefinition.Parts) { @@ -126,7 +125,7 @@ public async Task BuildDisplayAsync(ContentItem contentItem, BuildDisplayContext // e.g. LandingPage-ServicePart, LandingPage-ServicePart.Summary ctx.Shape.Metadata.Alternates.Add($"{contentType}{displayType}__{partTypeName}"); - if (!String.IsNullOrEmpty(stereotype)) + if (hasStereotype) { // [Stereotype]_[DisplayType]__[PartType], // e.g. Widget-ServicePart @@ -145,7 +144,7 @@ public async Task BuildDisplayAsync(ContentItem contentItem, BuildDisplayContext // e.g. Employee-Address1, Employee-Address2 ctx.Shape.Metadata.Alternates.Add($"{contentType}{displayType}__{partName}"); - if (!String.IsNullOrEmpty(stereotype)) + if (hasStereotype) { // [Stereotype]_[DisplayType]__[PartType]__[PartName] // e.g. Widget-Services diff --git a/src/OrchardCore/OrchardCore.ContentManagement.Display/ContentDisplay/ContentPartDisplayDriverTPart.cs b/src/OrchardCore/OrchardCore.ContentManagement.Display/ContentDisplay/ContentPartDisplayDriverTPart.cs index ece11fe178c..892a114504c 100644 --- a/src/OrchardCore/OrchardCore.ContentManagement.Display/ContentDisplay/ContentPartDisplayDriverTPart.cs +++ b/src/OrchardCore/OrchardCore.ContentManagement.Display/ContentDisplay/ContentPartDisplayDriverTPart.cs @@ -3,7 +3,6 @@ using System.Threading.Tasks; using OrchardCore.ContentManagement.Display.Models; using OrchardCore.ContentManagement.Metadata.Models; -using OrchardCore.ContentManagement.Metadata.Settings; using OrchardCore.DisplayManagement; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.DisplayManagement.ModelBinding; @@ -34,15 +33,6 @@ public override ShapeResult Factory(string shapeType, Func(); - - if (settings != null) - { - stereotype = settings.Stereotype; - } - var partName = _typePartDefinition.Name; var partType = _typePartDefinition.PartDefinition.Name; var contentType = _typePartDefinition.ContentTypeDefinition.Name; @@ -71,6 +61,8 @@ public override ShapeResult Factory(string shapeType, Func { + var stereotype = _typePartDefinition.ContentTypeDefinition.GetStereotype() ?? String.Empty; + string[] displayTypes; if (editorPartType == shapeType) diff --git a/src/OrchardCore/OrchardCore.ContentManagement.Display/ContentItemDisplayManager.cs b/src/OrchardCore/OrchardCore.ContentManagement.Display/ContentItemDisplayManager.cs index 56b4b8607f6..ddd58acb4ac 100644 --- a/src/OrchardCore/OrchardCore.ContentManagement.Display/ContentItemDisplayManager.cs +++ b/src/OrchardCore/OrchardCore.ContentManagement.Display/ContentItemDisplayManager.cs @@ -6,7 +6,7 @@ using OrchardCore.ContentManagement.Display.ContentDisplay; using OrchardCore.ContentManagement.Handlers; using OrchardCore.ContentManagement.Metadata; -using OrchardCore.ContentManagement.Metadata.Settings; +using OrchardCore.ContentManagement.Metadata.Models; using OrchardCore.DisplayManagement; using OrchardCore.DisplayManagement.Descriptors; using OrchardCore.DisplayManagement.Handlers; @@ -63,15 +63,14 @@ public async Task BuildDisplayAsync(ContentItem contentItem, IUpdateMode throw new NullReferenceException($"Content Type {contentItem.ContentType} does not exist."); } - var stereotype = contentTypeDefinition.GetSettings().Stereotype; var actualDisplayType = String.IsNullOrEmpty(displayType) ? "Detail" : displayType; - var hasStereotype = !String.IsNullOrWhiteSpace(stereotype); + var hasStereotype = contentTypeDefinition.TryGetStereotype(out var stereotype); var actualShapeType = "Content"; if (hasStereotype) { - actualShapeType = stereotype; + actualShapeType = contentTypeDefinition.GetStereotype(); } // [DisplayType] is only added for the ones different than Detail @@ -140,8 +139,7 @@ public async Task BuildEditorAsync(ContentItem contentItem, IUpdateModel throw new NullReferenceException($"Content Type {contentItem.ContentType} does not exist."); } - var stereotype = contentTypeDefinition.GetSettings().Stereotype; - var hasStereotype = !String.IsNullOrWhiteSpace(stereotype); + var hasStereotype = contentTypeDefinition.TryGetStereotype(out var stereotype); var actualShapeType = "Content_Edit"; if (hasStereotype) @@ -196,8 +194,7 @@ public async Task UpdateEditorAsync(ContentItem contentItem, IUpdateMode throw new NullReferenceException($"Content Type {contentItem.ContentType} does not exist."); } - var stereotype = contentTypeDefinition.GetSettings().Stereotype; - var hasStereotype = !String.IsNullOrWhiteSpace(stereotype); + var hasStereotype = contentTypeDefinition.TryGetStereotype(out var stereotype); var actualShapeType = "Content_Edit"; if (hasStereotype) diff --git a/src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Queries/ContentTypeQuery.cs b/src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Queries/ContentTypeQuery.cs index ba0d12327c3..17cc00f4fbc 100644 --- a/src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Queries/ContentTypeQuery.cs +++ b/src/OrchardCore/OrchardCore.ContentManagement.GraphQL/Queries/ContentTypeQuery.cs @@ -1,4 +1,3 @@ -using System; using System.Linq; using System.Threading.Tasks; using GraphQL.Types; @@ -10,7 +9,7 @@ using OrchardCore.ContentManagement.GraphQL.Options; using OrchardCore.ContentManagement.GraphQL.Queries.Types; using OrchardCore.ContentManagement.Metadata; -using OrchardCore.ContentManagement.Metadata.Settings; +using OrchardCore.ContentManagement.Metadata.Models; using OrchardCore.Contents; namespace OrchardCore.ContentManagement.GraphQL.Queries @@ -71,10 +70,8 @@ public Task BuildAsync(ISchema schema) builder.Build(query, typeDefinition, typeType); } - var settings = typeDefinition.GetSettings(); - // Only add queries over standard content types - if (settings == null || String.IsNullOrWhiteSpace(settings.Stereotype)) + if (!typeDefinition.HasStereotype()) { schema.Query.AddField(query); } diff --git a/src/OrchardCore/OrchardCore.ContentManagement/DefaultContentManager.cs b/src/OrchardCore/OrchardCore.ContentManagement/DefaultContentManager.cs index 9196b196006..9f3623d4dc1 100644 --- a/src/OrchardCore/OrchardCore.ContentManagement/DefaultContentManager.cs +++ b/src/OrchardCore/OrchardCore.ContentManagement/DefaultContentManager.cs @@ -10,7 +10,7 @@ using OrchardCore.ContentManagement.Handlers; using OrchardCore.ContentManagement.Metadata; using OrchardCore.ContentManagement.Metadata.Builders; -using OrchardCore.ContentManagement.Metadata.Settings; +using OrchardCore.ContentManagement.Metadata.Models; using OrchardCore.ContentManagement.Records; using OrchardCore.Modules; using YesSql; @@ -227,7 +227,7 @@ public async Task GetAsync(string contentItemId, VersionOptions opt var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(contentItem.ContentType); // Check if not versionable, meaning we use only one version - if (!(contentTypeDefinition?.GetSettings().Versionable ?? true)) + if (contentTypeDefinition != null && !contentTypeDefinition.IsVersionable()) { contentItem.Published = false; }