diff --git a/src/Orchard.Tests/Environment/DefaultOrchardShellTests.cs b/src/Orchard.Tests/Environment/DefaultOrchardShellTests.cs index 44b9e6d8d..c51dd089a 100644 --- a/src/Orchard.Tests/Environment/DefaultOrchardShellTests.cs +++ b/src/Orchard.Tests/Environment/DefaultOrchardShellTests.cs @@ -8,6 +8,7 @@ using NUnit.Framework; using Orchard.Environment; using Orchard.Mvc.ModelBinders; using Orchard.Mvc.Routes; +using Orchard.Packages; namespace Orchard.Tests.Environment { [TestFixture] @@ -35,7 +36,9 @@ namespace Orchard.Tests.Environment { new[] { provider1, provider2 }, publisher, new[] { modelBinderProvider1, modelBinderProvider2 }, - modelBinderPublisher); + modelBinderPublisher, + new ViewEngineCollection(), + new Moq.Mock().Object); runtime.Activate(); diff --git a/src/Orchard.Web/Global.asax.cs b/src/Orchard.Web/Global.asax.cs index 846d11ad2..761432803 100644 --- a/src/Orchard.Web/Global.asax.cs +++ b/src/Orchard.Web/Global.asax.cs @@ -42,10 +42,6 @@ namespace Orchard.Web { protected void Application_Start() { RegisterRoutes(RouteTable.Routes); - //TEMP: Modules should be able to register their stuff - var viewEngine = ViewEngines.Engines.OfType().Single(); - viewEngine.AreaViewLocationFormats = OrchardLocationFormats().Concat(viewEngine.AreaViewLocationFormats).ToArray(); - viewEngine.AreaPartialViewLocationFormats = OrchardLocationFormats().Concat(viewEngine.AreaPartialViewLocationFormats).ToArray(); _host = OrchardStarter.CreateHost(MvcSingletons); diff --git a/src/Orchard.Web/Orchard.Web.csproj b/src/Orchard.Web/Orchard.Web.csproj index 798316ec5..575fc1e0d 100644 --- a/src/Orchard.Web/Orchard.Web.csproj +++ b/src/Orchard.Web/Orchard.Web.csproj @@ -168,8 +168,6 @@ - - diff --git a/src/Orchard.Web/Packages/Orchard.Roles/Orchard.Roles.csproj b/src/Orchard.Web/Packages/Orchard.Roles/Orchard.Roles.csproj index fe11874d6..5d86599b0 100644 --- a/src/Orchard.Web/Packages/Orchard.Roles/Orchard.Roles.csproj +++ b/src/Orchard.Web/Packages/Orchard.Roles/Orchard.Roles.csproj @@ -82,7 +82,7 @@ - + diff --git a/src/Orchard.Web/Views/Admin/EditorTemplates/UserRolesViewModel.ascx b/src/Orchard.Web/Packages/Orchard.Roles/Views/Models/EditorTemplates/UserRolesViewModel.ascx similarity index 100% rename from src/Orchard.Web/Views/Admin/EditorTemplates/UserRolesViewModel.ascx rename to src/Orchard.Web/Packages/Orchard.Roles/Views/Models/EditorTemplates/UserRolesViewModel.ascx diff --git a/src/Orchard.Web/Packages/Orchard.Roles/Views/Shared/EditorTemplates/broken_UserRolesViewModel.ascx b/src/Orchard.Web/Packages/Orchard.Roles/Views/Shared/EditorTemplates/broken_UserRolesViewModel.ascx deleted file mode 100644 index 28f52bbbc..000000000 --- a/src/Orchard.Web/Packages/Orchard.Roles/Views/Shared/EditorTemplates/broken_UserRolesViewModel.ascx +++ /dev/null @@ -1,16 +0,0 @@ -<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> -

- Roles

-
    -<% - var index = 0; foreach (var entry in Model.Roles) {%> -
  1. - - <%= Html.Hidden("Roles[" + index + "].RoleId", entry.RoleId)%> - - -
  2. -<%++index; - } %> -
- diff --git a/src/Orchard.Web/Packages/Orchard.Wikis/Orchard.Wikis.csproj b/src/Orchard.Web/Packages/Orchard.Wikis/Orchard.Wikis.csproj index 4f54fe3ec..fac5fba21 100644 --- a/src/Orchard.Web/Packages/Orchard.Wikis/Orchard.Wikis.csproj +++ b/src/Orchard.Web/Packages/Orchard.Wikis/Orchard.Wikis.csproj @@ -70,6 +70,7 @@ + diff --git a/src/Orchard.Web/Views/Admin/EditorTemplates/WikiSettingsRecord.ascx b/src/Orchard.Web/Packages/Orchard.Wikis/Views/Models/EditorTemplates/WikiSettingsRecord.ascx similarity index 100% rename from src/Orchard.Web/Views/Admin/EditorTemplates/WikiSettingsRecord.ascx rename to src/Orchard.Web/Packages/Orchard.Wikis/Views/Models/EditorTemplates/WikiSettingsRecord.ascx diff --git a/src/Orchard/Environment/DefaultOrchardShell.cs b/src/Orchard/Environment/DefaultOrchardShell.cs index 3d477e563..e994aa126 100644 --- a/src/Orchard/Environment/DefaultOrchardShell.cs +++ b/src/Orchard/Environment/DefaultOrchardShell.cs @@ -1,7 +1,11 @@ +using System; using System.Collections.Generic; +using System.IO; using System.Linq; +using System.Web.Mvc; using Orchard.Mvc.ModelBinders; using Orchard.Mvc.Routes; +using Orchard.Packages; namespace Orchard.Environment { public class DefaultOrchardShell : IOrchardShell { @@ -9,21 +13,63 @@ namespace Orchard.Environment { private readonly IRoutePublisher _routePublisher; private readonly IEnumerable _modelBinderProviders; private readonly IModelBinderPublisher _modelBinderPublisher; + private readonly ViewEngineCollection _viewEngines; + private readonly IPackageManager _packageManager; public DefaultOrchardShell( IEnumerable routeProviders, IRoutePublisher routePublisher, IEnumerable modelBinderProviders, - IModelBinderPublisher modelBinderPublisher) { + IModelBinderPublisher modelBinderPublisher, + ViewEngineCollection viewEngines, + IPackageManager packageManager) { _routeProviders = routeProviders; _routePublisher = routePublisher; _modelBinderProviders = modelBinderProviders; _modelBinderPublisher = modelBinderPublisher; + _viewEngines = viewEngines; + _packageManager = packageManager; + } + + + static IEnumerable OrchardLocationFormats() { + return new[] { + "~/Packages/{2}/Views/{1}/{0}.aspx", + "~/Packages/{2}/Views/{1}/{0}.ascx", + "~/Packages/{2}/Views/Shared/{0}.aspx", + "~/Packages/{2}/Views/Shared/{0}.ascx", + "~/Core/{2}/Views/{1}/{0}.aspx", + "~/Core/{2}/Views/{1}/{0}.ascx", + "~/Core/{2}/Views/Shared/{0}.aspx", + "~/Core/{2}/Views/Shared/{0}.ascx", + }; } public void Activate() { _routePublisher.Publish(_routeProviders.SelectMany(provider => provider.GetRoutes())); _modelBinderPublisher.Publish(_modelBinderProviders.SelectMany(provider => provider.GetModelBinders())); + + + var viewEngine = ViewEngines.Engines.OfType().Single(); + viewEngine.AreaViewLocationFormats = OrchardLocationFormats() + .Concat(viewEngine.AreaViewLocationFormats) + .Distinct() + .ToArray(); + viewEngine.AreaPartialViewLocationFormats = OrchardLocationFormats() + .Concat(viewEngine.AreaPartialViewLocationFormats) + .Distinct() + .ToArray(); + + var activePackageDescriptors = _packageManager.ActivePackages().Select(x => x.Descriptor); + var sharedLocationFormats = activePackageDescriptors.Select(x => ModelsLocationFormat(x)); + viewEngine.PartialViewLocationFormats = sharedLocationFormats + .Concat(viewEngine.PartialViewLocationFormats) + .Distinct() + .ToArray(); + } + + private static string ModelsLocationFormat(PackageDescriptor descriptor) { + return Path.Combine(Path.Combine(descriptor.Location, descriptor.Name), "Views/Models/{0}.ascx"); } } } \ No newline at end of file