ThemeFilter is wholly responsible for determining if a request is themed. Previously, LayoutAwareViewEngine had some theme business logic which made it impossible to have an un-themed admin controller.

--HG--
branch : dev
This commit is contained in:
Dave Reed
2011-02-18 15:03:38 -08:00
parent 4768b99d51
commit 3ad849c22d
2 changed files with 14 additions and 4 deletions

View File

@@ -36,8 +36,7 @@ namespace Orchard.Mvc.ViewEngines.ThemeAwareness {
return viewResult;
}
// Don't layout the result if it's not an Admin controller and it's disabled
if ( !AdminFilter.IsApplied(controllerContext.RequestContext) && !ThemeFilter.IsApplied(controllerContext.RequestContext) ) {
if (!ThemeFilter.IsApplied(controllerContext.RequestContext)) {
return viewResult;
}

View File

@@ -2,13 +2,24 @@ using System.Linq;
using System.Web.Mvc;
using System.Web.Routing;
using Orchard.Mvc.Filters;
using Orchard.UI.Admin;
namespace Orchard.Themes {
public class ThemeFilter : FilterProvider, IActionFilter, IResultFilter {
public void OnActionExecuting(ActionExecutingContext filterContext) {
var attribute = GetThemedAttribute(filterContext.ActionDescriptor);
if (attribute != null && attribute.Enabled) {
Apply(filterContext.RequestContext);
if (AdminFilter.IsApplied(filterContext.RequestContext)) {
// admin are themed by default
if (attribute == null || attribute.Enabled) {
Apply(filterContext.RequestContext);
}
}
else {
// non-admin are explicitly themed
// Don't layout the result if it's not an Admin controller and it's disabled
if (attribute != null && attribute.Enabled) {
Apply(filterContext.RequestContext);
}
}
}