-
Notifications
You must be signed in to change notification settings - Fork 0
/
Index_Manager.aspx.cs
426 lines (301 loc) · 14.3 KB
/
Index_Manager.aspx.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DotNetNuke.Services.Localization;
using DotNetNuke.Entities.Modules;
using DotNetNuke.Security.Permissions;
using DotNetNuke.Security;
using DotNetNuke.Common;
using System.Threading;
namespace Playngo.Modules.ClientZone
{
public partial class Index_Manager : BasePage
{
#region "==属性=="
/// <summary>
/// 当前标签
/// </summary>
public String Token
{
get { return WebHelper.GetStringParam(HttpContext.Current.Request, "Token", MainModule ? "ProductRoadmap" : "Settings").ToLower(); }
}
/// <summary>
/// 提示操作类
/// </summary>
MessageTips mTips = new MessageTips();
/// <summary>
/// 是否为主模块
/// </summary>
private Boolean MainModule
{
get { return !String.IsNullOrEmpty(BaseModuleName) && BaseModuleName == "Playngo_ClientZone"; }
}
/// <summary>
/// 只显示某个菜单
/// </summary>
private String OnlyMenu = WebHelper.GetStringParam(HttpContext.Current.Request, "OnlyMenu", "");
public Boolean AdvancedPermissions
{
get { return ViewSettingT<Boolean>("General.AdvancedPermissions", true); }
}
/// <summary>
/// 查询参数
/// </summary>
public String QueryString
{
get { return String.Format("{0}&ModulePath={1}", WebHelper.GetScriptNameQueryString, HttpUtility.UrlEncode(ModulePath)); }
}
#endregion
#region "==方法=="
private MenuTabCollection _InitMenuTabCollection = new MenuTabCollection();
/// <summary>
/// 初始化标签集合
/// </summary>
public MenuTabCollection InitMenuTabCollection
{
get
{
if (_InitMenuTabCollection == null || _InitMenuTabCollection.Count < 1)
{
//靠XML地址切换菜单配置文件的地址
String MenuPath = MapPath(String.Format("{0}Resource/xml/MenuTabs.xml", ModulePath));
if (!MainModule)
{
if (BaseModuleName == "Playngo_ClientZone_Display")
{
MenuPath = MapPath(String.Format("{0}Resource/xml/MenuTabs.Display.xml", ModulePath));
}
}
XmlFormat xf = new XmlFormat(MenuPath);
List<MenuTabItem> tabs = xf.ToList<MenuTabItem>();
if (String.IsNullOrEmpty(OnlyMenu))
{
foreach (MenuTabItem item in tabs)
{
_InitMenuTabCollection.Add(item);
}
}
else
{
_InitMenuTabCollection.Add(tabs.Find(r=>r.Token ==OnlyMenu ));
}
//BindMenuTabCollection();//绑定标签集合参数
}
return _InitMenuTabCollection;
}
}
/// <summary>
/// 绑定左菜单
/// </summary>
public void BindLeftMenu()
{
if (InitMenuTabCollection != null && InitMenuTabCollection.Count > 0)
{
List<MenuTabItem> TokenItems = InitMenuTabCollection.ToList();
System.Text.StringBuilder sb = new System.Text.StringBuilder();
for (int i=0;i< TokenItems.Count;i++ )
{
if (String.IsNullOrEmpty(TokenItems[i].Parent) && TokenItems[i].Visible)
{
MenuTabItem item = TokenItems[i];
if (!item.IsAdministrator || IsAdministrator || (IsAdmin && AdvancedPermissions) )
{
String ChildHtml = String.Empty;
bool is_active = false;
bool is_Child = false;
List<MenuTabItem> ChildList = InitMenuTabCollection.FindByParent(TokenItems[i].Token);
if (ChildList.Count > 0)
{
ChildHtml = BindLeftMenuBySubmenu(ChildList, out is_active);
is_Child = true;
}
if (item.Token.ToLower() == Token.ToLower())
{
is_active = true;
}
String active_class = is_active ? "active open" : "";
String item_url = (ChildList != null && ChildList.Count > 0) || String.IsNullOrEmpty(item.Src) ? "javascript:;" : String.Format("{0}Index_Manager.aspx?PortalId={1}&TabId={2}&ModuleId={3}&Token={4}&language={5}{6}", ModulePath, PortalId, TabId, ModuleId, item.Token,language, ConvertParameter(item.Parameter)); ;
String item_icon = string.IsNullOrEmpty(item.Icon) ? "" : String.Format("<i class=\"{0}\"></i>", item.Icon);
sb.AppendFormat("<li class=\"{0}\">", active_class).AppendLine();
sb.AppendFormat("<a href=\"{0}\">{1} <span class=\"{2}\"> {2} </span> <span class=\"selected\"></span>", item_url, item_icon, ViewMenuText(item));
if (is_Child)
{
sb.Append("<i class=\"icon-arrow\"></i> ");
}
sb.Append("</a>").AppendLine();
sb.Append(ChildHtml).AppendLine();
sb.Append("</li>").AppendLine();
}
}
}
liLeftMenu.Text = sb.ToString();
}
}
/// <summary>
/// 绑定左边子菜单
/// </summary>
public String BindLeftMenuBySubmenu(List<MenuTabItem> TokenItems, out Boolean is_active)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
is_active = false;
sb.Append("<ul class=\"sub-menu\">").AppendLine();
foreach (MenuTabItem item in TokenItems)
{
String active_class = String.Empty;
if (item.Token.ToLower() == Token.ToLower() || (!String.IsNullOrEmpty(item.Link) && item.Link.ToLower() == Token.ToLower()))
{
is_active = true;
active_class = "active open";
}
if (item.Visible)
{
if (!item.IsAdministrator || IsAdministrator || (IsAdmin && AdvancedPermissions))
{
String language = WebHelper.GetStringParam(Request, "language", PortalSettings.DefaultLanguage);
String item_url = String.Format("{0}Index_Manager.aspx?PortalId={1}&TabId={2}&ModuleId={3}&Token={4}&language={5}{6}", ModulePath, PortalId, TabId, ModuleId, item.Token, language, ConvertParameter(item.Parameter)); ;
String item_icon = string.IsNullOrEmpty(item.Icon) ? "" : String.Format("<i class=\"{0}\"></i>", item.Icon);
sb.AppendFormat("<li class=\"{0}\">", active_class).AppendLine();
sb.AppendFormat("<a href=\"{0}\">{1} <span class=\"title\"> {2} </span> </a>", item_url, item_icon, ViewMenuText(item)).AppendLine();
sb.Append("</li>").AppendLine();
}
}
}
sb.Append("</ul>").AppendLine();
return sb.ToString();
}
public String ViewMenuText(MenuTabItem item)
{
String ResourceName = String.Format("Menu_{0}",item.Token);
return ViewResourceText(ResourceName, item.Title);
}
public String ConvertParameter(String parameter)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
if (!String.IsNullOrEmpty(parameter))
{
List<String> ss = Common.GetList(parameter);
foreach (String s in ss)
{
sb.AppendFormat("&{0}",s);
}
}
return sb.ToString();
}
/// <summary>
/// 绑定控件到容器
/// </summary>
public void BindContainer()
{
MenuTabItem _MenuTabItem = InitMenuTabCollection.ContainsKey(Token) ? InitMenuTabCollection[Token] : new MenuTabItem();
if (_MenuTabItem != null && !String.IsNullOrEmpty(_MenuTabItem.Token) && !this.DesignMode)
{
//判断是否为管理员菜单,当前用户是否为管理员
if (!(!_MenuTabItem.IsAdministrator || IsAdministrator || (IsAdmin && AdvancedPermissions)))
{
phContainer.Visible = false;
mTips.MsgType = EnumTips.Warning;
mTips.Content = ViewResourceText("HasModuleAccess", "You are not permitted to access this page! :(");
mTips.Put();
}
else
{
//加载相应的控件
BaseModule ManageContent = new BaseModule();
string ContentSrc = ResolveClientUrl(string.Format("{0}/{1}", this.TemplateSourceDirectory, _MenuTabItem.Src));
if (System.IO.File.Exists(MapPath(ContentSrc)))
{
ManageContent = (BaseModule)LoadControl(ContentSrc);
ManageContent.ModuleConfiguration = ModuleConfiguration;
ManageContent.ID = _MenuTabItem.Token;
ManageContent.LocalResourceFile = Localization.GetResourceFile(this, string.Format("{0}.resx", _MenuTabItem.Src));
phContainer.Controls.Add(ManageContent);
}
}
//标题
Page.Title = String.Format("{0} - {1} - {2}", ViewMenuText(_MenuTabItem), ModuleConfiguration.ModuleTitle, PortalSettings.ActiveTab.LocalizedTabName);
}
else if (!String.IsNullOrEmpty(Token) && Token.ToLower() == "error")
{
//加载相应的控件
BaseModule ManageContent = new BaseModule();
string ContentSrc = ResolveClientUrl(string.Format("{0}/{1}", this.TemplateSourceDirectory, "Manager_ErrorCatch.ascx"));
if (System.IO.File.Exists(MapPath(ContentSrc)))
{
ManageContent = (BaseModule)LoadControl(ContentSrc);
ManageContent.ModuleConfiguration = ModuleConfiguration;
ManageContent.ID = "ErrorCatch";
ManageContent.LocalResourceFile = Localization.GetResourceFile(this, string.Format("{0}.resx", "Manager_ErrorCatch.ascx"));
phContainer.Controls.Add(ManageContent);
}
//标题
Page.Title = String.Format("{0} - {1}", "Error", ModuleConfiguration.ModuleTitle);
}
//首页地址
hlHome.NavigateUrl = Globals.NavigateURL(TabId);
}
#endregion
#region "==事件=="
/// <summary>
/// 页面加载
/// </summary>
protected void Page_Load(object sender, EventArgs e)
{
Page.Header.DataBind();
}
protected void Page_PreRender(object sender, EventArgs e)
{
MessageTips mt = new MessageTips();
String MessageShow = mt.EventHtml(this);
if (!String.IsNullOrEmpty(MessageShow))
{
lblMessage.Text = MessageShow;
lblMessage.Visible = true;
}
else if (String.IsNullOrEmpty(Settings_SkinName))
{
lblMessage.Text =mt.ViewContentToHtml( ViewResourceText("", "请设置模块主题皮肤/效果"));
lblMessage.Visible = true;
}
else if (MainModule && String.IsNullOrEmpty(Settings_SkinDetailName))
{
lblMessage.Text = mt.ViewContentToHtml( ViewResourceText("","请设置模块主题皮肤(详情)"));
lblMessage.Visible = true;
}
else
{
lblMessage.Visible = false;
}
}
protected override void Page_Init(System.Object sender, System.EventArgs e)
{
//调用基类Page_Init,主要用于权限验证
base.Page_Init(sender, e);
try
{
if (!IsPostBack)
{
DotNetNuke.Entities.Modules.ModuleInfo m = ModuleConfiguration;
litModuleTitle.Text = BaseModuleName;
litModuleVersion.Text = ModuleProperty( m,"Version");
String Downloadlink = String.Empty;
String latestversion = String.Empty;
//litUpdateVersion.Text = Common.LoadUpdateVersionBy2("Playngo_ClientZone", m.Version, out Downloadlink, out latestversion);
hlModuleLink.NavigateUrl = Downloadlink;
hlModuleLink.Attributes.Add("data-original-title", String.Format(ViewResourceText("latest_version", "Click to download the latest version:{0}"), latestversion));
}
//LoadManagerScript();
//绑定Tabs和容器中的控件
BindContainer();
// 绑定左菜单
BindLeftMenu();
}
catch (Exception exc) //Module failed to load
{
DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc);
}
}
#endregion
}
}