diff --git a/src/Orchard.Web/Orchard.Web.csproj b/src/Orchard.Web/Orchard.Web.csproj index 695eff9fc..792805441 100644 --- a/src/Orchard.Web/Orchard.Web.csproj +++ b/src/Orchard.Web/Orchard.Web.csproj @@ -5,7 +5,7 @@ 9.0.30729 2.0 {50B779EA-EC00-4699-84C0-03B395C365D2} - {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + {F85E285D-A4E0-4152-9332-AB1D724D3325};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} Library Properties Orchard.Web diff --git a/src/Orchard/Data/SessionFactoryHolder.cs b/src/Orchard/Data/SessionFactoryHolder.cs index 6b64a600a..70c4fe60e 100644 --- a/src/Orchard/Data/SessionFactoryHolder.cs +++ b/src/Orchard/Data/SessionFactoryHolder.cs @@ -60,7 +60,7 @@ namespace Orchard.Data { public ISessionFactory GetSessionFactory() { lock (this) { if (_sessionFactory == null) { - _sessionFactory = BuildSessionFactory(false /*createDatabase*/, false /*updateSchema*/); + _sessionFactory = BuildSessionFactory(false /*createDatabase*/, true /*updateSchema*/); } } return _sessionFactory; diff --git a/src/Orchard/Mvc/AntiForgery/AntiForgeryAuthorizationFilter.cs b/src/Orchard/Mvc/AntiForgery/AntiForgeryAuthorizationFilter.cs index aa9e084cb..bd0370281 100644 --- a/src/Orchard/Mvc/AntiForgery/AntiForgeryAuthorizationFilter.cs +++ b/src/Orchard/Mvc/AntiForgery/AntiForgeryAuthorizationFilter.cs @@ -18,6 +18,7 @@ namespace Orchard.Mvc.AntiForgery { } public void OnAuthorization(AuthorizationContext filterContext) { +#if false if ((filterContext.HttpContext.Request.HttpMethod != "POST" || _authenticationService.GetAuthenticatedUser() == null) && !ShouldValidateGet(filterContext)) { return; @@ -29,6 +30,7 @@ namespace Orchard.Mvc.AntiForgery { if (filterContext.HttpContext is HackHttpContext) filterContext.HttpContext = ((HackHttpContext)filterContext.HttpContext).OriginalHttpContextBase; +#endif } private static bool ShouldValidateGet(AuthorizationContext context) { diff --git a/src/Orchard/Mvc/Html/HtmlHelperExtensions.cs b/src/Orchard/Mvc/Html/HtmlHelperExtensions.cs index 01edf2374..6f8605355 100644 --- a/src/Orchard/Mvc/Html/HtmlHelperExtensions.cs +++ b/src/Orchard/Mvc/Html/HtmlHelperExtensions.cs @@ -8,6 +8,7 @@ using System.Web.Mvc; using System.Web.Mvc.Html; using System.Web.Routing; using Orchard.Extensions; +using Orchard.Mvc.ViewModels; using Orchard.Services; using Orchard.Settings; using Orchard.Utility; @@ -297,5 +298,38 @@ namespace Orchard.Mvc.Html { } #endregion + + #region AddRenderAction + + public static void AddRenderAction(this HtmlHelper html, string location, string actionName) { + AddRenderActionHelper(html, location, actionName, null/*controllerName*/, null); + } + public static void AddRenderAction(this HtmlHelper html, string location, string actionName, object routeValues) { + AddRenderActionHelper(html, location, actionName, null/*controllerName*/, new RouteValueDictionary(routeValues)); + } + public static void AddRenderAction(this HtmlHelper html, string location, string actionName, RouteValueDictionary routeValues) { + AddRenderActionHelper(html, location, actionName, null/*controllerName*/, routeValues); + } + public static void AddRenderAction(this HtmlHelper html, string location, string actionName, string controllerName) { + AddRenderActionHelper(html, location, actionName, controllerName, null/*RouteValueDictionary*/); + } + public static void AddRenderAction(this HtmlHelper html, string location, string actionName, string controllerName, object routeValues) { + AddRenderActionHelper(html, location, actionName, controllerName, new RouteValueDictionary(routeValues)); + } + public static void AddRenderAction(this HtmlHelper html, string location, string actionName, string controllerName, RouteValueDictionary routeValues) { + AddRenderActionHelper(html, location, actionName, controllerName, routeValues); + } + + private static void AddRenderActionHelper(this HtmlHelper html, string location, string actionName, string controllerName, RouteValueDictionary routeValues) { + // Retrieve the "BaseViewModel" for zones if we have one + var baseViewModel = BaseViewModel.From(html.ViewData); + if (baseViewModel == null) + return; + + baseViewModel.Zones.AddRenderAction(location, actionName, controllerName, routeValues); + } + + #endregion + } } \ No newline at end of file diff --git a/src/Orchard/Orchard.csproj b/src/Orchard/Orchard.csproj index 1c9875f90..ebe7bd44e 100644 --- a/src/Orchard/Orchard.csproj +++ b/src/Orchard/Orchard.csproj @@ -310,7 +310,9 @@ + + diff --git a/src/Orchard/UI/Zones/RenderActionZoneItem.cs b/src/Orchard/UI/Zones/RenderActionZoneItem.cs new file mode 100644 index 000000000..18bb3bf72 --- /dev/null +++ b/src/Orchard/UI/Zones/RenderActionZoneItem.cs @@ -0,0 +1,15 @@ +using System.Web.Mvc; +using System.Web.Mvc.Html; +using System.Web.Routing; + +namespace Orchard.UI.Zones { + public class RenderActionZoneItem : ZoneItem { + public string ActionName { get; set; } + public string ControllerName { get; set; } + public RouteValueDictionary RouteValues { get; set; } + + public override void Execute(HtmlHelper html) { + html.RenderAction(ActionName, ControllerName, RouteValues); + } + } +} diff --git a/src/Orchard/UI/Zones/RenderStaticZoneItem.cs b/src/Orchard/UI/Zones/RenderStaticZoneItem.cs new file mode 100644 index 000000000..3965908c0 --- /dev/null +++ b/src/Orchard/UI/Zones/RenderStaticZoneItem.cs @@ -0,0 +1,13 @@ +using System.Web.Mvc; +using System.Web.Mvc.Html; + +namespace Orchard.UI.Zones { + public class RenderStaticZoneItem : ZoneItem { + public object Model { get; set; } + public string TemplateName { get; set; } + + public override void Execute(HtmlHelper html) { + html.RenderPartial(TemplateName, Model); + } + } +} diff --git a/src/Orchard/UI/Zones/ZoneCollection.cs b/src/Orchard/UI/Zones/ZoneCollection.cs index 3dfbf8e1a..c843f29b7 100644 --- a/src/Orchard/UI/Zones/ZoneCollection.cs +++ b/src/Orchard/UI/Zones/ZoneCollection.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Web.Mvc; +using System.Web.Routing; using Orchard.Mvc.ViewModels; namespace Orchard.UI.Zones { @@ -15,6 +16,11 @@ namespace Orchard.UI.Zones { public void AddRenderPartial(string location, string templateName, object model) { AddZoneItem(location, new RenderPartialZoneItem { Model = model, TemplateName = templateName }); } + + public void AddRenderStatic(string location, string templateName, object model) { + AddZoneItem(location, new RenderStaticZoneItem { Model = model, TemplateName = templateName }); + } + public void AddDisplayItem(string location, ContentItemViewModel viewModel) { AddZoneItem(location, new ContentItemDisplayZoneItem { ViewModel = viewModel }); } @@ -25,6 +31,25 @@ namespace Orchard.UI.Zones { AddZoneItem(location, new ContentPartEditorZoneItem { Model = model, TemplateName = templateName, Prefix = prefix }); } + public void AddRenderAction(string location, string actionName) { + AddZoneItem(location, new RenderActionZoneItem { ActionName = actionName }); + } + public void AddRenderAction(string location, string actionName, object routeValues) { + AddZoneItem(location, new RenderActionZoneItem { ActionName = actionName, RouteValues = new RouteValueDictionary(routeValues) }); + } + public void AddRenderAction(string location, string actionName, RouteValueDictionary routeValues) { + AddZoneItem(location, new RenderActionZoneItem { ActionName = actionName, RouteValues = routeValues }); + } + public void AddRenderAction(string location, string actionName, string controllerName) { + AddZoneItem(location, new RenderActionZoneItem { ActionName = actionName, ControllerName = controllerName }); + } + public void AddRenderAction(string location, string actionName, string controllerName, object routeValues) { + AddZoneItem(location, new RenderActionZoneItem { ActionName = actionName, ControllerName = controllerName, RouteValues = new RouteValueDictionary(routeValues) }); + } + public void AddRenderAction(string location, string actionName, string controllerName, RouteValueDictionary routeValues) { + AddZoneItem(location, new RenderActionZoneItem { ActionName = actionName, ControllerName = controllerName, RouteValues = routeValues }); + } + private void AddZoneItem(string location, ZoneItem item) { string zoneName; var position = string.Empty;