Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid HTML module using Globals.DependencyProvider #4786

Merged
merged 1 commit into from
Sep 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion DNN Platform/Modules/HTML/Components/HtmlTextController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@ public class HtmlTextController : ModuleSearchBase, IPortable, IUpgradeable
private const string PortalRootToken = "{{PortalRoot}}";

public HtmlTextController()
: this(Globals.DependencyProvider.GetRequiredService<INavigationManager>())
{
this.NavigationManager = Globals.DependencyProvider.GetRequiredService<INavigationManager>();
}

public HtmlTextController(INavigationManager navigationManager)
{
this.NavigationManager = navigationManager;
}

protected INavigationManager NavigationManager { get; }
Expand Down
3 changes: 2 additions & 1 deletion DNN Platform/Modules/HTML/EditHtml.ascx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ public partial class EditHtml : HtmlModuleBase
{
private readonly INavigationManager _navigationManager;

private readonly HtmlTextController _htmlTextController = new HtmlTextController();
private readonly HtmlTextController _htmlTextController;
private readonly HtmlTextLogController _htmlTextLogController = new HtmlTextLogController();
private readonly WorkflowStateController _workflowStateController = new WorkflowStateController();

public EditHtml()
{
this._navigationManager = this.DependencyProvider.GetRequiredService<INavigationManager>();
this._htmlTextController = new HtmlTextController(this._navigationManager);
}

private enum WorkflowType
Expand Down
10 changes: 5 additions & 5 deletions DNN Platform/Modules/HTML/HtmlModule.ascx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public ModuleActionCollection ModuleActions
false);

// get the content
var objHTML = new HtmlTextController();
var objHTML = new HtmlTextController(this._navigationManager);
var objWorkflow = new WorkflowStateController();
this.WorkflowID = objHTML.GetWorkflow(this.ModuleId, this.TabId, this.PortalId).Value;

Expand Down Expand Up @@ -159,7 +159,7 @@ protected override void OnInit(EventArgs e)
this.EditorEnabled = this.PortalSettings.InlineEditorEnabled;
try
{
this.WorkflowID = new HtmlTextController().GetWorkflow(this.ModuleId, this.TabId, this.PortalId).Value;
this.WorkflowID = new HtmlTextController(this._navigationManager).GetWorkflow(this.ModuleId, this.TabId, this.PortalId).Value;

// Add an Action Event Handler to the Skin
this.AddActionHandler(this.ModuleAction_Click);
Expand All @@ -182,7 +182,7 @@ protected override void OnLoad(EventArgs e)
base.OnLoad(e);
try
{
var objHTML = new HtmlTextController();
var objHTML = new HtmlTextController(this._navigationManager);

// edit in place
if (this.EditorEnabled && this.IsEditable && Personalization.GetUserMode() == PortalSettings.Mode.Edit)
Expand Down Expand Up @@ -290,7 +290,7 @@ private void lblContent_UpdateLabel(object source, DNNLabelEditEventArgs e)
else if (this.EditorEnabled && this.IsEditable && Personalization.GetUserMode() == PortalSettings.Mode.Edit)
{
// get content
var objHTML = new HtmlTextController();
var objHTML = new HtmlTextController(this._navigationManager);
var objWorkflow = new WorkflowStateController();
HtmlTextInfo objContent = objHTML.GetTopHtmlText(this.ModuleId, false, this.WorkflowID);
if (objContent == null)
Expand Down Expand Up @@ -336,7 +336,7 @@ private void ModuleAction_Click(object sender, ActionEventArgs e)
if (this.IsEditable && Personalization.GetUserMode() == PortalSettings.Mode.Edit)
{
// get content
var objHTML = new HtmlTextController();
var objHTML = new HtmlTextController(this._navigationManager);
HtmlTextInfo objContent = objHTML.GetTopHtmlText(this.ModuleId, false, this.WorkflowID);

var objWorkflow = new WorkflowStateController();
Expand Down
18 changes: 14 additions & 4 deletions DNN Platform/Modules/HTML/Settings.ascx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ namespace DotNetNuke.Modules.Html
{
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Generic;

using DotNetNuke.Abstractions;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Modules.Html.Components;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Services.Exceptions;

using Microsoft.Extensions.DependencyInjection;

/// <summary>
/// The Settings ModuleSettingsBase is used to manage the
Expand All @@ -21,6 +24,13 @@ public partial class Settings : ModuleSettingsBase
{
private HtmlModuleSettings _moduleSettings;

private readonly INavigationManager _navigationManager;

public Settings()
{
this._navigationManager = this.DependencyProvider.GetRequiredService<INavigationManager>();
}

private new HtmlModuleSettings ModuleSettings
{
get
Expand All @@ -40,7 +50,7 @@ public override void LoadSettings()
{
if (!this.Page.IsPostBack)
{
var htmlTextController = new HtmlTextController();
var htmlTextController = new HtmlTextController(this._navigationManager);
var workflowStateController = new WorkflowStateController();

this.chkReplaceTokens.Checked = this.ModuleSettings.ReplaceTokens;
Expand Down Expand Up @@ -89,7 +99,7 @@ public override void UpdateSettings()
{
try
{
var htmlTextController = new HtmlTextController();
var htmlTextController = new HtmlTextController(this._navigationManager);

// update replace token setting
this.ModuleSettings.ReplaceTokens = this.chkReplaceTokens.Checked;
Expand Down