diff --git a/src/Orchard.Web/Modules/Orchard.DevTools/Controllers/HomeController.cs b/src/Orchard.Web/Modules/Orchard.DevTools/Controllers/HomeController.cs
index f40699486..c4a8e26f0 100644
--- a/src/Orchard.Web/Modules/Orchard.DevTools/Controllers/HomeController.cs
+++ b/src/Orchard.Web/Modules/Orchard.DevTools/Controllers/HomeController.cs
@@ -1,17 +1,23 @@
+using System;
using System.Web.Mvc;
using Orchard.DevTools.Models;
+using Orchard.Localization;
using Orchard.Mvc.ViewModels;
+using Orchard.Themes;
using Orchard.UI.Notify;
namespace Orchard.DevTools.Controllers {
- //[Themed]
+ [Themed]
public class HomeController : Controller {
private readonly INotifier _notifier;
public HomeController(INotifier notifier) {
_notifier = notifier;
+ T = NullLocalizer.Instance;
}
+ public Localizer T { get; set; }
+
public ActionResult Index() {
return View(new BaseViewModel());
}
@@ -28,5 +34,15 @@ namespace Orchard.DevTools.Controllers {
public ActionResult _RenderableAction() {
return PartialView("_RenderableAction", "This is render action");
}
+
+ public ActionResult SimpleMessage() {
+ _notifier.Information(T("Notifier works without BaseViewModel"));
+ return RedirectToAction("Simple");
+ }
+
+ [Themed(false)]
+ public ActionResult SimpleNoTheme() {
+ return View("Simple", new Simple { Title = "This is not themed", Quantity = 5 });
+ }
}
}
diff --git a/src/Orchard.Web/Modules/Orchard.DevTools/Views/Home/Simple.aspx b/src/Orchard.Web/Modules/Orchard.DevTools/Views/Home/Simple.aspx
index e6d8d8872..49316bb8d 100644
--- a/src/Orchard.Web/Modules/Orchard.DevTools/Views/Home/Simple.aspx
+++ b/src/Orchard.Web/Modules/Orchard.DevTools/Views/Home/Simple.aspx
@@ -8,3 +8,5 @@
<%= Model.Quantity %>
<% Html.RenderAction("_RenderableAction"); %>
+
+ <%=Html.ActionLink("Test Messages", "SimpleMessage")%>
diff --git a/src/Orchard/Environment/ShellBuilders/SafeModeShellContainerFactory.cs b/src/Orchard/Environment/ShellBuilders/SafeModeShellContainerFactory.cs
index 93966bd0a..55f3e6c46 100644
--- a/src/Orchard/Environment/ShellBuilders/SafeModeShellContainerFactory.cs
+++ b/src/Orchard/Environment/ShellBuilders/SafeModeShellContainerFactory.cs
@@ -47,6 +47,7 @@ namespace Orchard.Environment.ShellBuilders {
builder.Register().As().ContainerScoped();
builder.Register().As().ContainerScoped();
builder.Register().As().ContainerScoped();
+ builder.Register().As().ContainerScoped();
builder.Register().As().ContainerScoped();
builder.Register().As().ContainerScoped();
builder.Register().As().ContainerScoped();
diff --git a/src/Orchard/Mvc/ViewEngines/LayoutViewEngine.cs b/src/Orchard/Mvc/ViewEngines/LayoutViewEngine.cs
index 9e6617db3..c5d3e8186 100644
--- a/src/Orchard/Mvc/ViewEngines/LayoutViewEngine.cs
+++ b/src/Orchard/Mvc/ViewEngines/LayoutViewEngine.cs
@@ -2,6 +2,7 @@
using System.Linq;
using System.Web.Mvc;
using Orchard.Mvc.ViewModels;
+using Orchard.Themes;
namespace Orchard.Mvc.ViewEngines {
public class LayoutViewEngine : IViewEngine {
@@ -24,6 +25,8 @@ namespace Orchard.Mvc.ViewEngines {
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)
diff --git a/src/Orchard/Orchard.csproj b/src/Orchard/Orchard.csproj
index 259a8e8a0..1f63a6418 100644
--- a/src/Orchard/Orchard.csproj
+++ b/src/Orchard/Orchard.csproj
@@ -225,6 +225,7 @@
+
diff --git a/src/Orchard/Themes/ThemeFilter.cs b/src/Orchard/Themes/ThemeFilter.cs
new file mode 100644
index 000000000..e5d71b612
--- /dev/null
+++ b/src/Orchard/Themes/ThemeFilter.cs
@@ -0,0 +1,55 @@
+using System.Linq;
+using System.Web.Mvc;
+using System.Web.Routing;
+using Orchard.Mvc.Filters;
+using Orchard.Mvc.ViewModels;
+
+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);
+ }
+ }
+
+ public void OnActionExecuted(ActionExecutedContext filterContext) {
+ }
+
+ public void OnResultExecuting(ResultExecutingContext filterContext) {
+ var viewResult = filterContext.Result as ViewResult;
+ if (viewResult == null)
+ return;
+
+ var model = viewResult.ViewData.Model as BaseViewModel;
+ if (model == null)
+ return;
+
+ Apply(filterContext.RequestContext);
+ }
+
+ public void OnResultExecuted(ResultExecutedContext filterContext) {
+
+ }
+
+ public static void Apply(RequestContext context) {
+ // the value isn't important
+ context.HttpContext.Items[typeof(ThemeFilter)] = null;
+ }
+
+ public static bool IsApplied(RequestContext context) {
+ return context.HttpContext.Items.Contains(typeof(ThemeFilter));
+ }
+
+
+ private static ThemedAttribute GetThemedAttribute(ActionDescriptor descriptor) {
+ return descriptor.GetCustomAttributes(typeof(ThemedAttribute), true)
+ .Concat(descriptor.ControllerDescriptor.GetCustomAttributes(typeof(ThemedAttribute), true))
+ .OfType()
+ .FirstOrDefault();
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/src/Orchard/UI/Admin/AdminFilter.cs b/src/Orchard/UI/Admin/AdminFilter.cs
index e414f85c4..36b47c88d 100644
--- a/src/Orchard/UI/Admin/AdminFilter.cs
+++ b/src/Orchard/UI/Admin/AdminFilter.cs
@@ -30,11 +30,11 @@ namespace Orchard.UI.Admin {
public static void Apply(RequestContext context) {
// the value isn't important
- context.HttpContext.Items[typeof(AdminThemeSelector)] = null;
+ context.HttpContext.Items[typeof(AdminFilter)] = null;
}
public static bool IsApplied(RequestContext context) {
- return context.HttpContext.Items.Contains(typeof(AdminThemeSelector));
+ return context.HttpContext.Items.Contains(typeof(AdminFilter));
}
private static bool IsAdmin(AuthorizationContext filterContext) {