mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-11-24 16:53:10 +08:00
Incremental work on localized menu items.
This commit is contained in:
@@ -1,10 +1,30 @@
|
||||
using Orchard.Core.Navigation.Models;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.Core.Navigation.Models;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
|
||||
namespace Orchard.Core.Navigation.Handlers {
|
||||
public class MenuItemPartHandler : ContentHandler {
|
||||
public MenuItemPartHandler() {
|
||||
Filters.Add(new ActivatingFilter<MenuItemPart>("MenuItem"));
|
||||
|
||||
OnUpdated<MenuItemPart>(AttachMenu);
|
||||
}
|
||||
|
||||
private void AttachMenu(UpdateContentContext context, MenuItemPart part) {
|
||||
// Check if the menu item is localizable.
|
||||
var localizableAspect = part.As<ILocalizableAspect>();
|
||||
|
||||
if (localizableAspect == null)
|
||||
return;
|
||||
|
||||
// Check if this is the master content item.
|
||||
if (localizableAspect.MasterContentItem == part)
|
||||
return;
|
||||
|
||||
// This is a localized version of the menu item, so ensure it is bound to the same Menu.
|
||||
var menuPart = part.As<MenuPart>();
|
||||
menuPart.Menu = localizableAspect.MasterContentItem.As<MenuPart>().Menu;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ namespace Orchard.Localization.Controllers {
|
||||
if (masterLocalizationPart == null)
|
||||
return HttpNotFound();
|
||||
|
||||
// Check is current item stll exists, and redirect.
|
||||
// Check if current item still exists, and redirect.
|
||||
var existingTranslation = _localizationService.GetLocalizedContentItem(masterContentItem, to);
|
||||
if (existingTranslation != null) {
|
||||
var existingTranslationMetadata = _contentManager.GetItemMetadata(existingTranslation);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
namespace Orchard.ContentManagement.Aspects {
|
||||
public interface ILocalizableAspect : IContent {
|
||||
string Culture { get ; }
|
||||
IContent MasterContentItem { get; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user