diff --git a/src/Orchard/Mvc/ViewEngines/LayoutViewEngine.cs b/src/Orchard/Mvc/ViewEngines/LayoutViewEngine.cs deleted file mode 100644 index de6401aa6..000000000 --- a/src/Orchard/Mvc/ViewEngines/LayoutViewEngine.cs +++ /dev/null @@ -1,128 +0,0 @@ -using System; -using System.Linq; -using System.Web.Mvc; -using Orchard.Themes; - -namespace Orchard.Mvc.ViewEngines { - public class LayoutViewEngine : IViewEngine { - private readonly ViewEngineCollection _viewEngines; - - public LayoutViewEngine(ViewEngineCollection viewEngines) { - _viewEngines = viewEngines; - } - - public ViewEngineResult FindPartialView(ControllerContext controllerContext, string partialViewName, bool useCache) { - return new ViewEngineResult(Enumerable.Empty()); - } - - public ViewEngineResult FindView( - ControllerContext controllerContext, - string viewName, - string masterName, - bool useCache) { - - var skipLayoutViewEngine = false; - if (string.IsNullOrEmpty(masterName) == false) - skipLayoutViewEngine = true; - if (!ThemeFilter.IsApplied(controllerContext.RequestContext)) - skipLayoutViewEngine = true; - if (_viewEngines == null || _viewEngines.Count == 0) - skipLayoutViewEngine = true; - if (skipLayoutViewEngine) - return new ViewEngineResult(Enumerable.Empty()); - - var bodyView = _viewEngines.FindPartialView(controllerContext, viewName); - - ViewEngineResult layoutView = null; - if (!string.IsNullOrEmpty(controllerContext.RouteData.Values["area"] as string)) - layoutView = _viewEngines.FindPartialView(controllerContext, string.Format("Layout.{0}", controllerContext.RouteData.Values["area"])); - if (layoutView == null || layoutView.View == null) - layoutView = _viewEngines.FindPartialView(controllerContext, "Layout"); - - var documentView = _viewEngines.FindPartialView(controllerContext, "Document"); - - if (bodyView.View == null || - layoutView.View == null || - documentView.View == null) { - - var missingTemplatesResult = new ViewEngineResult( - (bodyView.SearchedLocations ?? Enumerable.Empty()) - .Concat((layoutView.SearchedLocations ?? Enumerable.Empty())) - .Concat((documentView.SearchedLocations ?? Enumerable.Empty())) - ); - - return missingTemplatesResult; - } - - var view = new LayoutView(this, new[] { - bodyView, - layoutView, - documentView, - }); - - return new ViewEngineResult(view, this); - } - - public void ReleaseView(ControllerContext controllerContext, IView view) { - var layoutView = (LayoutView)view; - layoutView.ReleaseViews(controllerContext); - } - - public IDisposable CreateScope(ViewContext context) { - return new Scope(context) { LayoutViewEngine = this }; - } - - class Scope : IDisposable { - private readonly ControllerContext _context; - private readonly Scope _prior; - - public Scope(ControllerContext context) { - _context = context; - _prior = From(context); - context.HttpContext.Items[typeof(Scope)] = this; - } - - public LayoutViewEngine LayoutViewEngine { get; set; } - - public void Dispose() { - _context.HttpContext.Items[typeof(Scope)] = _prior; - } - - public static Scope From(ControllerContext context) { - return (Scope)context.HttpContext.Items[typeof(Scope)]; - } - } - - public static IViewEngine CreateShim() { - return new Shim(); - } - - class Shim : IViewEngine { - public ViewEngineResult FindPartialView(ControllerContext controllerContext, string partialViewName, bool useCache) { - var scope = Scope.From(controllerContext); - if (scope != null && scope.LayoutViewEngine != null) { - var result = scope.LayoutViewEngine._viewEngines.FindPartialView(controllerContext, partialViewName); - return result; - } - - return new ViewEngineResult(Enumerable.Empty()); - } - - public ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache) { - var scope = Scope.From(controllerContext); - if (scope != null && scope.LayoutViewEngine != null) { - var result = scope.LayoutViewEngine._viewEngines.FindView(controllerContext, viewName, masterName); - return result; - } - - return new ViewEngineResult(Enumerable.Empty()); - } - - public void ReleaseView(ControllerContext controllerContext, IView view) { - } - } - - } - - -} diff --git a/src/Orchard/Orchard.Framework.csproj b/src/Orchard/Orchard.Framework.csproj index 53a3d2326..718cdd4e5 100644 --- a/src/Orchard/Orchard.Framework.csproj +++ b/src/Orchard/Orchard.Framework.csproj @@ -715,8 +715,6 @@ - -