@@ -15,6 +15,7 @@ namespace DotNetNuke.Framework
1515 using System . Web . UI . WebControls ;
1616
1717 using DotNetNuke . Abstractions ;
18+ using DotNetNuke . Abstractions . Application ;
1819 using DotNetNuke . Abstractions . Portals ;
1920 using DotNetNuke . Application ;
2021 using DotNetNuke . Common . Utilities ;
@@ -42,23 +43,34 @@ namespace DotNetNuke.Framework
4243
4344 using DataCache = DotNetNuke . Common . Utilities . DataCache ;
4445 using Globals = DotNetNuke . Common . Globals ;
46+ using ReleaseMode = DotNetNuke . Abstractions . Application . ReleaseMode ;
4547
46- /// <summary>
47- /// The DNN default page.
48- /// </summary>
48+ /// <summary>The DNN default page.</summary>
4949 public partial class DefaultPage : CDefault , IClientAPICallbackEventHandler
5050 {
5151 private static readonly ILog Logger = LoggerSource . Instance . GetLogger ( typeof ( DefaultPage ) ) ;
5252 private static readonly Regex HeaderTextRegex = new Regex (
5353 "<meta([^>])+name=('|\" )robots('|\" )" ,
5454 RegexOptions . IgnoreCase | RegexOptions . Multiline | RegexOptions . Compiled ) ;
5555
56- /// <summary>
57- /// Initializes a new instance of the <see cref="DefaultPage"/> class.
58- /// </summary>
56+ private readonly IApplicationInfo appInfo ;
57+ private readonly IModuleControlPipeline moduleControlPipeline ;
58+
59+ /// <summary>Initializes a new instance of the <see cref="DefaultPage"/> class.</summary>
5960 public DefaultPage ( )
61+ : this ( null , null , null )
6062 {
61- this . NavigationManager = Globals . GetCurrentServiceProvider ( ) . GetRequiredService < INavigationManager > ( ) ;
63+ }
64+
65+ /// <summary>Initializes a new instance of the <see cref="DefaultPage"/> class.</summary>
66+ /// <param name="navigationManager">The navigation manager.</param>
67+ /// <param name="appInfo">The application info.</param>
68+ /// <param name="moduleControlPipeline">The module control pipeline.</param>
69+ public DefaultPage ( INavigationManager navigationManager , IApplicationInfo appInfo , IModuleControlPipeline moduleControlPipeline )
70+ {
71+ this . NavigationManager = navigationManager ?? Globals . GetCurrentServiceProvider ( ) . GetRequiredService < INavigationManager > ( ) ;
72+ this . appInfo = appInfo ?? Globals . GetCurrentServiceProvider ( ) . GetRequiredService < IApplicationInfo > ( ) ;
73+ this . moduleControlPipeline = moduleControlPipeline ?? Globals . GetCurrentServiceProvider ( ) . GetRequiredService < IModuleControlPipeline > ( ) ;
6274 }
6375
6476 public string CurrentSkinPath
@@ -135,6 +147,10 @@ protected string HtmlAttributeList
135147 }
136148 }
137149
150+ private IPortalAliasInfo CurrentPortalAlias => this . PortalSettings . PortalAlias ;
151+
152+ private IPortalAliasInfo PrimaryPortalAlias => this . PortalSettings . PrimaryAlias ;
153+
138154 /// <inheritdoc/>
139155 public string RaiseClientAPICallbackEvent ( string eventArgument )
140156 {
@@ -167,7 +183,7 @@ public string RaiseClientAPICallbackEvent(string eventArgument)
167183 /// <returns>A value indicating whether the current version is not a production version.</returns>
168184 protected bool NonProductionVersion ( )
169185 {
170- return DotNetNukeContext . Current . Application . Status != ReleaseMode . Stable ;
186+ return this . appInfo . Status != ReleaseMode . Stable ;
171187 }
172188
173189 /// <summary>Contains the functionality to populate the Root aspx page with controls.</summary>
@@ -215,7 +231,7 @@ protected override void OnInit(EventArgs e)
215231 }
216232 else
217233 {
218- this . Response . Redirect ( Globals . GetPortalDomainName ( this . PortalSettings . PortalAlias . HTTPAlias , this . Request , true ) , true ) ;
234+ this . Response . Redirect ( Globals . GetPortalDomainName ( this . CurrentPortalAlias . HttpAlias , this . Request , true ) , true ) ;
219235 }
220236 }
221237 }
@@ -227,18 +243,18 @@ protected override void OnInit(EventArgs e)
227243 if ( Config . GetFriendlyUrlProvider ( ) == "advanced" )
228244 {
229245 // advanced mode compares on the primary alias as set during alias identification
230- if ( this . PortalSettings . PrimaryAlias != null && this . PortalSettings . PortalAlias != null )
246+ if ( this . PrimaryPortalAlias != null && this . PortalSettings . PortalAlias != null )
231247 {
232- if ( string . Compare ( this . PortalSettings . PrimaryAlias . HTTPAlias , this . PortalSettings . PortalAlias . HTTPAlias , StringComparison . InvariantCulture ) != 0 )
248+ if ( string . Compare ( this . PrimaryPortalAlias . HttpAlias , this . CurrentPortalAlias . HttpAlias , StringComparison . InvariantCulture ) != 0 )
233249 {
234- primaryHttpAlias = this . PortalSettings . PrimaryAlias . HTTPAlias ;
250+ primaryHttpAlias = this . PrimaryPortalAlias . HttpAlias ;
235251 }
236252 }
237253 }
238254 else
239255 {
240256 // other modes just depend on the default alias
241- if ( string . Compare ( this . PortalSettings . PortalAlias . HTTPAlias , this . PortalSettings . DefaultPortalAlias , StringComparison . InvariantCulture ) != 0 )
257+ if ( string . Compare ( this . CurrentPortalAlias . HttpAlias , this . PortalSettings . DefaultPortalAlias , StringComparison . InvariantCulture ) != 0 )
242258 {
243259 primaryHttpAlias = this . PortalSettings . DefaultPortalAlias ;
244260 }
@@ -248,7 +264,7 @@ protected override void OnInit(EventArgs e)
248264 {
249265 // a primary http alias was identified
250266 var originalurl = this . Context . Items [ "UrlRewrite:OriginalUrl" ] . ToString ( ) ;
251- this . CanonicalLinkUrl = originalurl . Replace ( this . PortalSettings . PortalAlias . HTTPAlias , primaryHttpAlias ) ;
267+ this . CanonicalLinkUrl = originalurl . Replace ( this . CurrentPortalAlias . HttpAlias , primaryHttpAlias ) ;
252268
253269 if ( UrlUtils . IsSecureConnectionOrSslOffload ( this . Request ) )
254270 {
@@ -460,27 +476,20 @@ private void InitializePage()
460476 // Skip is popup is just a tab (no slave module)
461477 if ( slaveModule . DesktopModuleID != Null . NullInteger )
462478 {
463- var control = ModuleControlFactory . CreateModuleControl ( slaveModule ) as IModuleControl ;
479+ var control = ( IModuleControl ) this . moduleControlPipeline . CreateModuleControl ( slaveModule ) ;
464480 string extension = Path . GetExtension ( slaveModule . ModuleControl . ControlSrc . ToLowerInvariant ( ) ) ;
465481 switch ( extension )
466482 {
467483 case ".mvc" :
468484 var segments = slaveModule . ModuleControl . ControlSrc . Replace ( ".mvc" , string . Empty ) . Split ( '/' ) ;
469-
470- control . LocalResourceFile = string . Format (
471- "~/DesktopModules/MVC/{0}/{1}/{2}.resx" ,
472- slaveModule . DesktopModule . FolderName ,
473- Localization . LocalResourceDirectory ,
474- segments [ 0 ] ) ;
485+ control . LocalResourceFile =
486+ $ "~/DesktopModules/MVC/{ slaveModule . DesktopModule . FolderName } /{ Localization . LocalResourceDirectory } /{ segments [ 0 ] } .resx";
475487 break ;
476488 default :
477- control . LocalResourceFile = string . Concat (
478- slaveModule . ModuleControl . ControlSrc . Replace (
479- Path . GetFileName ( slaveModule . ModuleControl . ControlSrc ) ,
480- string . Empty ) ,
481- Localization . LocalResourceDirectory ,
482- "/" ,
483- Path . GetFileName ( slaveModule . ModuleControl . ControlSrc ) ) ;
489+ var controlFileName = Path . GetFileName ( slaveModule . ModuleControl . ControlSrc ) ;
490+ var controlSrcPath = slaveModule . ModuleControl . ControlSrc . Replace ( controlFileName , string . Empty ) ;
491+ control . LocalResourceFile =
492+ $ "{ controlSrcPath } { Localization . LocalResourceDirectory } /{ controlFileName } ";
484493 break ;
485494 }
486495
@@ -599,8 +608,7 @@ private void InitializePage()
599608 // NonProduction Label Injection
600609 if ( this . NonProductionVersion ( ) && Host . DisplayBetaNotice && ! UrlUtils . InPopUp ( ) )
601610 {
602- string versionString =
603- $ " ({ DotNetNukeContext . Current . Application . Status } Version: { DotNetNukeContext . Current . Application . Version } )";
611+ string versionString = $ " ({ this . appInfo . Status } Version: { this . appInfo . Version } )";
604612 this . Title += versionString ;
605613 }
606614
0 commit comments