-
-
Notifications
You must be signed in to change notification settings - Fork 777
Expand file tree
/
Copy pathDnnController.cs
More file actions
158 lines (134 loc) · 5.15 KB
/
DnnController.cs
File metadata and controls
158 lines (134 loc) · 5.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// 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.Framework.Controllers
{
using System;
using System.Diagnostics.CodeAnalysis;
using System.Text;
using System.Threading.Tasks;
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 DnnController : Controller, IDnnController
{
/// <summary>Initializes a new instance of the <see cref="DnnController"/> class.</summary>
protected DnnController()
{
this.ActionInvoker = new ResultCapturingActionInvoker();
}
public ModuleInfo ActiveModule
{
get { return (this.ModuleContext == null) ? null : this.ModuleContext.Configuration; }
}
public TabInfo ActivePage
{
get { return (this.PortalSettings == null) ? null : this.PortalSettings.ActiveTab; }
}
public PortalSettings PortalSettings
{
get { return (this.ModuleContext == null) ? null : this.ModuleContext.PortalSettings; }
}
/// <inheritdoc />
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; }
}
/// <inheritdoc />
public Page DnnPage { get; set; }
/// <inheritdoc />
public new DnnUrlHelper Url { get; set; }
/// <inheritdoc />
public string LocalResourceFile { get; set; }
/// <inheritdoc />
public ModuleActionCollection ModuleActions { get; set; }
/// <inheritdoc />
public ModuleInstanceContext ModuleContext { get; set; }
/// <inheritdoc />
public ViewEngineCollection ViewEngineCollectionEx { get; set; }
/// <inheritdoc />
public string LocalizeString(string key)
{
return Localization.GetString(key, this.LocalResourceFile);
}
[SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "Breaking change")]
protected internal RedirectToRouteResult RedirectToDefaultRoute()
{
return new DnnRedirecttoRouteResult(string.Empty, string.Empty, string.Empty, null, false);
}
/// <inheritdoc />
protected override RedirectToRouteResult RedirectToAction(string actionName, string controllerName, RouteValueDictionary routeValues)
{
return new DnnRedirecttoRouteResult(actionName, controllerName, string.Empty, routeValues, false, this.Url);
}
/// <inheritdoc />
protected override ViewResult View(IView view, object model)
{
if (model != null)
{
this.ViewData.Model = model;
}
return new DnnViewResult
{
View = view,
ViewData = this.ViewData,
TempData = this.TempData,
};
}
/// <inheritdoc />
protected override ViewResult View(string viewName, string masterName, object model)
{
if (model != null)
{
this.ViewData.Model = model;
}
return new DnnViewResult
{
ViewName = viewName,
MasterName = masterName,
ViewData = this.ViewData,
TempData = this.TempData,
ViewEngineCollection = this.ViewEngineCollection,
};
}
/// <inheritdoc />
protected override PartialViewResult PartialView(string viewName, object model)
{
if (model != null)
{
this.ViewData.Model = model;
}
return new DnnPartialViewResult
{
ViewName = viewName,
ViewData = this.ViewData,
TempData = this.TempData,
ViewEngineCollection = this.ViewEngineCollection,
};
}
/// <inheritdoc />
protected override void Initialize(RequestContext requestContext)
{
base.Initialize(requestContext);
this.Url = new DnnUrlHelper(requestContext, this);
}
}
}