mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-21 11:17:28 +08:00
MenuItem -> MenuItemPart
--HG-- branch : dev rename : src/Orchard.Web/Core/Navigation/Drivers/MenuItemDriver.cs => src/Orchard.Web/Core/Navigation/Drivers/MenuItemPartDriver.cs rename : src/Orchard.Web/Core/Navigation/Handlers/MenuItemHandler.cs => src/Orchard.Web/Core/Navigation/Handlers/MenuItemPartHandler.cs rename : src/Orchard.Web/Core/Navigation/Models/MenuItem.cs => src/Orchard.Web/Core/Navigation/Models/MenuItemPart.cs rename : src/Orchard.Web/Core/Navigation/Models/MenuItemRecord.cs => src/Orchard.Web/Core/Navigation/Models/MenuItemPartRecord.cs
This commit is contained in:
@@ -10,7 +10,6 @@ using Orchard.Localization;
|
|||||||
using Orchard.Mvc.AntiForgery;
|
using Orchard.Mvc.AntiForgery;
|
||||||
using Orchard.UI.Navigation;
|
using Orchard.UI.Navigation;
|
||||||
using Orchard.Utility;
|
using Orchard.Utility;
|
||||||
using MenuItem=Orchard.Core.Navigation.Models.MenuItem;
|
|
||||||
|
|
||||||
namespace Orchard.Core.Navigation.Controllers {
|
namespace Orchard.Core.Navigation.Controllers {
|
||||||
[ValidateInput(false)]
|
[ValidateInput(false)]
|
||||||
@@ -51,8 +50,8 @@ namespace Orchard.Core.Navigation.Controllers {
|
|||||||
|
|
||||||
menuPart.MenuText = menuItemEntry.MenuItem.Text;
|
menuPart.MenuText = menuItemEntry.MenuItem.Text;
|
||||||
menuPart.MenuPosition = menuItemEntry.MenuItem.Position;
|
menuPart.MenuPosition = menuItemEntry.MenuItem.Position;
|
||||||
if (menuPart.Is<MenuItem>())
|
if (menuPart.Is<MenuItemPart>())
|
||||||
menuPart.As<MenuItem>().Url = menuItemEntry.MenuItem.Url;
|
menuPart.As<MenuItemPart>().Url = menuItemEntry.MenuItem.Url;
|
||||||
|
|
||||||
_services.ContentManager.UpdateEditorModel(menuPart, this);
|
_services.ContentManager.UpdateEditorModel(menuPart, this);
|
||||||
}
|
}
|
||||||
@@ -65,12 +64,12 @@ namespace Orchard.Core.Navigation.Controllers {
|
|||||||
MenuItem = new UI.Navigation.MenuItem {
|
MenuItem = new UI.Navigation.MenuItem {
|
||||||
Text = menuPart.MenuText,
|
Text = menuPart.MenuText,
|
||||||
Position = menuPart.MenuPosition,
|
Position = menuPart.MenuPosition,
|
||||||
Url = menuPart.Is<MenuItem>()
|
Url = menuPart.Is<MenuItemPart>()
|
||||||
? menuPart.As<MenuItem>().Url
|
? menuPart.As<MenuItemPart>().Url
|
||||||
: _navigationManager.GetUrl(null, _services.ContentManager.GetItemMetadata(menuPart).DisplayRouteValues)
|
: _navigationManager.GetUrl(null, _services.ContentManager.GetItemMetadata(menuPart).DisplayRouteValues)
|
||||||
},
|
},
|
||||||
MenuItemId = menuPart.Id,
|
MenuItemId = menuPart.Id,
|
||||||
IsMenuItem = menuPart.Is<MenuItem>()
|
IsMenuItem = menuPart.Is<MenuItemPart>()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +82,7 @@ namespace Orchard.Core.Navigation.Controllers {
|
|||||||
if (!_services.Authorizer.Authorize(Permissions.ManageMainMenu, T("Couldn't manage the main menu")))
|
if (!_services.Authorizer.Authorize(Permissions.ManageMainMenu, T("Couldn't manage the main menu")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
var menuPart = _services.ContentManager.New<MenuPart>(MenuItemDriver.ContentType.Name);
|
var menuPart = _services.ContentManager.New<MenuPart>(MenuItemPartDriver.ContentType.Name);
|
||||||
model.MenuItem = _services.ContentManager.UpdateEditorModel(menuPart, this);
|
model.MenuItem = _services.ContentManager.UpdateEditorModel(menuPart, this);
|
||||||
|
|
||||||
if (!ModelState.IsValid) {
|
if (!ModelState.IsValid) {
|
||||||
@@ -108,7 +107,7 @@ namespace Orchard.Core.Navigation.Controllers {
|
|||||||
MenuPart menuPart = _menuService.Get(id);
|
MenuPart menuPart = _menuService.Get(id);
|
||||||
|
|
||||||
if (menuPart != null) {
|
if (menuPart != null) {
|
||||||
if (menuPart.Is<MenuItem>())
|
if (menuPart.Is<MenuItemPart>())
|
||||||
_menuService.Delete(menuPart);
|
_menuService.Delete(menuPart);
|
||||||
else
|
else
|
||||||
menuPart.OnMainMenu = false;
|
menuPart.OnMainMenu = false;
|
||||||
|
@@ -10,7 +10,7 @@ namespace Orchard.Core.Navigation.DataMigrations {
|
|||||||
|
|
||||||
public int Create() {
|
public int Create() {
|
||||||
//CREATE TABLE Navigation_MenuItemRecord (Id INTEGER not null, Url TEXT, primary key (Id));
|
//CREATE TABLE Navigation_MenuItemRecord (Id INTEGER not null, Url TEXT, primary key (Id));
|
||||||
SchemaBuilder.CreateTable("MenuItemRecord", table => table
|
SchemaBuilder.CreateTable("MenuItemPartRecord", table => table
|
||||||
.ContentPartRecord()
|
.ContentPartRecord()
|
||||||
.Column<string>("Url")
|
.Column<string>("Url")
|
||||||
);
|
);
|
||||||
|
@@ -6,7 +6,7 @@ using Orchard.Security;
|
|||||||
|
|
||||||
namespace Orchard.Core.Navigation.Drivers {
|
namespace Orchard.Core.Navigation.Drivers {
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public class MenuItemDriver : ContentItemDriver<MenuItem> {
|
public class MenuItemPartDriver : ContentItemDriver<MenuItemPart> {
|
||||||
private readonly IAuthorizationService _authorizationService;
|
private readonly IAuthorizationService _authorizationService;
|
||||||
|
|
||||||
public readonly static ContentType ContentType = new ContentType {
|
public readonly static ContentType ContentType = new ContentType {
|
||||||
@@ -14,7 +14,7 @@ namespace Orchard.Core.Navigation.Drivers {
|
|||||||
DisplayName = "Menu Item"
|
DisplayName = "Menu Item"
|
||||||
};
|
};
|
||||||
|
|
||||||
public MenuItemDriver(IAuthorizationService authorizationService) {
|
public MenuItemPartDriver(IAuthorizationService authorizationService) {
|
||||||
_authorizationService = authorizationService;
|
_authorizationService = authorizationService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,15 +26,15 @@ namespace Orchard.Core.Navigation.Drivers {
|
|||||||
|
|
||||||
protected override string Prefix { get { return ""; } }
|
protected override string Prefix { get { return ""; } }
|
||||||
|
|
||||||
protected override string GetDisplayText(MenuItem item) {
|
protected override string GetDisplayText(MenuItemPart itemPart) {
|
||||||
return item.Url;
|
return itemPart.Url;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override DriverResult Editor(MenuItem item, IUpdateModel updater) {
|
protected override DriverResult Editor(MenuItemPart itemPart, IUpdateModel updater) {
|
||||||
if (!_authorizationService.TryCheckAccess(Permissions.ManageMainMenu, CurrentUser, item))
|
if (!_authorizationService.TryCheckAccess(Permissions.ManageMainMenu, CurrentUser, itemPart))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
updater.TryUpdateModel(item, Prefix, null, null);
|
updater.TryUpdateModel(itemPart, Prefix, null, null);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
@@ -6,9 +6,9 @@ using Orchard.ContentManagement.Handlers;
|
|||||||
|
|
||||||
namespace Orchard.Core.Navigation.Handlers {
|
namespace Orchard.Core.Navigation.Handlers {
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public class MenuItemHandler : ContentHandler {
|
public class MenuItemPartHandler : ContentHandler {
|
||||||
public MenuItemHandler(IRepository<MenuItemRecord> repository) {
|
public MenuItemPartHandler(IRepository<MenuItemPartRecord> repository) {
|
||||||
Filters.Add(new ActivatingFilter<MenuItem>(MenuItemDriver.ContentType.Name));
|
Filters.Add(new ActivatingFilter<MenuItemPart>(MenuItemPartDriver.ContentType.Name));
|
||||||
Filters.Add(StorageFilter.For(repository));
|
Filters.Add(StorageFilter.For(repository));
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -3,7 +3,7 @@ using System.Web.Mvc;
|
|||||||
using Orchard.ContentManagement;
|
using Orchard.ContentManagement;
|
||||||
|
|
||||||
namespace Orchard.Core.Navigation.Models {
|
namespace Orchard.Core.Navigation.Models {
|
||||||
public class MenuItem : ContentPart<MenuItemRecord> {
|
public class MenuItemPart : ContentPart<MenuItemPartRecord> {
|
||||||
[HiddenInput(DisplayValue = false)]
|
[HiddenInput(DisplayValue = false)]
|
||||||
public int Id { get { return ContentItem.Id; } }
|
public int Id { get { return ContentItem.Id; } }
|
||||||
|
|
@@ -1,7 +1,7 @@
|
|||||||
using Orchard.ContentManagement.Records;
|
using Orchard.ContentManagement.Records;
|
||||||
|
|
||||||
namespace Orchard.Core.Navigation.Models {
|
namespace Orchard.Core.Navigation.Models {
|
||||||
public class MenuItemRecord : ContentPartRecord {
|
public class MenuItemPartRecord : ContentPartRecord {
|
||||||
public virtual string Url { get; set; }
|
public virtual string Url { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -4,7 +4,6 @@ using Orchard.ContentManagement;
|
|||||||
using Orchard.Core.Navigation.Models;
|
using Orchard.Core.Navigation.Models;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
using Orchard.UI.Navigation;
|
using Orchard.UI.Navigation;
|
||||||
using MenuItem=Orchard.Core.Navigation.Models.MenuItem;
|
|
||||||
|
|
||||||
namespace Orchard.Core.Navigation.Services {
|
namespace Orchard.Core.Navigation.Services {
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
@@ -35,9 +34,9 @@ namespace Orchard.Core.Navigation.Services {
|
|||||||
if (menuPart != null ) {
|
if (menuPart != null ) {
|
||||||
var part = menuPart;
|
var part = menuPart;
|
||||||
|
|
||||||
if (part.Is<MenuItem>())
|
if (part.Is<MenuItemPart>())
|
||||||
builder.Add(
|
builder.Add(
|
||||||
menu => menu.Add(new LocalizedString(part.MenuText), part.MenuPosition, nib => nib.Url(part.As<MenuItem>().Url)));
|
menu => menu.Add(new LocalizedString(part.MenuText), part.MenuPosition, nib => nib.Url(part.As<MenuItemPart>().Url)));
|
||||||
else
|
else
|
||||||
builder.Add(
|
builder.Add(
|
||||||
menu =>
|
menu =>
|
||||||
|
@@ -58,7 +58,7 @@ using (Html.BeginFormAntiForgeryPost(Url.Action("create"), FormMethod.Post)) { %
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<label for="Url"><%: T("Url")%></label>
|
<label for="Url"><%: T("Url")%></label>
|
||||||
<%: Html.EditorFor(nmvm => nmvm.NewMenuItem.MenuItem.Item.As<Orchard.Core.Navigation.Models.MenuItem>().Url)%>
|
<%: Html.EditorFor(nmvm => nmvm.NewMenuItem.MenuItem.Item.As<Orchard.Core.Navigation.Models.MenuItemPart>().Url)%>
|
||||||
</td>
|
</td>
|
||||||
<td><button class="add" type="submit"><%: T("Add") %></button></td>
|
<td><button class="add" type="submit"><%: T("Add") %></button></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@@ -161,14 +161,14 @@
|
|||||||
<Compile Include="Localization\Models\LocalizationPartRecord.cs" />
|
<Compile Include="Localization\Models\LocalizationPartRecord.cs" />
|
||||||
<Compile Include="Navigation\AdminMenu.cs" />
|
<Compile Include="Navigation\AdminMenu.cs" />
|
||||||
<Compile Include="Navigation\Controllers\AdminController.cs" />
|
<Compile Include="Navigation\Controllers\AdminController.cs" />
|
||||||
<Compile Include="Navigation\Models\MenuItem.cs" />
|
<Compile Include="Navigation\Models\MenuItemPart.cs" />
|
||||||
<Compile Include="Navigation\Drivers\MenuItemDriver.cs" />
|
<Compile Include="Navigation\Drivers\MenuItemPartDriver.cs" />
|
||||||
<Compile Include="Navigation\Handlers\MenuItemHandler.cs" />
|
<Compile Include="Navigation\Handlers\MenuItemPartHandler.cs" />
|
||||||
<Compile Include="Navigation\Models\MenuPart.cs" />
|
<Compile Include="Navigation\Models\MenuPart.cs" />
|
||||||
<Compile Include="Navigation\Drivers\MenuPartDriver.cs" />
|
<Compile Include="Navigation\Drivers\MenuPartDriver.cs" />
|
||||||
<Compile Include="Navigation\Handlers\MenuPartHandler.cs" />
|
<Compile Include="Navigation\Handlers\MenuPartHandler.cs" />
|
||||||
<Compile Include="Navigation\Permissions.cs" />
|
<Compile Include="Navigation\Permissions.cs" />
|
||||||
<Compile Include="Navigation\Models\MenuItemRecord.cs" />
|
<Compile Include="Navigation\Models\MenuItemPartRecord.cs" />
|
||||||
<Compile Include="Navigation\Models\MenuPartRecord.cs" />
|
<Compile Include="Navigation\Models\MenuPartRecord.cs" />
|
||||||
<Compile Include="Navigation\Services\IMenuService.cs" />
|
<Compile Include="Navigation\Services\IMenuService.cs" />
|
||||||
<Compile Include="Navigation\Services\MainMenuService.cs" />
|
<Compile Include="Navigation\Services\MainMenuService.cs" />
|
||||||
|
@@ -230,7 +230,7 @@ namespace Orchard.Setup.Services {
|
|||||||
menuItem.As<MenuPart>().MenuPosition = "1";
|
menuItem.As<MenuPart>().MenuPosition = "1";
|
||||||
menuItem.As<MenuPart>().MenuText = T("Home").ToString();
|
menuItem.As<MenuPart>().MenuText = T("Home").ToString();
|
||||||
menuItem.As<MenuPart>().OnMainMenu = true;
|
menuItem.As<MenuPart>().OnMainMenu = true;
|
||||||
menuItem.As<MenuItem>().Url = "";
|
menuItem.As<MenuItemPart>().Url = "";
|
||||||
|
|
||||||
//Temporary fix for running setup on command line
|
//Temporary fix for running setup on command line
|
||||||
if (HttpContext.Current != null) {
|
if (HttpContext.Current != null) {
|
||||||
|
Reference in New Issue
Block a user