mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-21 19:34:40 +08:00
#19515: Moving ContentMenuItemPart to Content.Picker
Work Item: 19515 --HG-- branch : 1.x
This commit is contained in:
@@ -1,82 +0,0 @@
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Core.Navigation.Models;
|
||||
using Orchard.Core.Navigation.ViewModels;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Security;
|
||||
|
||||
namespace Orchard.Core.Navigation.Drivers {
|
||||
[UsedImplicitly]
|
||||
public class ContentMenuItemPartDriver : ContentPartDriver<ContentMenuItemPart> {
|
||||
private readonly IContentManager _contentManager;
|
||||
private readonly IAuthorizationService _authorizationService;
|
||||
private readonly IWorkContextAccessor _workContextAccessor;
|
||||
|
||||
public ContentMenuItemPartDriver(
|
||||
IContentManager contentManager,
|
||||
IAuthorizationService authorizationService,
|
||||
IWorkContextAccessor workContextAccessor) {
|
||||
_contentManager = contentManager;
|
||||
_authorizationService = authorizationService;
|
||||
_workContextAccessor = workContextAccessor;
|
||||
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
protected override DriverResult Editor(ContentMenuItemPart part, dynamic shapeHelper) {
|
||||
return ContentShape("Parts_ContentMenuItem_Edit",
|
||||
() => {
|
||||
var model = new ContentMenuItemEditViewModel {
|
||||
ContentItemId = part.Content == null ? -1 : part.Content.Id,
|
||||
Part = part
|
||||
};
|
||||
return shapeHelper.EditorTemplate(TemplateName: "Parts.ContentMenuItem.Edit", Model: model, Prefix: Prefix);
|
||||
});
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(ContentMenuItemPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
var currentUser = _workContextAccessor.GetContext().CurrentUser;
|
||||
if (!_authorizationService.TryCheckAccess(Permissions.ManageMainMenu, currentUser, part))
|
||||
return null;
|
||||
|
||||
var model = new ContentMenuItemEditViewModel();
|
||||
|
||||
if(updater.TryUpdateModel(model, Prefix, null, null)) {
|
||||
var contentItem = _contentManager.Get(model.ContentItemId);
|
||||
if(contentItem == null) {
|
||||
updater.AddModelError("ContentItemId", T("You must select a Content Item"));
|
||||
}
|
||||
else {
|
||||
part.Content = contentItem;
|
||||
}
|
||||
}
|
||||
|
||||
return Editor(part, shapeHelper);
|
||||
}
|
||||
|
||||
protected override void Importing(ContentMenuItemPart part, ImportContentContext context) {
|
||||
var contentItemId = context.Attribute(part.PartDefinition.Name, "ContentItem");
|
||||
if (contentItemId != null) {
|
||||
var contentItem = context.GetItemFromSession(contentItemId);
|
||||
part.Content = contentItem;
|
||||
}
|
||||
else {
|
||||
part.Content = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Exporting(ContentMenuItemPart part, ExportContentContext context) {
|
||||
if (part.Content != null) {
|
||||
var contentItem = _contentManager.Get(part.Content.Id);
|
||||
if (contentItem != null) {
|
||||
var containerIdentity = _contentManager.GetItemMetadata(contentItem).Identity;
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("ContentItem", containerIdentity.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,95 +0,0 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.Core.Navigation.Models;
|
||||
using Orchard.Core.Navigation.Services;
|
||||
using Orchard.Core.Navigation.ViewModels;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Security;
|
||||
using Orchard.UI.Navigation;
|
||||
using Orchard.Utility;
|
||||
|
||||
namespace Orchard.Core.Navigation.Drivers {
|
||||
|
||||
public class NavigationPartDriver : ContentPartDriver<NavigationPart> {
|
||||
private readonly IAuthorizationService _authorizationService;
|
||||
private readonly IWorkContextAccessor _workContextAccessor;
|
||||
private readonly IContentManager _contentManager;
|
||||
private readonly IMenuService _menuService;
|
||||
private readonly INavigationManager _navigationManager;
|
||||
|
||||
public NavigationPartDriver(
|
||||
IAuthorizationService authorizationService,
|
||||
IWorkContextAccessor workContextAccessor,
|
||||
IContentManager contentManager,
|
||||
IMenuService menuService,
|
||||
INavigationManager navigationManager) {
|
||||
_authorizationService = authorizationService;
|
||||
_workContextAccessor = workContextAccessor;
|
||||
_contentManager = contentManager;
|
||||
_menuService = menuService;
|
||||
_navigationManager = navigationManager;
|
||||
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
protected override string Prefix {
|
||||
get {
|
||||
return "NavigationPart";
|
||||
}
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(NavigationPart part, dynamic shapeHelper) {
|
||||
var currentUser = _workContextAccessor.GetContext().CurrentUser;
|
||||
if (!_authorizationService.TryCheckAccess(Permissions.ManageMainMenu, currentUser, part))
|
||||
return null;
|
||||
|
||||
return ContentShape("Parts_Navigation_Edit",
|
||||
() => {
|
||||
// loads all menu part of type ContentMenuItem linking to the current content item
|
||||
var model = new NavigationPartViewModel {
|
||||
Part = part,
|
||||
ContentMenuItems = _contentManager
|
||||
.Query<MenuPart>()
|
||||
.Join<ContentMenuItemPartRecord>()
|
||||
.Where(x => x.ContentMenuItemRecord == part.ContentItem.Record)
|
||||
.List(),
|
||||
Menus = _menuService.GetMenus(),
|
||||
};
|
||||
|
||||
return shapeHelper.EditorTemplate(TemplateName: "Parts.Navigation.Edit", Model: model, Prefix: Prefix);
|
||||
});
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(NavigationPart part, IUpdateModel updater, dynamic shapeHelper) {
|
||||
var currentUser = _workContextAccessor.GetContext().CurrentUser;
|
||||
if (!_authorizationService.TryCheckAccess(Permissions.ManageMainMenu, currentUser, part))
|
||||
return null;
|
||||
|
||||
var model = new NavigationPartViewModel();
|
||||
|
||||
if (updater.TryUpdateModel(model, Prefix, null, null)) {
|
||||
if(model.AddMenuItem) {
|
||||
if (string.IsNullOrEmpty(model.MenuText)) {
|
||||
updater.AddModelError("MenuText", T("The MenuText field is required"));
|
||||
}
|
||||
else {
|
||||
var menu = _contentManager.Get(model.CurrentMenuId);
|
||||
|
||||
if(menu != null) {
|
||||
var menuItem = _contentManager.Create<ContentMenuItemPart>("ContentMenuItem");
|
||||
menuItem.Content = part.ContentItem;
|
||||
|
||||
menuItem.As<MenuPart>().MenuText = model.MenuText;
|
||||
menuItem.As<MenuPart>().MenuPosition = Position.GetNext(_navigationManager.BuildMenu(menu));
|
||||
menuItem.As<MenuPart>().Menu = menu;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Editor(part, shapeHelper);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,40 +0,0 @@
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Core.Navigation.Models;
|
||||
using Orchard.Data;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
|
||||
namespace Orchard.Core.Navigation.Handlers {
|
||||
[UsedImplicitly]
|
||||
public class ContentMenuItemPartHandler : ContentHandler {
|
||||
private readonly IContentManager _contentManager;
|
||||
|
||||
public ContentMenuItemPartHandler(IContentManager contentManager, IRepository<ContentMenuItemPartRecord> repository) {
|
||||
_contentManager = contentManager;
|
||||
Filters.Add(new ActivatingFilter<ContentMenuItemPart>("ContentMenuItem"));
|
||||
Filters.Add(StorageFilter.For(repository));
|
||||
|
||||
OnLoading<ContentMenuItemPart>((context, part) => part._content.Loader(p => contentManager.Get(part.Record.ContentMenuItemRecord.Id)));
|
||||
}
|
||||
|
||||
protected override void GetItemMetadata(GetContentItemMetadataContext context) {
|
||||
base.GetItemMetadata(context);
|
||||
|
||||
if (context.ContentItem.ContentType != "ContentMenuItem") {
|
||||
return;
|
||||
}
|
||||
|
||||
var contentMenuItemPart = context.ContentItem.As<ContentMenuItemPart>();
|
||||
// the display route for the menu item is the one for the referenced content item
|
||||
if(contentMenuItemPart != null) {
|
||||
|
||||
// if the content doesn't exist anymore
|
||||
if(contentMenuItemPart.Content == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
context.Metadata.DisplayRouteValues = _contentManager.GetItemMetadata(contentMenuItemPart.Content).DisplayRouteValues;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,65 +0,0 @@
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Core.Navigation.Models;
|
||||
using Orchard.Data;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
|
||||
namespace Orchard.Core.Navigation.Handlers {
|
||||
[UsedImplicitly]
|
||||
public class NavigationPartHandler : ContentHandler {
|
||||
private readonly IContentManager _contentManager;
|
||||
private readonly IRepository<ContentMenuItemPartRecord> _repository;
|
||||
|
||||
public NavigationPartHandler(IContentManager contentManager, IRepository<ContentMenuItemPartRecord> repository) {
|
||||
_contentManager = contentManager;
|
||||
_repository = repository;
|
||||
|
||||
OnRemoving<NavigationPart>((context, part) => RemoveContentItems(part));
|
||||
|
||||
OnUnpublished<NavigationPart>((context, part) => UnpublishContentItems(part));
|
||||
OnPublished<NavigationPart>((context, part) => PublishContentItems(part));
|
||||
}
|
||||
|
||||
public void RemoveContentItems(NavigationPart part) {
|
||||
// look for ContentMenuItemPart with this content
|
||||
var contentMenuItemRecords = _repository.Fetch(x => x.ContentMenuItemRecord == part.ContentItem.Record);
|
||||
|
||||
// delete all menu items linking to this content item
|
||||
foreach (var contentMenuItemRecord in contentMenuItemRecords) {
|
||||
// look for any version
|
||||
var contentItem = _contentManager.Get(contentMenuItemRecord.Id, VersionOptions.AllVersions);
|
||||
if (contentItem != null) {
|
||||
_contentManager.Remove(contentItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UnpublishContentItems(NavigationPart part) {
|
||||
// look for ContentMenuItemPart with this content
|
||||
var contentMenuItemRecords = _repository.Fetch(x => x.ContentMenuItemRecord == part.ContentItem.Record);
|
||||
|
||||
// delete all menu items linking to this content item
|
||||
foreach (var contentMenuItemRecord in contentMenuItemRecords) {
|
||||
// look for a published version only
|
||||
var contentItem = _contentManager.Get(contentMenuItemRecord.Id);
|
||||
if (contentItem != null) {
|
||||
_contentManager.Unpublish(contentItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void PublishContentItems(NavigationPart part) {
|
||||
// look for ContentMenuItemPart with this content
|
||||
var contentMenuItemRecords = _repository.Fetch(x => x.ContentMenuItemRecord == part.ContentItem.Record);
|
||||
|
||||
// delete all menu items linking to this content item
|
||||
foreach (var contentMenuItemRecord in contentMenuItemRecords) {
|
||||
// even look for an unpublished version
|
||||
var contentItem = _contentManager.Get(contentMenuItemRecord.Id, VersionOptions.Latest);
|
||||
if(contentItem != null) {
|
||||
_contentManager.Publish(contentItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -10,11 +10,6 @@ namespace Orchard.Core.Navigation {
|
||||
.Attachable()
|
||||
.WithDescription("Provides an easy way to create a ContentMenuItem from the content editor."));
|
||||
|
||||
ContentDefinitionManager.AlterPartDefinition("NavigationPart", builder => builder
|
||||
.Attachable()
|
||||
.WithDescription("Allows the management of Content Menu Items associated with a Content Item."));
|
||||
ContentDefinitionManager.AlterTypeDefinition("Page", cfg => cfg.WithPart("NavigationPart"));
|
||||
|
||||
SchemaBuilder.CreateTable("MenuItemPartRecord",
|
||||
table => table
|
||||
.ContentPartRecord()
|
||||
@@ -84,22 +79,6 @@ namespace Orchard.Core.Navigation {
|
||||
.Attachable()
|
||||
.WithDescription("Adds a menu item to the Admin menu that links to this content item."));
|
||||
|
||||
SchemaBuilder.CreateTable("ContentMenuItemPartRecord",
|
||||
table => table
|
||||
.ContentPartRecord()
|
||||
.Column<int>("ContentMenuItemRecord_id")
|
||||
);
|
||||
|
||||
ContentDefinitionManager.AlterTypeDefinition("ContentMenuItem", cfg => cfg
|
||||
.WithPart("MenuPart")
|
||||
.WithPart("CommonPart")
|
||||
.WithPart("IdentityPart")
|
||||
.WithPart("ContentMenuItemPart")
|
||||
.DisplayedAs("Content Menu Item")
|
||||
.WithSetting("Description", "Adds a Content Item to the menu.")
|
||||
.WithSetting("Stereotype", "MenuItem")
|
||||
);
|
||||
|
||||
SchemaBuilder.CreateTable("ShapeMenuItemPartRecord",
|
||||
table => table.ContentPartRecord()
|
||||
.Column<string>("ShapeType")
|
||||
@@ -179,24 +158,6 @@ namespace Orchard.Core.Navigation {
|
||||
.WithSetting("Stereotype", "MenuItem")
|
||||
);
|
||||
|
||||
ContentDefinitionManager.AlterPartDefinition("NavigationPart", builder => builder.Attachable());
|
||||
|
||||
SchemaBuilder.CreateTable("ContentMenuItemPartRecord",
|
||||
table => table
|
||||
.ContentPartRecord()
|
||||
.Column<int>("ContentMenuItemRecord_id")
|
||||
);
|
||||
|
||||
ContentDefinitionManager.AlterTypeDefinition("ContentMenuItem", cfg => cfg
|
||||
.WithPart("MenuPart")
|
||||
.WithPart("CommonPart")
|
||||
.WithPart("IdentityPart")
|
||||
.WithPart("ContentMenuItemPart")
|
||||
.DisplayedAs("Content Menu Item")
|
||||
.WithSetting("Description", "Adds a Content Item to the menu.")
|
||||
.WithSetting("Stereotype", "MenuItem")
|
||||
);
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
@@ -223,9 +184,6 @@ namespace Orchard.Core.Navigation {
|
||||
ContentDefinitionManager.AlterPartDefinition("MenuPart", builder => builder
|
||||
.WithDescription("Provides an easy way to create a ContentMenuItem from the content editor."));
|
||||
|
||||
ContentDefinitionManager.AlterPartDefinition("NavigationPart", builder => builder
|
||||
.WithDescription("Allows the management of Content Menu Items associated with a Content Item."));
|
||||
|
||||
ContentDefinitionManager.AlterPartDefinition("AdminMenuPart", builder => builder
|
||||
.Attachable()
|
||||
.WithDescription("Adds a menu item to the Admin menu that links to this content item."));
|
||||
|
@@ -1,17 +0,0 @@
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Utilities;
|
||||
|
||||
namespace Orchard.Core.Navigation.Models {
|
||||
public class ContentMenuItemPart : ContentPart<ContentMenuItemPartRecord> {
|
||||
|
||||
public readonly LazyField<ContentItem> _content = new LazyField<ContentItem>();
|
||||
|
||||
public ContentItem Content {
|
||||
get { return _content.Value; }
|
||||
set {
|
||||
_content.Value = value;
|
||||
Record.ContentMenuItemRecord = value == null ? null : value.Record;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
using Orchard.ContentManagement.Records;
|
||||
|
||||
namespace Orchard.Core.Navigation.Models {
|
||||
public class ContentMenuItemPartRecord : ContentPartRecord {
|
||||
public virtual ContentItemRecord ContentMenuItemRecord { get; set; }
|
||||
}
|
||||
}
|
@@ -1,9 +0,0 @@
|
||||
using Orchard.ContentManagement;
|
||||
|
||||
namespace Orchard.Core.Navigation.Models {
|
||||
/// <summary>
|
||||
/// Allows the management of Content Menu Items associated with a Content Item
|
||||
/// </summary>
|
||||
public class NavigationPart : ContentPart {
|
||||
}
|
||||
}
|
@@ -7,4 +7,4 @@ OrchardVersion: 1.6
|
||||
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
|
||||
Dependencies: Orchard.ContentPicker, Title
|
||||
Dependencies: Title
|
||||
|
@@ -1,9 +1,7 @@
|
||||
<Placement>
|
||||
<Place Parts_Navigation_Menu_Edit="Content:9"/>
|
||||
<Place Parts_Navigation_AdminMenu_Edit="Content:9.1"/>
|
||||
<Place Parts_Navigation_Edit="Content:10"/>
|
||||
<Place Parts_MenuItem_Edit="Content:10"/>
|
||||
<Place Parts_ContentMenuItem_Edit="Content:10"/>
|
||||
<Place Parts_MenuWidget_Edit="Content:10"/>
|
||||
<Place Parts_MenuWidget="Content"/>
|
||||
<Place Parts_ShapeMenuItemPart_Edit="Content:10"/>
|
||||
|
@@ -1,37 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.Core.Common.Models;
|
||||
using Orchard.Core.Navigation.Models;
|
||||
using Orchard.Security;
|
||||
|
||||
namespace Orchard.Core.Navigation.Security {
|
||||
public class ContentMenuItemAuthorizationEventHandler : IAuthorizationServiceEventHandler{
|
||||
private readonly IAuthorizationService _authorizationService;
|
||||
|
||||
public ContentMenuItemAuthorizationEventHandler(IAuthorizationService authorizationService) {
|
||||
_authorizationService = authorizationService;
|
||||
}
|
||||
|
||||
public void Checking(CheckAccessContext context) { }
|
||||
public void Adjust(CheckAccessContext context) { }
|
||||
|
||||
public void Complete(CheckAccessContext context) {
|
||||
if (context.Content == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
var part = context.Content.As<ContentMenuItemPart>();
|
||||
|
||||
// if the content item has no right attached, check on the container
|
||||
if (part == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
context.Granted = _authorizationService.TryCheckAccess(context.Permission, context.User, part.Content);
|
||||
context.Adjusted = true;
|
||||
}
|
||||
}
|
||||
}
|
@@ -30,16 +30,6 @@ namespace Orchard.Core.Navigation.Services {
|
||||
if (localized != null) {
|
||||
culture = localized.Culture;
|
||||
}
|
||||
else {
|
||||
// fetch the culture of the content menu item, if any
|
||||
var contentMenuItemPart = part.As<ContentMenuItemPart>();
|
||||
if (contentMenuItemPart != null) {
|
||||
localized = contentMenuItemPart.Content.As<ILocalizableAspect>();
|
||||
if (localized != null) {
|
||||
culture = localized.Culture;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (part.Is<MenuItemPart>())
|
||||
builder.Add(new LocalizedString(HttpUtility.HtmlEncode(part.MenuText)), part.MenuPosition, item => item.Url(part.As<MenuItemPart>().Url).Content(part).Culture(culture).Permission(Contents.Permissions.ViewContent));
|
||||
|
@@ -1,8 +0,0 @@
|
||||
using Orchard.Core.Navigation.Models;
|
||||
|
||||
namespace Orchard.Core.Navigation.ViewModels {
|
||||
public class ContentMenuItemEditViewModel {
|
||||
public int ContentItemId { get; set; }
|
||||
public ContentMenuItemPart Part { get; set; }
|
||||
}
|
||||
}
|
@@ -1,14 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Core.Navigation.Models;
|
||||
|
||||
namespace Orchard.Core.Navigation.ViewModels {
|
||||
public class NavigationPartViewModel {
|
||||
public IEnumerable<MenuPart> ContentMenuItems { get; set; }
|
||||
public NavigationPart Part { get; set; }
|
||||
public IEnumerable<ContentItem> Menus { get; set; }
|
||||
public string MenuText { get; set; }
|
||||
public bool AddMenuItem { get; set; }
|
||||
public int CurrentMenuId { get; set; }
|
||||
}
|
||||
}
|
@@ -1,37 +0,0 @@
|
||||
@model Orchard.Core.Navigation.ViewModels.ContentMenuItemEditViewModel
|
||||
@{
|
||||
Script.Require("ContentPicker").AtFoot();
|
||||
var title = Model.Part.Content == null ? new HtmlString(T("Empty").Text) : Html.ItemDisplayText(Model.Part.Content);
|
||||
}
|
||||
<fieldset>
|
||||
<label>@T("Content Item")</label>
|
||||
<span id="title-@Html.FieldIdFor(m => m.ContentItemId)" class="content-picker-title">@title</span>
|
||||
<span id="btn-@Html.FieldIdFor(m => m.ContentItemId)" class="button">@T("Browse")</span>
|
||||
|
||||
@Html.HiddenFor(m => m.ContentItemId)
|
||||
<span class="hint">@T("Select the Content Item to display in the menu.")</span>
|
||||
</fieldset>
|
||||
|
||||
@using(Script.Foot()) {
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
jQuery('#btn-@Html.FieldIdFor(m => m.ContentItemId)').click(function() {
|
||||
jQuery('#btn-@Html.FieldIdFor(m => m.ContentItemId)').trigger("orchard-admin-contentpicker-open", {
|
||||
callback: function(data) {
|
||||
|
||||
jQuery('#@Html.FieldIdFor(m => m.ContentItemId)').val(data.id);
|
||||
|
||||
jQuery('#title-@Html.FieldIdFor(m => m.ContentItemId)').text(data.displayText);
|
||||
|
||||
// define the menu text if it's empty
|
||||
var menuText = jQuery('#MenuPart_MenuText');
|
||||
if (menuText.val().length == 0) {
|
||||
menuText.val(data.displayText);
|
||||
}
|
||||
},
|
||||
baseUrl: '@Url.Content("~/")'
|
||||
});
|
||||
});
|
||||
//]]>
|
||||
</script>
|
||||
}
|
@@ -1,43 +0,0 @@
|
||||
@model Orchard.Core.Navigation.ViewModels.NavigationPartViewModel
|
||||
@using Orchard.ContentManagement
|
||||
|
||||
@{
|
||||
var contentManager = WorkContext.Resolve<IContentManager>();
|
||||
}
|
||||
<fieldset>
|
||||
<label>@T("Menu Items")</label>
|
||||
<span class="hint">@T("The menu items linking to this content item.")</span>
|
||||
@if(Model.ContentMenuItems.Any()) {
|
||||
<ul>
|
||||
@foreach(var menuPart in Model.ContentMenuItems) {
|
||||
var menuContentItem = contentManager.Get(menuPart.Menu.Id);
|
||||
var menuName = Html.ItemDisplayText(menuContentItem).ToString();
|
||||
<li>
|
||||
<div><span>@menuPart.MenuText</span> @T("on") <span>@Html.ActionLink(menuName, "Index", "Admin", new { area = "Navigation", menuId = menuContentItem.Id }, new {}) </span></div>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
else {
|
||||
@T("Not displayed in any menu.")
|
||||
}
|
||||
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
@Html.EditorFor(m => m.AddMenuItem)
|
||||
<label for="@Html.FieldIdFor(m => m.AddMenuItem)" class="forcheckbox">@T("Add on a menu")</label>
|
||||
<div data-controllerid="@Html.FieldIdFor(m => m.AddMenuItem)">
|
||||
<select id="@Html.FieldIdFor(m => m.CurrentMenuId)" name="@Html.FieldNameFor(m => m.CurrentMenuId)">
|
||||
@foreach (ContentItem menu in Model.Menus) {
|
||||
@Html.SelectOption(Model.CurrentMenuId, menu.Id, Html.ItemDisplayText(menu).ToString())
|
||||
}
|
||||
</select>
|
||||
<span class="hint">@T("Select which menu you want the content item to be added on.")</span>
|
||||
|
||||
<label for="MenuText">@T("Menu text")</label>
|
||||
@Html.TextBoxFor(m => m.MenuText, new { @class = "text-box single-line" })
|
||||
<span class="hint">@T("The text that should appear in the menu.")</span>
|
||||
</div>
|
||||
|
||||
|
||||
</fieldset>
|
@@ -1,8 +0,0 @@
|
||||
@using Orchard.ContentManagement
|
||||
@{
|
||||
ContentItem contentItem = Model.Content.ContentItem.ContentMenuItemPart.Content;
|
||||
}
|
||||
|
||||
@if (contentItem != null) {
|
||||
<a href="@Model.Href">@Model.Text</a>
|
||||
}
|
@@ -132,26 +132,19 @@
|
||||
<Compile Include="Dashboard\Services\CompilationErrorBanner.cs" />
|
||||
<Compile Include="Navigation\Commands\MenuCommands.cs" />
|
||||
<Compile Include="Navigation\Drivers\AdminMenuPartDriver.cs" />
|
||||
<Compile Include="Navigation\Drivers\NavigationPartDriver.cs" />
|
||||
<Compile Include="Navigation\Drivers\MenuItemPartDriver.cs" />
|
||||
<Compile Include="Navigation\Drivers\MenuWidgetPartDriver.cs" />
|
||||
<Compile Include="Navigation\Drivers\ShapeMenuItemPartDriver.cs" />
|
||||
<Compile Include="Navigation\Handlers\AdminMenuPartHandler.cs" />
|
||||
<Compile Include="Navigation\Handlers\ContentMenuItemPartHandler.cs" />
|
||||
<Compile Include="Navigation\Handlers\NavigationPartHandler.cs" />
|
||||
<Compile Include="Navigation\Handlers\MenuHandler.cs" />
|
||||
<Compile Include="Navigation\Handlers\MenuWidgetPartHandler.cs" />
|
||||
<Compile Include="Navigation\Handlers\ShapeMenuItemPartHandler.cs" />
|
||||
<Compile Include="Navigation\Models\AdminMenuPart.cs" />
|
||||
<Compile Include="Navigation\Models\AdminMenuPartRecord.cs" />
|
||||
<Compile Include="Navigation\Models\ContentMenuItemPartRecord.cs" />
|
||||
<Compile Include="Navigation\Models\ContentMenuItemPart.cs" />
|
||||
<Compile Include="Navigation\Models\NavigationPart.cs" />
|
||||
<Compile Include="Navigation\Models\MenuWidgetPartRecord.cs" />
|
||||
<Compile Include="Navigation\Models\MenuWidgetPart.cs" />
|
||||
<Compile Include="Navigation\Models\ShapeMenuItemPart.cs" />
|
||||
<Compile Include="Navigation\Models\ShapeMenuItemPartRecord.cs" />
|
||||
<Compile Include="Navigation\Security\ContentMenuItemAuthorizationEventHandler.cs" />
|
||||
<Compile Include="Navigation\Services\AdminMenuNavigationProvider.cs" />
|
||||
<Compile Include="Navigation\Services\DefaultMenuManager.cs" />
|
||||
<Compile Include="Navigation\Services\IMenuManager.cs" />
|
||||
@@ -160,8 +153,6 @@
|
||||
<Compile Include="Navigation\Settings\AdminMenuPartTypeSettings.cs" />
|
||||
<Compile Include="Contents\ViewModels\ListContentsViewModel.cs" />
|
||||
<Compile Include="Contents\ViewModels\ListContentTypesViewModel.cs" />
|
||||
<Compile Include="Navigation\ViewModels\ContentMenuItemEditViewModel.cs" />
|
||||
<Compile Include="Navigation\ViewModels\NavigationPartViewModel.cs" />
|
||||
<Compile Include="Navigation\ViewModels\MenuPartViewModel.cs" />
|
||||
<Compile Include="Navigation\ViewModels\MenuWidgetViewModel.cs" />
|
||||
<Compile Include="Reports\AdminMenu.cs" />
|
||||
@@ -205,7 +196,6 @@
|
||||
<Compile Include="Navigation\AdminMenu.cs" />
|
||||
<Compile Include="Navigation\Controllers\AdminController.cs" />
|
||||
<Compile Include="Navigation\Models\MenuItemPart.cs" />
|
||||
<Compile Include="Navigation\Drivers\ContentMenuItemPartDriver.cs" />
|
||||
<Compile Include="Navigation\Handlers\MenuItemPartHandler.cs" />
|
||||
<Compile Include="Navigation\Models\MenuPart.cs" />
|
||||
<Compile Include="Navigation\Drivers\MenuPartDriver.cs" />
|
||||
@@ -542,15 +532,6 @@
|
||||
<ItemGroup>
|
||||
<Content Include="Navigation\Views\MenuItemLink-HtmlMenuItem.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Navigation\Views\EditorTemplates\Parts.ContentMenuItem.Edit.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Navigation\Views\MenuItemLink-ContentMenuItem.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Navigation\Views\EditorTemplates\Parts.Navigation.Edit.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Navigation\Views\Content-Menu.Edit.cshtml" />
|
||||
</ItemGroup>
|
||||
|
Reference in New Issue
Block a user