mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Merge
--HG-- branch : 1.x
This commit is contained in:
@@ -1,15 +1,9 @@
|
|||||||
using Orchard.ContentManagement.MetaData;
|
using Orchard.ContentManagement.MetaData;
|
||||||
using Orchard.Core.Contents.Extensions;
|
using Orchard.Core.Contents.Extensions;
|
||||||
using Orchard.Core.Navigation.Services;
|
|
||||||
using Orchard.Data.Migration;
|
using Orchard.Data.Migration;
|
||||||
|
|
||||||
namespace Orchard.Core.Navigation {
|
namespace Orchard.Core.Navigation {
|
||||||
public class Migrations : DataMigrationImpl {
|
public class Migrations : DataMigrationImpl {
|
||||||
private readonly IMenuService _menuService;
|
|
||||||
|
|
||||||
public Migrations(IMenuService menuService ) {
|
|
||||||
_menuService = menuService;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Create() {
|
public int Create() {
|
||||||
ContentDefinitionManager.AlterPartDefinition("MenuPart", builder => builder.Attachable());
|
ContentDefinitionManager.AlterPartDefinition("MenuPart", builder => builder.Attachable());
|
||||||
@@ -181,20 +175,6 @@ namespace Orchard.Core.Navigation {
|
|||||||
.WithSetting("Stereotype", "MenuItem")
|
.WithSetting("Stereotype", "MenuItem")
|
||||||
);
|
);
|
||||||
|
|
||||||
// create a Main Menu
|
|
||||||
var mainMenu = _menuService.Create("Main Menu");
|
|
||||||
|
|
||||||
// assign the Main Menu to all current menu items
|
|
||||||
foreach (var menuItem in _menuService.Get()) {
|
|
||||||
// if they don't have a position or a text, then they are not displayed
|
|
||||||
if(string.IsNullOrWhiteSpace(menuItem.MenuPosition) || string.IsNullOrEmpty(menuItem.MenuText)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
menuItem.Menu = mainMenu.ContentItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
// at this point a widget should still be created to display the navigation
|
|
||||||
|
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,11 +0,0 @@
|
|||||||
Name: UpgradeTo15
|
|
||||||
AntiForgery: enabled
|
|
||||||
Author: The Orchard Team
|
|
||||||
Website: http://orchardproject.net
|
|
||||||
Version: 1.5
|
|
||||||
OrchardVersion: 1.5
|
|
||||||
Description: Description for the module
|
|
||||||
Features:
|
|
||||||
UpgradeTo15:
|
|
||||||
Description: Description for feature UpgradeTo15.
|
|
||||||
Dependencies: Orchard.Autoroute, Title
|
|
@@ -2,7 +2,7 @@
|
|||||||
using Orchard.Security;
|
using Orchard.Security;
|
||||||
using Orchard.UI.Navigation;
|
using Orchard.UI.Navigation;
|
||||||
|
|
||||||
namespace UpgradeTo15 {
|
namespace UpgradeTo16 {
|
||||||
public class AdminMenu : INavigationProvider {
|
public class AdminMenu : INavigationProvider {
|
||||||
public Localizer T { get; set; }
|
public Localizer T { get; set; }
|
||||||
|
|
||||||
@@ -12,9 +12,10 @@ namespace UpgradeTo15 {
|
|||||||
|
|
||||||
public void GetNavigation(NavigationBuilder builder) {
|
public void GetNavigation(NavigationBuilder builder) {
|
||||||
builder
|
builder
|
||||||
.Add(T("Migrate to 1.5"), "0", menu => menu.Action("Index", "Route", new { area = "UpgradeTo15" })
|
.Add(T("Upgrade to 1.6"), "0", menu => menu.Action("Index", "Route", new { area = "UpgradeTo16" })
|
||||||
.Add(T("Migrate Routes"), "0", item => item.Action("Index", "Route", new { area = "UpgradeTo15" }).LocalNav().Permission(StandardPermissions.SiteOwner))
|
.Add(T("Migrate Routes"), "0", item => item.Action("Index", "Route", new { area = "UpgradeTo16" }).LocalNav().Permission(StandardPermissions.SiteOwner))
|
||||||
.Add(T("Migrate Fields"), "0", item => item.Action("Index", "Field", new { area = "UpgradeTo15" }).LocalNav().Permission(StandardPermissions.SiteOwner))
|
.Add(T("Migrate Fields"), "0", item => item.Action("Index", "Field", new { area = "UpgradeTo16" }).LocalNav().Permission(StandardPermissions.SiteOwner))
|
||||||
|
.Add(T("Migrate Menu"), "0", item => item.Action("Index", "Menu", new { area = "UpgradeTo16" }).LocalNav().Permission(StandardPermissions.SiteOwner))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -9,9 +9,9 @@ using Orchard.Localization;
|
|||||||
using Orchard.Security;
|
using Orchard.Security;
|
||||||
using Orchard.UI.Admin;
|
using Orchard.UI.Admin;
|
||||||
using Orchard.UI.Notify;
|
using Orchard.UI.Notify;
|
||||||
using UpgradeTo15.ViewModels;
|
using UpgradeTo16.ViewModels;
|
||||||
|
|
||||||
namespace UpgradeTo15.Controllers {
|
namespace UpgradeTo16.Controllers {
|
||||||
[Admin]
|
[Admin]
|
||||||
public class FieldController : Controller {
|
public class FieldController : Controller {
|
||||||
private readonly IContentDefinitionManager _contentDefinitionManager;
|
private readonly IContentDefinitionManager _contentDefinitionManager;
|
@@ -0,0 +1,92 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
using Orchard;
|
||||||
|
using Orchard.ContentManagement;
|
||||||
|
using Orchard.Core.Navigation.Models;
|
||||||
|
using Orchard.Core.Navigation.Services;
|
||||||
|
using Orchard.Localization;
|
||||||
|
using Orchard.Security;
|
||||||
|
using Orchard.UI.Admin;
|
||||||
|
using Orchard.UI.Notify;
|
||||||
|
using Orchard.Widgets.Models;
|
||||||
|
using Orchard.Widgets.Services;
|
||||||
|
|
||||||
|
namespace UpgradeTo16.Controllers {
|
||||||
|
[Admin]
|
||||||
|
public class MenuController : Controller {
|
||||||
|
private readonly IMenuService _menuService;
|
||||||
|
private readonly IOrchardServices _orchardServices;
|
||||||
|
private readonly IWidgetsService _widgetsService;
|
||||||
|
|
||||||
|
public MenuController(
|
||||||
|
IMenuService menuService,
|
||||||
|
IOrchardServices orchardServices,
|
||||||
|
IWidgetsService widgetsService ) {
|
||||||
|
_menuService = menuService;
|
||||||
|
_orchardServices = orchardServices;
|
||||||
|
_widgetsService = widgetsService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Localizer T { get; set; }
|
||||||
|
|
||||||
|
public ActionResult Index() {
|
||||||
|
var menus = _menuService.GetMenus();
|
||||||
|
|
||||||
|
if(menus.Any()) {
|
||||||
|
_orchardServices.Notifier.Warning(T("This step is unnecessary as some menus already exist."));
|
||||||
|
}
|
||||||
|
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost, ActionName("Index")]
|
||||||
|
public ActionResult IndexPOST() {
|
||||||
|
if (!_orchardServices.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not allowed to migrate the navigation.")))
|
||||||
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
|
var menus = _menuService.GetMenus();
|
||||||
|
|
||||||
|
if (menus.Any()) {
|
||||||
|
_orchardServices.Notifier.Error(T("This step is unnecessary as some menus already exist."));
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
// create a Main Menu
|
||||||
|
var mainMenu = _menuService.Create("Main Menu");
|
||||||
|
_orchardServices.Notifier.Information(T("Main menu created"));
|
||||||
|
|
||||||
|
// assign the Main Menu to all current menu items
|
||||||
|
foreach (var menuItem in _menuService.Get()) {
|
||||||
|
// if they don't have a position or a text, then they are not displayed
|
||||||
|
if (string.IsNullOrWhiteSpace(menuItem.MenuPosition) || string.IsNullOrEmpty(menuItem.MenuText)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
menuItem.Menu = mainMenu.ContentItem;
|
||||||
|
}
|
||||||
|
_orchardServices.Notifier.Information(T("Menu items moved to Main menu"));
|
||||||
|
|
||||||
|
// a widget should is created to display the navigation
|
||||||
|
var layer = _widgetsService.GetLayers().FirstOrDefault(x => x.Name == "Default");
|
||||||
|
if(layer == null) {
|
||||||
|
_orchardServices.Notifier.Warning(T("Widget could not be created. Please create it manually."));
|
||||||
|
}
|
||||||
|
|
||||||
|
var widget = _widgetsService.CreateWidget(layer.Id, "MenuWidget", "Main Menu", "1.0", "Navigation");
|
||||||
|
widget.RenderTitle = false;
|
||||||
|
|
||||||
|
var menuWidget = widget.As<MenuWidgetPart>();
|
||||||
|
|
||||||
|
menuWidget.Menu = mainMenu.ContentItem.Record;
|
||||||
|
|
||||||
|
menuWidget.StartLevel = 1;
|
||||||
|
menuWidget.Levels = 1;
|
||||||
|
menuWidget.Breadcrumb = false;
|
||||||
|
menuWidget.AddHomePage = false;
|
||||||
|
menuWidget.AddCurrentPage = false;
|
||||||
|
|
||||||
|
_orchardServices.ContentManager.Publish(menuWidget.ContentItem);
|
||||||
|
|
||||||
|
return View("Index");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -18,9 +18,9 @@ using Orchard.Reports.Services;
|
|||||||
using Orchard.Security;
|
using Orchard.Security;
|
||||||
using Orchard.UI.Admin;
|
using Orchard.UI.Admin;
|
||||||
using Orchard.UI.Notify;
|
using Orchard.UI.Notify;
|
||||||
using UpgradeTo15.ViewModels;
|
using UpgradeTo16.ViewModels;
|
||||||
|
|
||||||
namespace UpgradeTo15.Controllers {
|
namespace UpgradeTo16.Controllers {
|
||||||
[Admin]
|
[Admin]
|
||||||
public class RouteController : Controller {
|
public class RouteController : Controller {
|
||||||
private readonly IContentDefinitionManager _contentDefinitionManager;
|
private readonly IContentDefinitionManager _contentDefinitionManager;
|
||||||
@@ -73,7 +73,7 @@ namespace UpgradeTo15.Controllers {
|
|||||||
if(TryUpdateModel(viewModel)) {
|
if(TryUpdateModel(viewModel)) {
|
||||||
|
|
||||||
// creating report
|
// creating report
|
||||||
_reportsCoordinator.Register("Migration", "UpgradeTo15", "Migrating " + string.Join(" ,", viewModel.ContentTypes.Where(x => x.IsChecked).Select(x => x.ContentTypeName).ToArray()));
|
_reportsCoordinator.Register("Migration", "UpgradeTo16", "Migrating " + string.Join(" ,", viewModel.ContentTypes.Where(x => x.IsChecked).Select(x => x.ContentTypeName).ToArray()));
|
||||||
|
|
||||||
var contentTypesToMigrate = viewModel.ContentTypes.Where(c => c.IsChecked).Select(c => c.ContentTypeName);
|
var contentTypesToMigrate = viewModel.ContentTypes.Where(c => c.IsChecked).Select(c => c.ContentTypeName);
|
||||||
|
|
11
src/Orchard.Web/Modules/UpgradeTo16/Module.txt
Normal file
11
src/Orchard.Web/Modules/UpgradeTo16/Module.txt
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
Name: UpgradeTo16
|
||||||
|
AntiForgery: enabled
|
||||||
|
Author: The Orchard Team
|
||||||
|
Website: http://orchardproject.net
|
||||||
|
Version: 1.6
|
||||||
|
OrchardVersion: 1.5
|
||||||
|
Description: Description for the module
|
||||||
|
Features:
|
||||||
|
UpgradeTo16:
|
||||||
|
Description: Description for feature UpgradeTo16.
|
||||||
|
Dependencies: Orchard.Autoroute, Title, Navigation
|
@@ -6,7 +6,7 @@ using System.Security;
|
|||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
// associated with an assembly.
|
// associated with an assembly.
|
||||||
[assembly: AssemblyTitle("UpgradeTo15")]
|
[assembly: AssemblyTitle("UpgradeTo16")]
|
||||||
[assembly: AssemblyDescription("")]
|
[assembly: AssemblyDescription("")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyProduct("Orchard")]
|
[assembly: AssemblyProduct("Orchard")]
|
@@ -10,8 +10,8 @@
|
|||||||
<ProjectTypeGuids>{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
<ProjectTypeGuids>{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>UpgradeTo15</RootNamespace>
|
<RootNamespace>UpgradeTo16</RootNamespace>
|
||||||
<AssemblyName>UpgradeTo15</AssemblyName>
|
<AssemblyName>UpgradeTo16</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||||
<MvcBuildViews>false</MvcBuildViews>
|
<MvcBuildViews>false</MvcBuildViews>
|
||||||
<FileUpgradeFlags>
|
<FileUpgradeFlags>
|
||||||
@@ -88,9 +88,14 @@
|
|||||||
<Project>{66FCCD76-2761-47E3-8D11-B45D0001DDAA}</Project>
|
<Project>{66FCCD76-2761-47E3-8D11-B45D0001DDAA}</Project>
|
||||||
<Name>Orchard.Autoroute</Name>
|
<Name>Orchard.Autoroute</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\Orchard.Widgets\Orchard.Widgets.csproj">
|
||||||
|
<Project>{194D3CCC-1153-474D-8176-FDE8D7D0D0BD}</Project>
|
||||||
|
<Name>Orchard.Widgets</Name>
|
||||||
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="AdminMenu.cs" />
|
<Compile Include="AdminMenu.cs" />
|
||||||
|
<Compile Include="Controllers\MenuController.cs" />
|
||||||
<Compile Include="Controllers\FieldController.cs" />
|
<Compile Include="Controllers\FieldController.cs" />
|
||||||
<Compile Include="Controllers\RouteController.cs" />
|
<Compile Include="Controllers\RouteController.cs" />
|
||||||
<Compile Include="ViewModels\MigrateViewModel.cs" />
|
<Compile Include="ViewModels\MigrateViewModel.cs" />
|
||||||
@@ -102,6 +107,9 @@
|
|||||||
<Content Include="Views\Field\Index.cshtml" />
|
<Content Include="Views\Field\Index.cshtml" />
|
||||||
<Content Include="Views\Route\Index.cshtml" />
|
<Content Include="Views\Route\Index.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="Views\Menu\Index.cshtml" />
|
||||||
|
</ItemGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
@@ -1,6 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace UpgradeTo15.ViewModels {
|
namespace UpgradeTo16.ViewModels {
|
||||||
public class MigrateViewModel {
|
public class MigrateViewModel {
|
||||||
public IList<ContentTypeEntry> ContentTypes { get; set; }
|
public IList<ContentTypeEntry> ContentTypes { get; set; }
|
||||||
}
|
}
|
@@ -1,5 +1,5 @@
|
|||||||
@using Orchard.Utility.Extensions
|
@using Orchard.Utility.Extensions
|
||||||
@model UpgradeTo15.ViewModels.MigrateViewModel
|
@model UpgradeTo16.ViewModels.MigrateViewModel
|
||||||
|
|
||||||
@{ Layout.Title = T("Migrate Fields").ToString(); }
|
@{ Layout.Title = T("Migrate Fields").ToString(); }
|
||||||
|
|
14
src/Orchard.Web/Modules/UpgradeTo16/Views/Menu/Index.cshtml
Normal file
14
src/Orchard.Web/Modules/UpgradeTo16/Views/Menu/Index.cshtml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
@using Orchard.Utility.Extensions
|
||||||
|
|
||||||
|
@{ Layout.Title = T("Migrate Menu").ToString(); }
|
||||||
|
|
||||||
|
@using (Html.BeginFormAntiForgeryPost()) {
|
||||||
|
Html.ValidationSummary();
|
||||||
|
<fieldset>
|
||||||
|
<legend>@T("Migrating Menu:")</legend>
|
||||||
|
<span class="hint">@T("This migration step will create a new Menu named \"Main Menu\" and add all your previous menu items to it. Finally it will create a new \"Menu Widget\" instance to render this menu on the website.")</span>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<button type="submit">@T("Migrate")</button>
|
||||||
|
</fieldset>
|
||||||
|
}
|
@@ -1,5 +1,5 @@
|
|||||||
@using Orchard.Utility.Extensions
|
@using Orchard.Utility.Extensions
|
||||||
@model UpgradeTo15.ViewModels.MigrateViewModel
|
@model UpgradeTo16.ViewModels.MigrateViewModel
|
||||||
|
|
||||||
@{ Layout.Title = T("Migrate Routes").ToString(); }
|
@{ Layout.Title = T("Migrate Routes").ToString(); }
|
||||||
|
|
@@ -142,7 +142,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.ContentPermissions"
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SysCache", "Orchard.Web\Modules\SysCache\SysCache.csproj", "{3BD22132-D538-48C6-8854-F71333C798EB}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SysCache", "Orchard.Web\Modules\SysCache\SysCache.csproj", "{3BD22132-D538-48C6-8854-F71333C798EB}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpgradeTo15", "Orchard.Web\Modules\UpgradeTo15\UpgradeTo15.csproj", "{8A9FDB57-342D-49C2-BAFC-D885AAE5CC7C}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpgradeTo16", "Orchard.Web\Modules\UpgradeTo16\UpgradeTo16.csproj", "{8A9FDB57-342D-49C2-BAFC-D885AAE5CC7C}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
@@ -26,7 +26,7 @@ namespace Orchard.ContentManagement.Drivers.Coordinators {
|
|||||||
if (contentTypeDefinition == null)
|
if (contentTypeDefinition == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var partInfos = _drivers.SelectMany(cpp => cpp.GetPartInfo());
|
var partInfos = _drivers.SelectMany(cpp => cpp.GetPartInfo()).ToList();
|
||||||
|
|
||||||
foreach (var typePartDefinition in contentTypeDefinition.Parts) {
|
foreach (var typePartDefinition in contentTypeDefinition.Parts) {
|
||||||
var partName = typePartDefinition.PartDefinition.Name;
|
var partName = typePartDefinition.PartDefinition.Name;
|
||||||
|
Reference in New Issue
Block a user