-
Notifications
You must be signed in to change notification settings - Fork 2
/
AdminSettings.ascx.vb
745 lines (595 loc) · 31.7 KB
/
AdminSettings.ascx.vb
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
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
' --- Copyright (c) notice NevoWeb ---
' Copyright (c) 2008 SARL NevoWeb. www.nevoweb.com. BSD License.
' Author: D.C.Lee
' ------------------------------------------------------------------------
' 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.
' ------------------------------------------------------------------------
' This copyright notice may NOT be removed, obscured or modified without written consent from the author.
' --- End copyright notice ---
Imports DotNetNuke
Imports DotNetNuke.Common
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.Localization
Imports NEvoWeb.Modules.NB_Store.SharedFunctions
Imports System.Xml
Namespace NEvoWeb.Modules.NB_Store
'TODO: Re-write to get better admin interface.
Partial Public Class AdminSettings
Inherits BaseAdminModule
#Region "Private Members"
Protected TemID As String = ""
Protected EditTemplateMode As Boolean = False
#End Region
#Region "Event Handlers"
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
selectlang.DisplayNoLang = True
' Determine ItemId of NB_Store to Update
If Not (Request.QueryString("TemId") Is Nothing) Then
TemID = Request.QueryString("TemId")
Else
TemID = ""
End If
'Work out if we're editing templates..
If Not (Request.QueryString("etmode") Is Nothing) Then
If Request.QueryString("etmode") = "1" Then
EditTemplateMode = True
Else
EditTemplateMode = False
End If
Else
EditTemplateMode = False
End If
' If this is the first visit to the page, bind the role data to the datalist
If Not Page.IsPostBack Then
If selectlang.EditedLang = "" Then
selectlang.SelectedLang = "None"
End If
selectlang.EditedLang = ""
cmdDelete.Attributes.Add("onClick", "javascript:return confirm('" & Localization.GetString("DeleteItem", LocalResourceFile) & "');")
If TemID = "" Then
pnlEdit.Visible = False
Else
populateEdit()
End If
ShowTreeMenu()
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub cmdCancel_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdCancel.Click
Try
If EditTemplateMode Then
Response.Redirect(EditUrl("etmode", "1", "AdminSetting"), True)
Else
Response.Redirect(EditUrl("etmode", "0", "AdminSetting"), True)
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub cmdUpdate_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdUpdate.Click
Try
Dim objInfo As NB_Store_SettingsTextInfo
objInfo = updateSettings()
If Not objInfo Is Nothing Then
selectlang.EditedLang = selectlang.SelectedLang
If EditTemplateMode Then
Response.Redirect(EditUrl("TemId", objInfo.SettingName.ToString, "AdminSetting", "etmode=1"), True)
Else
Response.Redirect(EditUrl("TemId", objInfo.SettingName.ToString, "AdminSetting", "etmode=0"), True)
End If
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub cmdDelete_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdDelete.Click
Try
Dim objCtrl As New SettingsController
Dim objInfo As NB_Store_SettingsTextInfo
If EditTemplateMode Then
objInfo = objCtrl.GetSettingsTextNotCached(PortalId, TemID, selectlang.SelectedLang)
objCtrl.DeleteSettingsText(PortalId, TemID, selectlang.SelectedLang)
Else
objInfo = objCtrl.GetSettingObjNotCached(PortalId, TemID, selectlang.SelectedLang)
objCtrl.DeleteSetting(PortalId, TemID, selectlang.SelectedLang)
End If
removeLangCache(PortalId, "nbstoreadminsettingtreemenu" & UserId.ToString)
removeLangCache(PortalId, "nbstoreadmintemplatetreemenu" & UserId.ToString)
If Not objInfo Is Nothing Then
UpdateLog(UserId, Me.ControlName & " - " & System.Reflection.MethodBase.GetCurrentMethod.Name & " - " & DotNetNuke.Common.Utilities.XmlUtils.Serialize(objInfo))
If objInfo.Lang.Trim = "None" Then
If EditTemplateMode Then
Response.Redirect(EditUrl("etmode", "1", "AdminSetting"), True)
Else
Response.Redirect(EditUrl("etmode", "0", "AdminSetting"), True)
End If
End If
End If
If EditTemplateMode Then
Response.Redirect(EditUrl("TemId", objInfo.SettingName.ToString, "AdminSetting", "etmode=1"), True)
Else
Response.Redirect(EditUrl("TemId", objInfo.SettingName.ToString, "AdminSetting", "etmode=0"), True)
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub cmdAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdAdd.Click
Try
If EditTemplateMode Then
Response.Redirect(EditUrl("TemId", "0", "AdminSetting", "etmode=1"), True)
Else
Response.Redirect(EditUrl("TemId", "0", "AdminSetting", "etmode=0"), True)
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub selectlang_AfterChange(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs, ByVal PreviousEditLang As String) Handles selectlang.AfterChange
Select Case e.CommandName
Case "Change"
ShowTreeMenu()
populateEdit()
End Select
End Sub
Private Sub selectlang_BeforeChange(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs, ByVal NewEditLang As String) Handles selectlang.BeforeChange
Select Case e.CommandName
Case "Change"
'Dim objInfo As New NB_Store_SettingsTextInfo
'objInfo = updateSettings()
'If TemID = "0" Then
' 'new category created, so reset the url
' If EditTemplateMode Then
' Response.Redirect(EditUrl("TemID", objInfo.SettingName, "AdminSetting", "etmode=1"), True)
' Else
' Response.Redirect(EditUrl("TemID", objInfo.SettingName, "AdminSetting", "etmode=0"), True)
' End If
'End If
End Select
End Sub
Private Sub chkTextBoxEdit_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkTextBoxEdit.CheckedChanged
Try
SetStoreSetting(PortalId, "textboxedit.flag", chkTextBoxEdit.Checked.ToString, "None", False)
If EditTemplateMode Then
Response.Redirect(EditUrl("TemID", TemID, "AdminSetting", "etmode=1"), True)
Else
Response.Redirect(EditUrl("TemID", TemID, "AdminSetting", "etmode=0"), True)
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub chkUseFileSystem_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkUseFileSystem.CheckedChanged
Try
SetStoreSetting(PortalId, "filesystemtemplates.flag", chkUseFileSystem.Checked.ToString, "None", False)
If chkUseFileSystem.Checked Then
'filesystem turned on, so take DB and update the setting to the filesystem
Dim objInfo As NB_Store_SettingsTextInfo
objInfo = updateSettings()
If Not objInfo Is Nothing Then
selectlang.EditedLang = selectlang.SelectedLang
End If
End If
If EditTemplateMode Then
Response.Redirect(EditUrl("TemID", TemID, "AdminSetting", "etmode=1"), True)
Else
Response.Redirect(EditUrl("TemID", TemID, "AdminSetting", "etmode=0"), True)
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
#End Region
#Region "Update/View methods"
Private Function updateSettings() As NB_Store_SettingsTextInfo
Dim objCtrl As New SettingsController
Dim objInfo As New NB_Store_SettingsTextInfo
If EditTemplateMode Then
objInfo = objCtrl.GetSettingsTextNotCached(PortalId, TemID, selectlang.SelectedLang)
Else
objInfo = objCtrl.GetSettingObjNotCached(PortalId, TemID, selectlang.SelectedLang)
End If
If objInfo Is Nothing Then
objInfo = New NB_Store_SettingsTextInfo
End If
objInfo.Lang = selectlang.SelectedLang
objInfo.PortalID = PortalId
objInfo.SettingName = txtTemplName.Text
If EditTemplateMode Then
If txtMessage.Visible Then
objInfo.SettingText = System.Web.HttpUtility.HtmlEncode(txtMessage.Text)
Else
objInfo.SettingText = CType(txtEditor, DotNetNuke.UI.UserControls.TextEditor).Text
End If
Else
If txtMessage.Visible Then
objInfo.SettingValue = txtMessage.Text
End If
If rblSettingValue.Visible Then
objInfo.SettingValue = rblSettingValue.SelectedValue
End If
If ddlTabs.Visible Then
objInfo.SettingValue = ddlTabs.SelectedValue
End If
End If
objInfo.GroupRef = ddlGroups.SelectedValue
If rblCtrlType.Visible Then
objInfo.CtrlType = rblCtrlType.SelectedValue
End If
objInfo.HostOnly = chkHostOnly.Checked
If EditTemplateMode Then
objCtrl.UpdateObjSettingsText(objInfo)
Else
objCtrl.UpdateObjSettingObj(objInfo)
End If
If Not objInfo Is Nothing Then
UpdateLog(UserId, Me.ControlName & " - " & System.Reflection.MethodBase.GetCurrentMethod.Name & " - " & DotNetNuke.Common.Utilities.XmlUtils.Serialize(objInfo))
End If
removeStoreTemplateCache(PortalId)
removeLangCache(PortalId, "nbstoreadminsettingtreemenu" & UserId.ToString)
removeLangCache(PortalId, "nbstoreadmintemplatetreemenu" & UserId.ToString)
Return objInfo
End Function
Private Sub populateEdit()
Dim objCtrl As New SettingsController
Dim li As ListItem
Dim objInfo As NB_Store_SettingsTextInfo
pnlEdit.Visible = True
selectlang.DisplayNoLang = True
If Page.IsPostBack Then
selectlang.Refresh()
End If
txtMessage.Visible = False
rblSettingValue.Visible = False
txtEditor.Visible = False
chkTextBoxEdit.Visible = False
chkUseFileSystem.Visible = False
ddlTabs.Visible = False
If EditTemplateMode Then
rblCtrlType.Visible = False
End If
PopulateGroupDropdownlist(ddlGroups)
If EditTemplateMode Then
objInfo = objCtrl.GetSettingsTextNotCached(PortalId, TemID, selectlang.SelectedLang)
Else
objInfo = objCtrl.GetSettingObjNotCached(PortalId, TemID, selectlang.SelectedLang)
End If
If Not objInfo Is Nothing Then
If objInfo.GroupRef Is Nothing Then objInfo.GroupRef = ""
If Not ddlGroups.Items.FindByValue(objInfo.GroupRef) Is Nothing Then
ddlGroups.ClearSelection()
ddlGroups.Items.FindByValue(objInfo.GroupRef).Selected = True
End If
txtHelp.Enabled = False
If EditTemplateMode Then
'template edit only
Dim blnTextBox As Boolean
blnTextBox = GetStoreSettingBoolean(PortalId, "textboxedit.flag", "None")
chkTextBoxEdit.Visible = True
chkTextBoxEdit.Checked = blnTextBox
chkUseFileSystem.Visible = True
If GetStoreSettingBoolean(PortalId, "debug.mode", "None") Then
chkUseFileSystem.Enabled = True
chkUseFileSystem.Checked = GetStoreSettingBoolean(PortalId, "filesystemtemplates.flag", "None")
Else
chkUseFileSystem.Enabled = False
chkUseFileSystem.Checked = False
End If
If blnTextBox Or (GetStoreSettingBoolean(PortalId, "filesystemtemplates.flag", "None") And GetStoreSettingBoolean(PortalId, "debug.mode", "None")) Then
txtEditor.Visible = False
txtMessage.Visible = True
txtMessage.TextMode = TextBoxMode.MultiLine
txtMessage.Height = 400
txtMessage.Wrap = False
txtMessage.Text = System.Web.HttpUtility.HtmlDecode(objInfo.SettingText)
Else
txtEditor.Visible = True
txtMessage.Visible = False
CType(txtEditor, DotNetNuke.UI.UserControls.TextEditor).Text = objInfo.SettingText
End If
If GetStoreSettingBoolean(PortalId, "filesystemtemplates.flag", "None") And GetStoreSettingBoolean(PortalId, "debug.mode", "None") Then
txtEditor.Visible = False
txtMessage.Enabled = False
End If
Else
'setting edit
If objInfo.CtrlType = "" Then
rblCtrlType.Visible = True
txtMessage.Visible = True
txtMessage.Visible = True
txtMessage.MaxLength = 2000
txtMessage.TextMode = TextBoxMode.MultiLine
txtMessage.Height = 400
txtMessage.Wrap = False
txtMessage.Text = objInfo.SettingValue
Else
rblCtrlType.Visible = False
Select Case objInfo.CtrlType.ToLower
Case "textbox"
txtMessage.Visible = True
txtMessage.MaxLength = 2000
txtMessage.TextMode = TextBoxMode.SingleLine
txtMessage.Text = objInfo.SettingValue
Case "boolean"
rblSettingValue.Visible = True
If rblSettingValue.Items.Count < 2 Then
li = New ListItem
li.Value = "1"
li.Text = Localization.GetString("True", LocalResourceFile)
rblSettingValue.Items.Add(li)
li = New ListItem
li.Value = "0"
li.Text = Localization.GetString("False", LocalResourceFile)
rblSettingValue.Items.Add(li)
End If
Try
If CBool(objInfo.SettingValue) Then
rblSettingValue.SelectedValue = "1"
Else
rblSettingValue.SelectedValue = "0"
End If
Catch ex As Exception
rblSettingValue.SelectedValue = "0"
End Try
Case "websitetab"
populateTabsList(ddlTabs, PortalSettings, "")
If Not ddlTabs.Items.FindByValue(objInfo.SettingValue) Is Nothing Then
ddlTabs.ClearSelection()
ddlTabs.Items.FindByValue(objInfo.SettingValue).Selected = True
End If
ddlTabs.Visible = True
Case Else
txtMessage.Visible = True
txtMessage.MaxLength = 2000
txtMessage.TextMode = TextBoxMode.MultiLine
txtMessage.Height = 400
txtMessage.Wrap = False
txtMessage.Text = objInfo.SettingValue
End Select
End If
End If
txtTemplName.Text = objInfo.SettingName
chkHostOnly.Checked = objInfo.HostOnly
txtHelp.Text = Localization.GetString(objInfo.SettingName, LocalResourceFile)
If UserInfo.IsSuperUser Or UserInfo.IsInRole("Administrator") Then
cmdAdd.Visible = True
Else
cmdAdd.Visible = False
End If
If (UserInfo.IsSuperUser Or UserInfo.IsInRole("Administrators")) Then
chkHostOnly.Enabled = True
Else
chkHostOnly.Enabled = False
If objInfo.HostOnly Then
txtMessage.Enabled = False
txtTemplName.Enabled = False
cmdDelete.Visible = False
cmdUpdate.Visible = False
End If
End If
End If
End Sub
#End Region
#Region "GroupList"
Private Sub PopulateGroupDropdownlist(ByRef ddlGroups As DropDownList)
Dim strXML As String = ""
Dim xmlDoc As New XmlDataDocument
If EditTemplateMode Then
strXML = GetStoreSetting(PortalId, "admintemplates.groups", GetCurrentCulture)
Else
strXML = GetStoreSetting(PortalId, "adminsettings.groups", GetCurrentCulture)
End If
Try
xmlDoc.LoadXml(strXML)
Catch ex As Exception
ddlGroups.Items.Add("ERROR - Invalid xml setting")
Exit Sub
End Try
BuildGroupList(ddlGroups, xmlDoc, "root", "")
End Sub
Private Sub BuildGroupList(ByRef ddlGroups As DropDownList, ByVal xmlDoc As XmlDataDocument, ByVal xPath As String, ByVal LevelIndent As String)
Dim xmlNodList As XmlNodeList
Dim li As ListItem
xmlNodList = xmlDoc.SelectSingleNode(xPath).ChildNodes()
For Each xmlNod As XmlNode In xmlNodList
li = New ListItem
li.Text = LevelIndent & xmlNod.Attributes("text").InnerText
li.Value = xPath & "/" & xmlNod.Name
ddlGroups.Items.Add(li)
BuildGroupList(ddlGroups, xmlDoc, xPath & "/" & xmlNod.Name, LevelIndent & ".")
Next
End Sub
#End Region
#Region "TreeView"
Private Sub ShowTreeMenu()
If EditTemplateMode Then
ShowTreeMenu("nbstoreadmintemplatetreemenu" & UserId.ToString)
Else
ShowTreeMenu("nbstoreadminsettingtreemenu" & UserId.ToString)
End If
End Sub
Private Sub ShowTreeMenu(ByVal CacheName As String)
Dim objCtrl As New SettingsController
Dim aryList As ArrayList
Dim strHtml As String = ""
Dim DebugMode As Boolean = GetStoreSettingBoolean(PortalId, "debug.mode", "None")
Dim colMenuList As New Collection
If getLangCache(PortalId, CacheName, GetCurrentCulture) Is Nothing Or DebugMode Then
Dim strXML As String = ""
Dim xmlDoc As New XmlDataDocument
Dim blnErr As Boolean = False
If EditTemplateMode Then
strXML = GetStoreSetting(PortalId, "admintemplates.groups", GetCurrentCulture)
Else
strXML = GetStoreSetting(PortalId, "adminsettings.groups", GetCurrentCulture)
End If
Try
xmlDoc.LoadXml(strXML)
Catch ex As Exception
phTreeMenu.Controls.Add(New LiteralControl("Invalid xml setting - ""adminsettings.groups"" "))
blnErr = True
End Try
Dim hFlagList As Hashtable
If EditTemplateMode Then
aryList = objCtrl.GetSettingsTexts(PortalId, "None", (UserInfo.IsSuperUser Or UserInfo.IsInRole("Administrators")), "")
hFlagList = BuildFlags("nbstoreadmintemplateflaglist" & UserId.ToString, aryList, TemID)
Else
aryList = objCtrl.GetSettingListObj(PortalId, "None", (UserInfo.IsSuperUser Or UserInfo.IsInRole("Administrators")), "")
hFlagList = BuildFlags("nbstoreadminsettingflaglist" & UserId.ToString, aryList, TemID)
End If
For Each objInfo As NB_Store_SettingsTextInfo In aryList
colMenuList.Add("<div class=""NBright_SettingMenuListItem"">" & getSettingLink(objInfo, hFlagList) & "</div>")
Next
If Not blnErr Then
strHtml = BuildTreeMenu(xmlDoc, aryList, "root", hFlagList)
End If
setLangCache(PortalId, CacheName, GetCurrentCulture, strHtml)
If EditTemplateMode Then
setLangCache(PortalId, "nbstoreadmintemplatelistmenu" & UserId.ToString, GetCurrentCulture, colMenuList)
Else
setLangCache(PortalId, "nbstoreadminsettinglistmenu" & UserId.ToString, GetCurrentCulture, colMenuList)
End If
Else
strHtml = getLangCache(PortalId, CacheName, GetCurrentCulture).ToString
If EditTemplateMode Then
If Not getLangCache(PortalId, "nbstoreadmintemplatelistmenu" & UserId.ToString, GetCurrentCulture) Is Nothing Then
colMenuList = getLangCache(PortalId, "nbstoreadmintemplatelistmenu" & UserId.ToString, GetCurrentCulture)
End If
Else
If Not getLangCache(PortalId, "nbstoreadminsettinglistmenu" & UserId.ToString, GetCurrentCulture) Is Nothing Then
colMenuList = getLangCache(PortalId, "nbstoreadminsettinglistmenu" & UserId.ToString, GetCurrentCulture)
End If
End If
End If
phTreeMenu.Controls.Add(New LiteralControl(strHtml))
'display listmenu if no edit
If pnlEdit.Visible Then
dlListMenu.Visible = False
Else
dlListMenu.DataSource = colMenuList
dlListMenu.DataBind()
End If
End Sub
Private Function BuildTreeMenu(ByVal xmlDoc As XmlDataDocument, ByRef aryList As ArrayList, ByVal xPath As String, ByVal hFlagList As Hashtable) As String
Dim strHeader As String = ""
Dim strFooter As String = "</ul>"
Dim xmlNodList As XmlNodeList
Dim htmlText As String = ""
If xPath = "root" Then
strHeader &= "<ul id=""AdminTreeMenu"" class=""NBright_TreeView"">"
Else
strHeader &= "<ul>"
End If
xmlNodList = xmlDoc.SelectSingleNode(xPath).ChildNodes()
For Each xmlNod As XmlNode In xmlNodList
htmlText &= "<li>"
htmlText &= "<font class=""NBright_AdminTree"">" & xmlNod.Attributes("text").InnerText & "</font>"
htmlText &= BuildAdminSettingLink(aryList, xPath & "/" & xmlNod.Name, hFlagList)
htmlText &= BuildTreeMenu(xmlDoc, aryList, xPath & "/" & xmlNod.Name, hFlagList)
htmlText &= "</li>"
Next
If xPath = "root" Then
If aryList.Count > 0 Then
htmlText &= "<li>"
htmlText &= "<font class=""NBright_AdminTree"">Unknown</font>"
htmlText &= BuildAdminSettingLink(aryList, "", hFlagList)
htmlText &= "</li>"
End If
End If
If htmlText <> "" Then
htmlText = strHeader & htmlText & strFooter
End If
Return htmlText
End Function
Private Function BuildFlags(ByVal CacheName As String, ByVal aryList As ArrayList, Optional ByVal SettingName As String = "") As Hashtable
Dim hFlagList As New Hashtable
Dim objCtrl As New SettingsController
Dim aryLangList As ArrayList
Dim strHtml As String = ""
If SettingName <> "" And Not getLangCache(PortalId, CacheName, GetCurrentCulture) Is Nothing Then
hFlagList = getLangCache(PortalId, CacheName, GetCurrentCulture)
If hFlagList.ContainsKey(SettingName) Then
hFlagList.Remove(SettingName)
End If
If EditTemplateMode Then
aryLangList = objCtrl.GetSettingsTexts(PortalId, "", True, SettingName)
Else
aryLangList = objCtrl.GetSettingListObj(PortalId, "", True, SettingName)
End If
strHtml = " "
For Each itemInfo2 As NB_Store_SettingsTextInfo In aryLangList
If itemInfo2.Lang.Trim <> "None" Then
strHtml &= "<img src=""" & DotNetNuke.Common.ResolveUrl("~/images/flags/" & itemInfo2.Lang.Trim & ".gif") & """ height=""10"" width=""15"" border=""0"" />"
End If
Next
hFlagList.Add(SettingName, strHtml)
Else
If getLangCache(PortalId, CacheName, GetCurrentCulture) Is Nothing Then
For Each itemInfo As NB_Store_SettingsTextInfo In aryList
If EditTemplateMode Then
aryLangList = objCtrl.GetSettingsTexts(PortalId, "", True, itemInfo.SettingName)
Else
aryLangList = objCtrl.GetSettingListObj(PortalId, "", True, itemInfo.SettingName)
End If
strHtml = " "
For Each itemInfo2 As NB_Store_SettingsTextInfo In aryLangList
If itemInfo2.Lang.Trim <> "None" Then
strHtml &= "<img src=""" & DotNetNuke.Common.ResolveUrl("~/images/flags/" & itemInfo2.Lang.Trim & ".gif") & """ height=""10"" width=""15"" border=""0"" />"
End If
Next
hFlagList.Add(itemInfo.SettingName, strHtml)
Next
setLangCache(PortalId, CacheName, GetCurrentCulture, hFlagList)
Else
hFlagList = getLangCache(PortalId, CacheName, GetCurrentCulture)
End If
End If
Return hFlagList
End Function
Private Function BuildAdminSettingLink(ByRef aryList As ArrayList, ByVal GroupName As String, ByVal hFlagList As Hashtable) As String
Dim itemInfo As NB_Store_SettingsTextInfo
Dim strHtmlText As String
Dim aryRemove As New ArrayList
strHtmlText = "<ul>"
For Each itemInfo In aryList
If itemInfo.GroupRef Is Nothing Then itemInfo.GroupRef = ""
If itemInfo.GroupRef = GroupName Or GroupName = "" Then
strHtmlText &= "<li>"
strHtmlText &= getSettingLink(itemInfo, hFlagList)
aryRemove.Add(itemInfo)
strHtmlText &= "</li>"
End If
Next
strHtmlText &= "</ul>"
'remove allocated settings
For Each itemInfo In aryRemove
aryList.Remove(itemInfo)
Next
Return strHtmlText
End Function
Private Function getSettingLink(ByVal itemInfo As NB_Store_SettingsTextInfo, ByVal hFlagList As Hashtable) As String
Dim strHtmlLink As String = ""
Dim strHtmlText As String = ""
If EditTemplateMode Then
strHtmlLink = EditUrl("TemID", itemInfo.SettingName, "AdminSetting", "etmode=1")
Else
strHtmlLink = EditUrl("TemID", itemInfo.SettingName, "AdminSetting", "etmode=0")
End If
strHtmlText &= "<a class=""NBright_AdminTreeSetting"" href=""" & strHtmlLink & """ >" & itemInfo.SettingName & "</a>" & hFlagList(itemInfo.SettingName)
If itemInfo.HostOnly Then
strHtmlText &= "<img src=""" & Me.ResolveUrl("img/bullet_key.png") & """ border=""0"" />"
Else
strHtmlText &= "<img src=""" & Me.ResolveUrl("img/bullet_wrench.png") & """ border=""0"" />"
End If
Return strHtmlText
End Function
#End Region
End Class
End Namespace