--HG--
branch : dev
This commit is contained in:
Andre Rodrigues 2010-12-01 16:42:55 -08:00
commit 3c9b2c8489
12 changed files with 137 additions and 19 deletions

View File

@ -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<ContainablePart> {
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;
}

View File

@ -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<ContainerPart> {
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<ContainerPartRecord> repository, IOrchardServices orchardServices) {
public ContainerPartHandler(IRepository<ContainerPartRecord> repository) {
Filters.Add(StorageFilter.For(repository));
OnInitializing<ContainerPart>((context, part) => {
part.Record.PageSize = part.Settings.GetModel<ContainerTypePartSettings>().PageSizeDefault

View File

@ -1,8 +1,17 @@
<Placement>
<!-- available display shapes -->
<!--
Parts_Container_Contained
Parts_Container_Contained_Summary
Parts_Container_Contained_SummaryAdmin
-->
<Place Parts_Containable_Edit="Content:before.3"/>
<Place Parts_Container_Edit="Content:5"/>
<Place Parts_ContainerCustom_Edit="Content:5"/>
<Place Parts_ContainerWidget_Edit="Content:5"/>
<Place Parts_Container_SiteSettings="Content:10"/>
<Place Parts_ContainerWidget="Content"/>
<Match DisplayType="SummaryAdmin">
<Place Parts_Container_Contained_SummaryAdmin="Actions:10"/>
</Match>
</Placement>

View File

@ -0,0 +1,9 @@
@using Orchard.ContentManagement;
@using Orchard.Core.Containers.Models;
@using Orchard.Utility.Extensions;
@{
ContentPart contentPart = Model.ContentPart;
}
@if (contentPart.Is<ContainerPart>()) {
@Html.Link(T("Contained Items").Text, Url.Action("List", "Admin", new { area = "Contents", containerId = contentPart.Id }))@T(" | ")
}

View File

@ -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<CommonPartRecord>().Where(cr => cr.Container.Id == model.ContainerId);
}
switch (model.Options.OrderBy) {
case ContentsOrder.Modified:

View File

@ -2,6 +2,7 @@
<!-- available display shapes -->
<!--
Parts_Contents_Publish
Parts_Contents_Publish_Summary
Parts_Contents_Publish_SummaryAdmin
-->
<!-- edit "shape" -->

View File

@ -5,8 +5,6 @@ using Orchard.Mvc.Routes;
namespace Orchard.Core.Contents {
public class Routes : IRouteProvider {
#region IRouteProvider Members
public void GetRoutes(ICollection<RouteDescriptor> 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
}
}

View File

@ -370,6 +370,9 @@
<Content Include="Routable\Views\Parts\RoutableTitle_Summary.cshtml" />
<Content Include="Routable\Views\Parts\RoutableTitle_SummaryAdmin.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Containers\Views\Parts\Container.Contained.SummaryAdmin.cshtml" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@ -0,0 +1,32 @@
using Orchard.ContentManagement;
using Orchard.Localization;
using Orchard.UI.Navigation;
namespace Orchard.Lists {
public class AdminMenu : INavigationProvider {
private const string ListContentTypeName = "List";
private readonly IContentManager _contentManager;
public AdminMenu(IContentManager contentManager) {
_contentManager = contentManager;
}
public Localizer T { get; set; }
public string MenuName { get { return "admin"; } }
public void GetNavigation(NavigationBuilder builder) {
builder.Add(T("Lists"), "3", BuildMenu);
}
private void BuildMenu(NavigationItemBuilder menu) {
menu.Add(T("Manage Lists"), "1.0",
item => item.Action("List", "Admin", new { area = "Contents", id = ListContentTypeName }));
var ci = _contentManager.New(ListContentTypeName);
var metadata = _contentManager.GetItemMetadata(ci);
menu.Add(T("Create New List"), "1.5",
item => item.Action(metadata.CreateRouteValues["Action"] as string, metadata.CreateRouteValues["Controller"] as string, metadata.CreateRouteValues));
}
}
}

View File

@ -46,6 +46,7 @@
<Reference Include="System.Web" />
</ItemGroup>
<ItemGroup>
<Compile Include="AdminMenu.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Content Include="Module.txt" />
</ItemGroup>
@ -62,7 +63,12 @@
<ItemGroup>
<Compile Include="Migrations.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Content Include="Views\Items\Content-List.SummaryAdmin.cshtml" />
</ItemGroup>
<ItemGroup>
<None Include="Placement.info" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@ -0,0 +1,7 @@
<Placement>
<Match ContentType="List">
<Match DisplayType="SummaryAdmin">
<Place Parts_Container_Contained_SummaryAdmin="-"/>
</Match>
</Match>
</Placement>

View File

@ -0,0 +1,28 @@
@using Orchard.ContentManagement;
@using Orchard.Utility.Extensions;
@{
ContentItem contentItem = Model.ContentItem;
string returnUrl = ViewContext.RequestContext.HttpContext.Request.ToUrlString();
ContentItemMetadata contentItemMetadata = contentItem.ContentManager.GetItemMetadata(contentItem);
}
<div class="summary" itemscope="itemscope" itemid="@contentItem.Id" itemtype="http://orchardproject.net/data/ContentItem">
<div class="properties">
<input type="checkbox" value="@contentItem.Id" name="itemIds"/>
<h3>@Html.Link(contentItemMetadata.DisplayText, Url.Action("List", "Admin", new { area = "Contents", containerId = contentItem.Id }))</h3>
@if (Model.Header != null) {
<div class="header">@Display(Model.Header)</div>
}
@if (Model.Meta != null) {
<div class="metadata">@Display(Model.Meta)</div>
}
</div>
<div class="related">
@Display(Model.Actions)
@Html.Link(T("List Items").Text, Url.Action("List", "Admin", new { area = "Contents", containerId = contentItem.Id }))@T(" | ")
@Html.ItemEditLink(T("Edit").Text, contentItem) @T(" | ")
@Html.Link(T("Remove").Text, Url.Action("Remove", "Admin", new { area = "Contents", id = contentItem.Id, returnUrl }), new { itemprop = "RemoveUrl UnsafeUrl" })
</div>
@if (Model.Content != null) {
<div class="primary">@Display(Model.Content)</div>
}
</div>