forked from EngageSoftware/Engage-Publish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AdminLoader.ascx.cs
149 lines (131 loc) · 5.57 KB
/
AdminLoader.ascx.cs
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
// <copyright file="AdminLoader.ascx.cs" company="Engage Software">
// Engage: Publish
// Copyright (c) 2004-2013
// by Engage Software ( http://www.engagesoftware.com )
// </copyright>
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
namespace Engage.Dnn.Publish
{
using System;
using System.Collections.Specialized;
using System.Data;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using DotNetNuke.Services.Localization;
using Engage.Dnn.Publish.Admin;
using Engage.Dnn.Publish.Util;
public partial class AdminLoader : ModuleBase
{
private static StringDictionary _adminControlKeys;
private string _controlToLoad;
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Not a property")]
public static StringDictionary GetAdminControlKeys()
{
if (_adminControlKeys == null)
{
FillAdminControlKeys();
}
return _adminControlKeys;
}
protected override void OnInit(EventArgs e)
{
this.ModuleConfiguration.ModuleTitle = Localization.GetString("Title", this.LocalResourceFile);
this.ReadQueryString();
this.LoadControlType();
base.OnInit(e);
}
private static void FillAdminControlKeys()
{
var adminControlKeys = new StringDictionary
{
{
"CATEGORYLIST", "categorycontrols/CategoryList.ascx"
},
{
"CATEGORYLISTING", "categorycontrols/CategoryListing.ascx"
},
{
"CATEGORYSORT", "categorycontrols/CategorySort.ascx"
},
{
"CATEGORYEDIT", "categorycontrols/CategoryEdit.ascx"
},
{
"VERSIONSLIST", "controls/ItemVersions.ascx"
},
{
"HELP", "admin/AdminInstructions.ascx"
},
{
"ARTICLELIST", "articlecontrols/ArticleList.ascx"
},
{
"ARTICLEEDIT", "articlecontrols/ArticleEdit.ascx"
},
{
"ADMINMAIN", "Admin/AdminMain.ascx"
},
{
"ADMINTOOLS", "Admin/AdminTools.ascx"
},
{
"COMMENTLIST", "Admin/CommentList.ascx"
},
{
"COMMENTEDIT", "Admin/CommentEdit.ascx"
},
{
"ITEMCREATED", "Admin/ItemCreated.ascx"
},
{
"AMSSETTINGS", "Admin/AdminSettings.ascx"
},
{
"DELETEITEM", "Admin/DeleteItem.ascx"
},
{
"SYNDICATION", "Admin/Syndication.ascx"
},
{
"DEFAULT", "Admin/AdminMain.ascx"
}
};
_adminControlKeys = adminControlKeys;
}
private void LoadControlType()
{
var mb = (AdminMain)this.LoadControl("Admin/AdminMain.ascx");
mb.ModuleConfiguration = this.ModuleConfiguration;
mb.ID = Path.GetFileNameWithoutExtension("Admin/AdminMain.ascx");
this.phAdminControls.Controls.Add(mb);
var amb = (ModuleBase)this.LoadControl(this._controlToLoad);
amb.ModuleConfiguration = this.ModuleConfiguration;
amb.ID = Path.GetFileNameWithoutExtension(this._controlToLoad);
this.phControls.Controls.Add(amb);
// TODO: we need to be able to restrict which controls load, it's currently possible to get to the category edit page by changing the URL
}
private void ReadQueryString()
{
StringDictionary returnDict = GetAdminControlKeys();
string adminTypeParam = this.Request.Params["adminType"];
if (Engage.Utility.HasValue(adminTypeParam))
{
this._controlToLoad = returnDict[adminTypeParam.ToUpperInvariant()];
}
else
{
// check to see if there are any categories, if not display an instructions control
DataTable dt = Category.GetCategories(this.PortalId);
this._controlToLoad = dt.Rows.Count < 1 ? "Admin/AdminInstructions.ascx" : "articlecontrols/ArticleList.ascx";
}
if (!this.IsSetup)
{
this._controlToLoad = "Admin/AdminSettings.ascx";
}
}
}
}