forked from dnnsoftware/Dnn.Platform
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sacha Trauwaen
committed
Sep 11, 2024
1 parent
5def7cc
commit 07d8366
Showing
36 changed files
with
3,999 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
581 changes: 581 additions & 0 deletions
581
DNN Platform/DotNetNuke.Web.Client/MvcClientResourceManager.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information | ||
namespace DotNetNuke.Web.Mvc | ||
{ | ||
using System; | ||
using System.Web; | ||
using System.Web.Mvc; | ||
using System.Web.Routing; | ||
using System.Web.SessionState; | ||
|
||
using DotNetNuke.ComponentModel; | ||
using DotNetNuke.Entities.Portals; | ||
using DotNetNuke.HttpModules.Membership; | ||
using DotNetNuke.Services.Localization; | ||
using DotNetNuke.UI.Modules; | ||
using DotNetNuke.Web.Mvc.Common; | ||
using DotNetNuke.Web.Mvc.Framework.Modules; | ||
using DotNetNuke.Web.Mvc.Routing; | ||
|
||
public class DnnMvcPageHandler : MvcHandler, IHttpHandler, IRequiresSessionState | ||
{ | ||
public DnnMvcPageHandler(RequestContext requestContext) | ||
: base(requestContext) | ||
{ | ||
} | ||
|
||
/// <inheritdoc/> | ||
protected override void ProcessRequest(HttpContext httpContext) | ||
{ | ||
this.SetThreadCulture(); | ||
MembershipModule.AuthenticateRequest(this.RequestContext.HttpContext, allowUnknownExtensions: true); | ||
base.ProcessRequest(httpContext); | ||
} | ||
|
||
protected override IAsyncResult BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, object state) | ||
{ | ||
this.SetThreadCulture(); | ||
MembershipModule.AuthenticateRequest(this.RequestContext.HttpContext, allowUnknownExtensions: true); | ||
return base.BeginProcessRequest(httpContext, callback, state); | ||
} | ||
|
||
private void SetThreadCulture() | ||
{ | ||
var portalSettings = PortalController.Instance.GetCurrentSettings(); | ||
if (portalSettings is null) | ||
{ | ||
return; | ||
} | ||
|
||
var pageLocale = Localization.GetPageLocale(portalSettings); | ||
if (pageLocale is null) | ||
{ | ||
return; | ||
} | ||
|
||
Localization.SetThreadCultures(pageLocale, portalSettings); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information | ||
namespace DotNetNuke.Web.Mvc | ||
{ | ||
using System; | ||
using System.Web; | ||
using System.Web.Mvc; | ||
using System.Web.Routing; | ||
using System.Web.SessionState; | ||
|
||
public class DnnMvcPageRouteHandler : IRouteHandler | ||
{ | ||
private readonly IControllerFactory controllerFactory; | ||
|
||
/// <summary>Initializes a new instance of the <see cref="DnnMvcPageRouteHandler"/> class.</summary> | ||
public DnnMvcPageRouteHandler() | ||
{ | ||
} | ||
|
||
/// <summary>Initializes a new instance of the <see cref="DnnMvcPageRouteHandler"/> class.</summary> | ||
/// <param name="controllerFactory">The controller factory.</param> | ||
public DnnMvcPageRouteHandler(IControllerFactory controllerFactory) | ||
{ | ||
this.controllerFactory = controllerFactory; | ||
} | ||
|
||
/// <inheritdoc/> | ||
IHttpHandler IRouteHandler.GetHttpHandler(RequestContext requestContext) | ||
{ | ||
return this.GetHttpHandler(requestContext); | ||
} | ||
|
||
protected virtual IHttpHandler GetHttpHandler(RequestContext requestContext) | ||
{ | ||
requestContext.HttpContext.SetSessionStateBehavior(this.GetSessionStateBehavior(requestContext)); | ||
return new DnnMvcPageHandler(requestContext); | ||
} | ||
|
||
protected virtual SessionStateBehavior GetSessionStateBehavior(RequestContext requestContext) | ||
{ | ||
string controllerName = (string)requestContext.RouteData.Values["controller"]; | ||
if (string.IsNullOrWhiteSpace(controllerName)) | ||
{ | ||
throw new InvalidOperationException("No Controller"); | ||
} | ||
|
||
IControllerFactory controllerFactory = this.controllerFactory ?? ControllerBuilder.Current.GetControllerFactory(); | ||
return controllerFactory.GetControllerSessionBehavior(requestContext, controllerName); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
DNN Platform/DotNetNuke.Web.Mvc/Skins/Controllers/DnnPageController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information | ||
|
||
namespace DotNetNuke.Web.Mvc.Skins.Controllers | ||
{ | ||
using System; | ||
using System.Text; | ||
using System.Web.Mvc; | ||
using System.Web.Routing; | ||
using System.Web.UI; | ||
|
||
using DotNetNuke.Entities.Modules; | ||
using DotNetNuke.Entities.Modules.Actions; | ||
using DotNetNuke.Entities.Portals; | ||
using DotNetNuke.Entities.Tabs; | ||
using DotNetNuke.Entities.Users; | ||
using DotNetNuke.Services.Localization; | ||
using DotNetNuke.UI.Modules; | ||
using DotNetNuke.Web.Mvc.Framework.ActionResults; | ||
using DotNetNuke.Web.Mvc.Framework.Modules; | ||
using DotNetNuke.Web.Mvc.Helpers; | ||
|
||
public abstract class DnnPageController : Controller // IDnnController | ||
{ | ||
/// <summary>Initializes a new instance of the <see cref="DnnPageController"/> class.</summary> | ||
protected DnnPageController() | ||
{ | ||
// this.ActionInvoker = new ResultCapturingActionInvoker(); | ||
} | ||
|
||
public TabInfo ActivePage | ||
{ | ||
get { return (this.PortalSettings == null) ? null : this.PortalSettings.ActiveTab; } | ||
} | ||
|
||
public PortalSettings PortalSettings | ||
{ | ||
get | ||
{ | ||
return PortalController.Instance.GetCurrentPortalSettings(); | ||
} | ||
} | ||
|
||
public ActionResult ResultOfLastExecute | ||
{ | ||
get | ||
{ | ||
var actionInvoker = this.ActionInvoker as ResultCapturingActionInvoker; | ||
return (actionInvoker != null) ? actionInvoker.ResultOfLastInvoke : null; | ||
} | ||
} | ||
|
||
/* | ||
public new UserInfo User | ||
{ | ||
get { return (this.PortalSettings == null) ? null : this.PortalSettings.UserInfo; } | ||
} | ||
public new DnnUrlHelper Url { get; set; } | ||
*/ | ||
public string LocalResourceFile { get; set; } | ||
|
||
public string LocalizeString(string key) | ||
{ | ||
return Localization.GetString(key, this.LocalResourceFile); | ||
} | ||
|
||
/// <inheritdoc/> | ||
protected override void Initialize(RequestContext requestContext) | ||
{ | ||
base.Initialize(requestContext); | ||
|
||
// this.Url = new DnnUrlHelper(requestContext, this); | ||
} | ||
} | ||
} |
Oops, something went wrong.