diff --git a/src/Orchard.Web/Core/Containers/Drivers/ContainablePartDriver.cs b/src/Orchard.Web/Core/Containers/Drivers/ContainablePartDriver.cs index 7f33c0b18..81ab2c936 100644 --- a/src/Orchard.Web/Core/Containers/Drivers/ContainablePartDriver.cs +++ b/src/Orchard.Web/Core/Containers/Drivers/ContainablePartDriver.cs @@ -7,20 +7,14 @@ using Orchard.ContentManagement.Drivers; using Orchard.Core.Containers.Models; using Orchard.Core.Containers.ViewModels; using Orchard.Core.Routable.Models; -using Orchard.Core.Routable.Services; using Orchard.Localization; -using Orchard.UI.Notify; namespace Orchard.Core.Containers.Drivers { public class ContainablePartDriver : ContentPartDriver { private readonly IContentManager _contentManager; - private readonly IRoutableService _routableService; - private readonly IOrchardServices _services; - public ContainablePartDriver(IContentManager contentManager, IRoutableService routableService, IOrchardServices services) { + public ContainablePartDriver(IContentManager contentManager) { _contentManager = contentManager; - _routableService = routableService; - _services = services; T = NullLocalizer.Instance; } diff --git a/src/Orchard.Web/Core/Containers/Drivers/ContainerPartDriver.cs b/src/Orchard.Web/Core/Containers/Drivers/ContainerPartDriver.cs index 8f4168a53..0cd207dde 100644 --- a/src/Orchard.Web/Core/Containers/Drivers/ContainerPartDriver.cs +++ b/src/Orchard.Web/Core/Containers/Drivers/ContainerPartDriver.cs @@ -1,17 +1,50 @@ -using Orchard.ContentManagement; +using System.Linq; +using Orchard.ContentManagement; using Orchard.ContentManagement.Drivers; using Orchard.ContentManagement.Handlers; +using Orchard.ContentManagement.MetaData; using Orchard.Core.Common.Models; using Orchard.Core.Containers.Models; using Orchard.Core.Containers.Settings; using Orchard.Data; +using Orchard.Localization; +using Orchard.UI.Notify; namespace Orchard.Core.Containers.Drivers { public class ContainerPartDriver : ContentPartDriver { + private readonly IContentDefinitionManager _contentDefinitionManager; + + public ContainerPartDriver(IContentDefinitionManager contentDefinitionManager, IOrchardServices orchardServices) { + _contentDefinitionManager = contentDefinitionManager; + Services = orchardServices; + T = NullLocalizer.Instance; + } + + public IOrchardServices Services { get; private set; } + public Localizer T { get; set; } + + protected override DriverResult Display(ContainerPart part, string displayType, dynamic shapeHelper) { + return Combined( + ContentShape("Parts_Container_Contained", + () => shapeHelper.Parts_Container_Contained(ContentPart: part)), + ContentShape("Parts_Container_Contained_Summary", + () => shapeHelper.Parts_Container_Contained_Summary(ContentPart: part)), + ContentShape("Parts_Container_Contained_SummaryAdmin", + () => shapeHelper.Parts_Container_Contained_SummaryAdmin(ContentPart: part)) + ); + } + protected override DriverResult Editor(ContainerPart part, dynamic shapeHelper) { return Editor(part, null, shapeHelper); } - protected override DriverResult Editor(ContainerPart part, ContentManagement.IUpdateModel updater, dynamic shapeHelper) { + + protected override DriverResult Editor(ContainerPart part, IUpdateModel updater, dynamic shapeHelper) { + // if there are no containable items then show a nice little warning + if (!_contentDefinitionManager.ListTypeDefinitions() + .Where(typeDefinition => typeDefinition.Parts.Any(partDefinition => partDefinition.PartDefinition.Name == "ContainablePart")).Any()) { + Services.Notifier.Warning(T("There are no content types in the system with a Containable part attached. Consider adding a Containable part to some content type, existing or new, in order to relate items to this (Container enabled) item.")); + } + return ContentShape( "Parts_Container_Edit", () => { @@ -24,7 +57,7 @@ namespace Orchard.Core.Containers.Drivers { } public class ContainerPartHandler : ContentHandler { - public ContainerPartHandler(IRepository repository, IOrchardServices orchardServices) { + public ContainerPartHandler(IRepository repository) { Filters.Add(StorageFilter.For(repository)); OnInitializing((context, part) => { part.Record.PageSize = part.Settings.GetModel().PageSizeDefault diff --git a/src/Orchard.Web/Core/Containers/Placement.info b/src/Orchard.Web/Core/Containers/Placement.info index 44a4aaa1b..b98c878cd 100644 --- a/src/Orchard.Web/Core/Containers/Placement.info +++ b/src/Orchard.Web/Core/Containers/Placement.info @@ -1,8 +1,17 @@  + + + + + diff --git a/src/Orchard.Web/Core/Containers/Views/Parts/Container.Contained.SummaryAdmin.cshtml b/src/Orchard.Web/Core/Containers/Views/Parts/Container.Contained.SummaryAdmin.cshtml new file mode 100644 index 000000000..1a1a0534a --- /dev/null +++ b/src/Orchard.Web/Core/Containers/Views/Parts/Container.Contained.SummaryAdmin.cshtml @@ -0,0 +1,9 @@ +@using Orchard.ContentManagement; +@using Orchard.Core.Containers.Models; +@using Orchard.Utility.Extensions; +@{ + ContentPart contentPart = Model.ContentPart; +} +@if (contentPart.Is()) { + @Html.Link(T("Contained Items").Text, Url.Action("List", "Admin", new { area = "Contents", containerId = contentPart.Id }))@T(" | ") +} \ No newline at end of file diff --git a/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs b/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs index 5c6411d5b..65c8be665 100644 --- a/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs +++ b/src/Orchard.Web/Core/Contents/Controllers/AdminController.cs @@ -8,7 +8,6 @@ using Orchard.ContentManagement; using Orchard.ContentManagement.Aspects; using Orchard.ContentManagement.MetaData; using Orchard.ContentManagement.MetaData.Models; -using Orchard.ContentManagement.Records; using Orchard.Core.Common.Models; using Orchard.Core.Contents.Settings; using Orchard.Core.Contents.ViewModels; @@ -62,9 +61,10 @@ namespace Orchard.Core.Contents.Controllers { : contentTypeDefinition.Name; query = query.ForType(model.TypeName); } - - if (model.ContainerId != null) + // content type and container filters are mutually exclusive + else if (model.ContainerId != null) { query = query.Join().Where(cr => cr.Container.Id == model.ContainerId); + } switch (model.Options.OrderBy) { case ContentsOrder.Modified: diff --git a/src/Orchard.Web/Core/Contents/Placement.info b/src/Orchard.Web/Core/Contents/Placement.info index 143f76215..c481eed8f 100644 --- a/src/Orchard.Web/Core/Contents/Placement.info +++ b/src/Orchard.Web/Core/Contents/Placement.info @@ -2,6 +2,7 @@ diff --git a/src/Orchard.Web/Core/Contents/Routes.cs b/src/Orchard.Web/Core/Contents/Routes.cs index 09ec9a84f..0e40f779e 100644 --- a/src/Orchard.Web/Core/Contents/Routes.cs +++ b/src/Orchard.Web/Core/Contents/Routes.cs @@ -5,8 +5,6 @@ using Orchard.Mvc.Routes; namespace Orchard.Core.Contents { public class Routes : IRouteProvider { - #region IRouteProvider Members - public void GetRoutes(ICollection routes) { foreach (RouteDescriptor routeDescriptor in GetRoutes()) { routes.Add(routeDescriptor); @@ -18,7 +16,7 @@ namespace Orchard.Core.Contents { new RouteDescriptor { Priority = 5, Route = new Route( - "Admin/Contents/List/{id}/InContainer/{containerId}", + "Admin/Contents/List/InContainer/{containerId}", new RouteValueDictionary { {"area", "Contents"}, {"controller", "Admin"}, @@ -32,7 +30,5 @@ namespace Orchard.Core.Contents { } }; } - - #endregion } } \ No newline at end of file diff --git a/src/Orchard.Web/Core/Orchard.Core.csproj b/src/Orchard.Web/Core/Orchard.Core.csproj index 4be7b7e50..74290bf2d 100644 --- a/src/Orchard.Web/Core/Orchard.Core.csproj +++ b/src/Orchard.Web/Core/Orchard.Core.csproj @@ -370,6 +370,9 @@ + + +