mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-07-16 07:04:52 +08:00
parent
cee5f3bb47
commit
5ca9b03741
@ -88,7 +88,8 @@ namespace Orchard.Core.Navigation.Drivers {
|
||||
}
|
||||
|
||||
protected override void Exporting(MenuPart part, ContentManagement.Handlers.ExportContentContext context) {
|
||||
var menuIdentity = _orchardServices.ContentManager.GetItemMetadata(_orchardServices.ContentManager.Get(part.Menu.Id)).Identity;
|
||||
var menu = _orchardServices.ContentManager.Get(part.Menu.Id);
|
||||
var menuIdentity = _orchardServices.ContentManager.GetItemMetadata(menu).Identity;
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("Menu", menuIdentity);
|
||||
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("MenuText", part.MenuText);
|
||||
|
39
src/Orchard.Web/Core/Navigation/Handlers/MenuHandler.cs
Normal file
39
src/Orchard.Web/Core/Navigation/Handlers/MenuHandler.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Core.Navigation.Services;
|
||||
using Orchard.Core.Title.Models;
|
||||
|
||||
namespace Orchard.Core.Navigation.Handlers {
|
||||
[UsedImplicitly]
|
||||
public class MenuHandler : ContentHandler {
|
||||
private readonly IMenuService _menuService;
|
||||
private readonly IContentManager _contentManager;
|
||||
|
||||
public MenuHandler(IMenuService menuService, IContentManager contentManager) {
|
||||
_menuService = menuService;
|
||||
_contentManager = contentManager;
|
||||
}
|
||||
|
||||
protected override void GetItemMetadata(GetContentItemMetadataContext context) {
|
||||
if(context.ContentItem.ContentType != "Menu") {
|
||||
return;
|
||||
}
|
||||
|
||||
context.Metadata.Identity.Add("name", context.ContentItem.As<TitlePart>().Title);
|
||||
}
|
||||
|
||||
protected override void Removing(RemoveContentContext context) {
|
||||
if (context.ContentItem.ContentType != "Menu") {
|
||||
return;
|
||||
}
|
||||
|
||||
// remove all menu items
|
||||
var menuParts = _menuService.GetMenuParts(context.ContentItem.Id);
|
||||
|
||||
foreach(var menuPart in menuParts) {
|
||||
_contentManager.Remove(menuPart.ContentItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -41,7 +41,6 @@ namespace Orchard.Core.Navigation {
|
||||
ContentDefinitionManager.AlterTypeDefinition("Menu", cfg => cfg
|
||||
.WithPart("CommonPart", p => p.WithSetting("OwnerEditorSettings.ShowOwnerEditor", "false"))
|
||||
.WithPart("TitlePart")
|
||||
.WithPart("Identity")
|
||||
);
|
||||
|
||||
SchemaBuilder.CreateTable("MenuWidgetPartRecord", table => table
|
||||
@ -123,7 +122,6 @@ namespace Orchard.Core.Navigation {
|
||||
ContentDefinitionManager.AlterTypeDefinition("Menu", cfg => cfg
|
||||
.WithPart("CommonPart")
|
||||
.WithPart("TitlePart")
|
||||
.WithPart("Identity")
|
||||
);
|
||||
|
||||
SchemaBuilder.CreateTable("MenuWidgetPartRecord",table => table
|
||||
|
@ -7,4 +7,4 @@ OrchardVersion: 1.4.2
|
||||
Description: The navigation module creates and manages a simple navigation menu for the front-end of the application and allows you to add content items to the admin menu.
|
||||
FeatureDescription: Menu management.
|
||||
Category: Core
|
||||
FeatureDependencies: Orchard.ContentPicker
|
||||
FeatureDependencies: Orchard.ContentPicker, Title
|
||||
|
@ -24,7 +24,7 @@
|
||||
}
|
||||
</select>
|
||||
<button type="submit" class="apply-bulk-actions-auto">@T("Show")</button>
|
||||
@Html.ActionLink(T("Edit").Text, "Edit", "Admin", new { area = "Contents", id = Model.CurrentMenu.Id, returnUrl = Request.RawUrl }, new { @class = "button" })
|
||||
@Html.ActionLink(T("Edit").Text, "Edit", "Admin", new { area = "Contents", id = Model.CurrentMenu.Id, returnUrl = Url.Action("Index", "Admin", new { area = "Navigation" }) }, new { @class = "button" })
|
||||
</fieldset>
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,25 @@
|
||||
@{
|
||||
Model.Sidebar.Add(New.Menu_DeleteButton().ContentItem(Model.ContentItem), "25");
|
||||
}
|
||||
|
||||
<div class="edit-item">
|
||||
<div class="edit-item-primary">
|
||||
@if (Model.Content != null) {
|
||||
<div class="edit-item-content">
|
||||
@Display(Model.Content)
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="edit-item-secondary group">
|
||||
@if (Model.Actions != null) {
|
||||
<div class="edit-item-actions">
|
||||
@Display(Model.Actions)
|
||||
</div>
|
||||
}
|
||||
@if (Model.Sidebar != null) {
|
||||
<div class="edit-item-sidebar group">
|
||||
@Display(Model.Sidebar)
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,14 @@
|
||||
@using Orchard.ContentManagement;
|
||||
@using Orchard.Core.Contents
|
||||
@using Orchard.Utility.Extensions;
|
||||
|
||||
@{
|
||||
ContentItem contentItem = Model.ContentItem;
|
||||
string returnUrl = Request["returnUrl"];
|
||||
}
|
||||
|
||||
@if (Authorizer.Authorize(Permissions.DeleteContent, contentItem)) {
|
||||
<fieldset class="delete-button">
|
||||
@Html.Link(T("Delete").Text, Url.ItemRemoveUrl(contentItem, new {returnUrl}), new { @class = "button", itemprop = "RemoveUrl UnsafeUrl"})
|
||||
</fieldset>
|
||||
}
|
26
src/Orchard.Web/Core/Navigation/Views/Menu.Edit.cshtml
Normal file
26
src/Orchard.Web/Core/Navigation/Views/Menu.Edit.cshtml
Normal file
@ -0,0 +1,26 @@
|
||||
@{
|
||||
Model.Sidebar.Add("Foo");
|
||||
}
|
||||
|
||||
<div class="edit-item">
|
||||
<div class="edit-item-primary">
|
||||
@if (Model.Content != null) {
|
||||
<div class="edit-item-content">
|
||||
@Display(Model.Content)
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="edit-item-secondary group">
|
||||
@if (Model.Actions != null) {
|
||||
<div class="edit-item-actions">
|
||||
@Display(Model.Actions)
|
||||
</div>
|
||||
}
|
||||
@if (Model.Sidebar != null) {
|
||||
<div class="edit-item-sidebar group">
|
||||
@Display(Model.Sidebar)
|
||||
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
@ -136,6 +136,7 @@
|
||||
<Compile Include="Navigation\Drivers\MenuWidgetPartDriver.cs" />
|
||||
<Compile Include="Navigation\Handlers\AdminMenuPartHandler.cs" />
|
||||
<Compile Include="Navigation\Handlers\ContentMenuItemPartHandler.cs" />
|
||||
<Compile Include="Navigation\Handlers\MenuHandler.cs" />
|
||||
<Compile Include="Navigation\Handlers\MenuWidgetPartHandler.cs" />
|
||||
<Compile Include="Navigation\Models\AdminMenuPart.cs" />
|
||||
<Compile Include="Navigation\Models\AdminMenuPartRecord.cs" />
|
||||
@ -545,6 +546,15 @@
|
||||
<ItemGroup>
|
||||
<Content Include="Navigation\Views\EditorTemplates\Parts.Navigation.Edit.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Navigation\Views\Content-Menu.Edit.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Navigation\Views\Menu.DeleteButton.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Navigation\Views\Menu.Edit.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.
|
||||
|
@ -71,6 +71,9 @@ namespace Orchard.ContentManagement {
|
||||
dynamic itemShape = CreateItemShape(actualShapeType);
|
||||
itemShape.ContentItem = content.ContentItem;
|
||||
|
||||
// adding an alternate for [Stereotype]_Edit__[ContentType] e.g. Content-Menu.Edit
|
||||
((IShape)itemShape).Metadata.Alternates.Add(actualShapeType + "__" + content.ContentItem.ContentType);
|
||||
|
||||
var context = new BuildEditorContext(itemShape, content, groupId, _shapeFactory);
|
||||
BindPlacement(context, null, stereotype);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user