This repository has been archived by the owner on Dec 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
ManageAggregator.ascx.vb
663 lines (533 loc) · 27.4 KB
/
ManageAggregator.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
Option Strict On
Option Explicit On
Imports DotNetNuke
Imports DotNetNuke.Common
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Entities.Portals
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.Localization
Imports System.Collections.Generic
Imports DotNetNuke.Security.Permissions
Namespace DNNStuff.Aggregator
Partial Class ManageAggregator
Inherits Entities.Modules.PortalModuleBase
' other
Private _numberOfTabs As Integer = 0
Private _numberOfModules As Integer = 0
Private _numberOfTargets As Integer = 0
Private _aggregatorId As Integer = -1
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
MyBase.HelpURL = "http://www.dnnstuff.com/"
End Sub
#End Region
#Region " Page Level"
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
DNNUtilities.InjectCSS(Me.Page, ResolveUrl("Resources/Support/edit.css"))
Page.ClientScript.RegisterClientScriptInclude(Me.GetType, "yeti", ResolveUrl("resources/support/yetii-min.js"))
cmdAddAllModules.Attributes.Add("onclick", _
String.Format("return confirm('{0}');", Localization.GetString("ConfirmAddAllModules", LocalResourceFile)))
' Obtain PortalSettings from Current Context
Dim _portalSettings As PortalSettings = CType(HttpContext.Current.Items("PortalSettings"), PortalSettings)
If Page.IsPostBack = False Then
LoadSettings()
BindTabGrid()
BindTargetGrid(False)
End If
' Load custom settings (if any)
LoadAggregatorCustomProperties(cpvMain)
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
If Page.IsValid Then
UpdateSettings()
ReturnToPage()
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
ReturnToPage()
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub ReturnToPage()
Entities.Modules.ModuleController.SynchronizeModule(ModuleId)
' clear the tab cache
DataCache.ClearModuleCache(TabId)
' Redirect back to the portal home page
Response.Redirect(NavigateURL(), True)
End Sub
#End Region
#Region " Targets"
Private Sub BindTargetGrid(ByVal InsertRow As Boolean)
Localization.LocalizeDataGrid(grdTargets, Me.LocalResourceFile)
Dim ctrl As New AggregatorController
Dim dr As IDataReader = ctrl.GetTargets(ModuleId)
Dim ds As DataSet
ds = ConvertDataReaderToDataSet(dr)
dr.Close()
' save number of modules
_numberOfTargets = ds.Tables(0).Rows.Count
' inserting a new field
If InsertRow Then
Dim row As DataRow
row = ds.Tables(0).NewRow()
row("AggregatorTargetId") = "-1"
row("TargetModuleId") = "-1"
ds.Tables(0).Rows.InsertAt(row, 0)
grdTargets.EditItemIndex = 0
End If
grdTargets.DataSource = ds
grdTargets.DataBind()
' hide if nothing and not inserting
grdTargets.Visible = Not (_numberOfTargets = 0 And Not InsertRow)
End Sub
Public Sub grdTargets_CancelEdit(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
Try
grdTargets.EditItemIndex = -1
BindTargetGrid(False)
Catch exc As Exception 'Target failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Public Sub grdTargets_Edit(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
Try
grdTargets.EditItemIndex = e.Item.ItemIndex
grdTargets.SelectedIndex = -1
BindTargetGrid(False)
Catch exc As Exception 'Target failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Sub grdTargets_Item_Bound(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
Try
If (e.Item.ItemType = ListItemType.EditItem) Then
Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView)
Dim cboTarget As WebControls.DropDownList
cboTarget = CType(e.Item.FindControl("cboTarget"), WebControls.DropDownList)
BindAvailableTargetList(cboTarget, False, Convert.ToInt32(drv("AggregatorTargetId")))
Dim item As ListItem = cboTarget.Items.FindByValue(drv("TargetModuleId").ToString)
If Not item Is Nothing Then item.Selected = True
End If
Catch exc As Exception 'Target failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub BindAvailableTargetList(ByVal o As DropDownList, ByVal showAllTargets As Boolean, ByVal AggregatorTargetId As Integer)
Dim dr As IDataReader
' targets
dr = DataProvider.Instance().GetAvailableTargets(TabId, ModuleId, AggregatorTargetId)
With o
.DataSource = dr
.DataValueField = "ModuleId"
.DataTextField = "FullModuleTitle"
.DataBind()
End With
End Sub
Public Sub grdTargets_Update(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
Try
Dim cboTarget As DropDownList = CType(e.Item.FindControl("cboTarget"), WebControls.DropDownList)
If cboTarget.SelectedValue <> "" Then
Dim ctrl As New AggregatorController
Dim ati As New AggregatorTargetInfo
If Integer.Parse(Convert.ToString(grdTargets.DataKeys(e.Item.ItemIndex))) = -1 Then
' insert target
With ati
.ModuleId = ModuleId
.AggregatorTargetId = -1
.TargetModuleId = Convert.ToInt32(cboTarget.SelectedItem.Value)
End With
Else
' update module
With ati
.ModuleId = ModuleId
.AggregatorTargetId = Convert.ToInt32(grdTargets.DataKeys(e.Item.ItemIndex).ToString)
.TargetModuleId = Convert.ToInt32(cboTarget.SelectedItem.Value)
End With
End If
ctrl.UpdateTarget(ati)
grdTargets.EditItemIndex = -1
BindTargetGrid(False)
Else
grdTargets.EditItemIndex = -1
BindTargetGrid(False)
End If
Catch exc As Exception 'Target failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Public Sub grdTargets_Delete(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
Try
Dim ctrl As New AggregatorController
ctrl.DeleteTarget(Integer.Parse(Convert.ToString(grdTargets.DataKeys(e.Item.ItemIndex))))
grdTargets.EditItemIndex = -1
BindTargetGrid(False)
Catch exc As Exception 'Target failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub cmdAddTarget_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAddTarget.Click
Try
BindTargetGrid(True)
Catch exc As Exception 'Target failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub grdTargets_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles grdTargets.ItemCreated
Try
If e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.Item Then
Dim cmdDeleteTarget As Control = e.Item.FindControl("cmdDeleteTarget")
If Not cmdDeleteTarget Is Nothing Then
CType(cmdDeleteTarget, ImageButton).Attributes.Add("onClick", "javascript: return confirm('Are You Sure You Wish To Delete This Target ?')")
End If
End If
Catch exc As Exception 'Target failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
#End Region
#Region " Style Settings"
Private Sub UpdateSettings()
Dim ms As New ModuleSettings(ModuleId)
With ms
.HideTitles = chkHideTitles.Checked
.TabSkin = cboTabSkin.SelectedItem.Value
.TabTemplate = cboTabTemplate.SelectedItem.Value
.ShowPrevNext = chkShowPrevNext.Checked
.HideSingleTab = chkHideSingleTab.Checked
.ActiveHover = chkActiveHover.Checked
Int32.TryParse(txtActiveHoverDelay.Text, .ActiveHoverDelay)
.HideTabs = chkHideTabs.Checked
Int32.TryParse(txtDefaultTab.Text, .DefaultTab)
.RememberLastOpenTab = chkRememberLastOpenTab.Checked
.Width = txtWidth.Text
.Height = txtHeight.Text
' rss
.RSSUrl = txtRSSUrl.Text
Int32.TryParse(txtRSSMaxItems.Text, .RSSMaxItems)
Int32.TryParse(txtRSSCacheTime.Text, .RSSCacheTime)
.RSSTabCaption = txtRSSTabCaption.Text
.RSSUsername = txtRSSUsername.Text
.RSSPassword = txtRSSPassword.Text
End With
ms.UpdateSettings()
Dim objModules As New DotNetNuke.Entities.Modules.ModuleController
objModules.UpdateTabModuleOrder(TabId)
' update properties
cpvMain.SetProperties()
For Each prop As CustomProperty In cpvMain.Properties.Values
DataProvider.Instance().UpdateProperties(ModuleId, -1, cboTabSkin.SelectedValue, cboTabTemplate.SelectedValue, prop.Name, prop.Value)
Next
' clear rss cache
DataCache.RemoveCache("RSS_" & ModuleId.ToString)
End Sub
Private Sub LoadSettings()
Dim ms As New ModuleSettings(ModuleId)
Dim item As ListItem
' hide titles
chkHideTitles.Checked = ms.HideTitles
' theme/skin
BindSkinFolder(cboTabSkin)
item = cboTabSkin.Items.FindByValue(ms.TabSkin)
If Not item Is Nothing Then item.Selected = True
' tab style
BindTemplateFolder(cboTabTemplate, cboTabSkin.SelectedItem.Text)
item = cboTabTemplate.Items.FindByValue(ms.TabTemplate)
If Not item Is Nothing Then item.Selected = True
' prev next
chkShowPrevNext.Checked = ms.ShowPrevNext
' hide single tab
chkHideSingleTab.Checked = ms.HideSingleTab
' active hover
chkActiveHover.Checked = ms.ActiveHover
txtActiveHoverDelay.Text = ms.ActiveHoverDelay.ToString
' hide tabs
chkHideTabs.Checked = ms.HideTabs
' default tab
txtDefaultTab.Text = ms.DefaultTab.ToString
chkRememberLastOpenTab.Checked = ms.RememberLastOpenTab
' height/width
txtHeight.Text = ms.Height
txtWidth.Text = ms.Width
' rss
txtRSSUrl.Text = ms.RSSUrl
txtRSSMaxItems.Text = ms.RSSMaxItems.ToString
txtRSSCacheTime.Text = ms.RSSCacheTime.ToString
txtRSSTabCaption.Text = ms.RSSTabCaption
txtRSSUsername.Text = ms.RSSUsername
txtRSSPassword.Text = ms.RSSPassword
End Sub
Private Sub BindSkinFolder(ByVal o As ListControl)
Dim skinFolder As New IO.DirectoryInfo(Server.MapPath(ResolveUrl("Skins")))
o.Items.Clear()
For Each folder As IO.DirectoryInfo In skinFolder.GetDirectories()
If folder.GetDirectories.Length > 0 Then
o.Items.Add(folder.Name)
End If
Next
End Sub
Private Sub BindTemplateFolder(ByVal o As ListControl, ByVal skinName As String)
Dim skinFolder As New IO.DirectoryInfo(IO.Path.Combine(Server.MapPath(ResolveUrl("Skins")), skinName))
o.Items.Clear()
For Each folder As IO.DirectoryInfo In skinFolder.GetDirectories()
If Not folder.Name.StartsWith("_") Then o.Items.Add(folder.Name)
Next
End Sub
Private Sub cboTabSkin_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboTabSkin.SelectedIndexChanged
BindTemplateFolder(cboTabTemplate, cboTabSkin.SelectedItem.Text)
End Sub
#End Region
#Region " Tabs"
Private Sub BindTabGrid()
Dim ctrl As New AggregatorController
Dim drTabs As IDataReader = ctrl.ListAggregator(ModuleId)
Try
dlTabs.DataKeyField = "AggregatorTabId"
dlTabs.DataSource = drTabs
dlTabs.DataBind()
Catch ex As Exception
ProcessModuleLoadException(Me, ex)
End Try
' hide unnecessary move buttons
Dim ib As ImageButton
For Each r As DataListItem In dlTabs.Items
If r.ItemType = ListItemType.Item Or r.ItemType = ListItemType.AlternatingItem Then
If r.ItemIndex = 0 Then
ib = CType(r.FindControl("cmdMoveTabUp"), ImageButton)
If Not ib Is Nothing Then
ib.Visible = False
End If
End If
If r.ItemIndex = dlTabs.Items.Count - 1 Then
ib = CType(r.FindControl("cmdMoveTabDown"), ImageButton)
If Not ib Is Nothing Then
ib.Visible = False
End If
End If
' hide move/up down buttons for modules
Dim moduleList As DataList
moduleList = CType(r.FindControl("dlTabModules"), DataList)
If moduleList IsNot Nothing Then
For Each m As DataListItem In moduleList.Items
If m.ItemType = ListItemType.Item Or m.ItemType = ListItemType.AlternatingItem Then
If m.ItemIndex = 0 Then
ib = CType(m.FindControl("cmdMoveModuleUp"), ImageButton)
If Not ib Is Nothing Then
ib.Visible = False
End If
End If
If m.ItemIndex = moduleList.Items.Count - 1 Then
ib = CType(m.FindControl("cmdMoveModuleDown"), ImageButton)
If Not ib Is Nothing Then
ib.Visible = False
End If
End If
End If
Next
End If
End If
Next
End Sub
Private Sub cmdAddTab_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdAddTab.Click
' add a new tab
Response.Redirect(NavigateEditTab(-1, 0))
End Sub
Private Sub cmdAddModule_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdAddModule.Click
' add a new module
Response.Redirect(EditUrl("EditModule"))
End Sub
Private Sub cmdQuickTabsAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdQuickTabsAdd.Click
' loop through lines of text and create a new empty tab for each one
Dim objAggregatorController As AggregatorController = New AggregatorController
Dim tabs As String() = System.Text.RegularExpressions.Regex.Split(txtQuickTabs.Text, "\r\n")
For Each s As String In tabs
Dim objAggregator As New AggregatorTabInfo
With objAggregator
.ModuleId = ModuleId
.AggregatorTabId = -1
.Caption = s
.Locale = "All"
.HtmlText = s & " content"
End With
objAggregator.AggregatorTabId = objAggregatorController.UpdateAggregatorTab(objAggregator)
Next
txtQuickTabs.Text = ""
' refresh tabs
LoadSettings()
BindTabGrid()
End Sub
Private Sub cmdAddAllModules_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdAddAllModules.Click
' grab all remaining candidate modules and add them to new tabs
Dim dr As IDataReader
' modules
dr = DataProvider.Instance().GetTabModules(TabId, ModuleId, False, ModuleId, PortalId)
While dr.Read
Dim objAggregatorController As AggregatorController = New AggregatorController
Dim objAggregatorModule As AggregatorModuleInfo = New AggregatorModuleInfo
With objAggregatorModule
.AggregatorTabId = -1
.AggregatorModuleId = -1
.TabModuleId = Convert.ToInt32(dr("TabModuleId"))
.Locale = "All"
.InsertBreak = False
End With
Dim tabCaption As String = System.Text.RegularExpressions.Regex.Replace(dr("FullModuleTitle").ToString, ".*>", "")
objAggregatorModule.AggregatorModuleId = objAggregatorController.UpdateAggregatorModule(objAggregatorModule, ModuleId, tabCaption)
End While
' refresh tabs
LoadSettings()
BindTabGrid()
End Sub
Public Function LinkPath(ByVal ItemIndex As Integer) As String
' returns the url to select the tab
Return NavigateURL(TabId, "", "Agg" & ModuleId & "_SelectTab=" & ItemIndex + 1)
End Function
Public Function NavigateEditTab(ByVal TabId As Integer, ByVal tabNumber As Integer) As String
Return EditUrl("AggregatorTabId", TabId.ToString, "EditTab", "TabNumber=" & tabNumber)
End Function
Private Sub dlTabs_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles dlTabs.ItemCommand
Select Case e.CommandName.ToLower
Case "edit"
Response.Redirect(NavigateEditTab(Convert.ToInt32(dlTabs.DataKeys(e.Item.ItemIndex)), e.Item.ItemIndex + 1))
Case "delete"
Dim ctrl As New AggregatorController
ctrl.DeleteAggregatorTab(Integer.Parse(Convert.ToString(dlTabs.DataKeys(e.Item.ItemIndex))))
BindTabGrid()
Case "moveup"
Dim ctrl As New AggregatorController
ctrl.UpdateTabOrder(Integer.Parse(Convert.ToString(dlTabs.DataKeys(e.Item.ItemIndex))), -1)
BindTabGrid()
Case "movedown"
Dim ctrl As New AggregatorController
ctrl.UpdateTabOrder(Integer.Parse(Convert.ToString(dlTabs.DataKeys(e.Item.ItemIndex))), 1)
BindTabGrid()
End Select
End Sub
Private Sub dlTabs_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles dlTabs.ItemCreated
Try
Dim cmdDeleteTab As Control = e.Item.FindControl("cmdDeleteTab")
If Not cmdDeleteTab Is Nothing Then
CType(cmdDeleteTab, ImageButton).Attributes.Add("onClick", "javascript: return confirm('Are You Sure You Wish To Delete This Tab ?')")
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub dlTabs_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles dlTabs.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
Dim dl As DataList = DirectCast(e.Item.FindControl("dlTabModules"), DataList)
Dim id As Integer = Convert.ToInt32(DirectCast(e.Item.DataItem, IDataRecord)("AggregatorTabId"))
Dim ctrl As New AggregatorController
Dim dr As IDataReader = ctrl.ListAggregatorModule(Convert.ToInt32(id))
dl.DataKeyField = "AggregatorModuleId"
dl.DataSource = dr
dl.DataBind()
' collapse row if no items
If dl.Items.Count = 0 Then
Dim tr As HtmlTableRow = DirectCast(e.Item.FindControl("trTabModules"), HtmlTableRow)
tr.Visible = False
End If
End If
End Sub
#End Region
#Region " Modules in Tabs"
Public Sub dlTabModules_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs)
Try
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
' add delete confirmation
Dim cmdDeleteTabModule As Control = e.Item.FindControl("cmdDeleteTabModule")
If Not cmdDeleteTabModule Is Nothing Then
CType(cmdDeleteTabModule, ImageButton).Attributes.Add("onClick", "javascript: return confirm('Are you sure you wish to remove this module from the tab ?')")
End If
' check module edit rights and enable editing if necessary
Dim ctrl As New AggregatorController
Dim ami As AggregatorModuleInfo = ctrl.GetAggregatorModule(Convert.ToInt32(Convert.ToString(DirectCast(sender, DataList).DataKeys(e.Item.ItemIndex))))
If ModulePermissionController.CanEditModuleContent(ami.ModuleInfo) Then
Dim cmdEditTabModuleSettings As Control = e.Item.FindControl("cmdEditTabModuleSettings")
If Not cmdEditTabModuleSettings Is Nothing Then
CType(cmdEditTabModuleSettings, ImageButton).Visible = True
End If
End If
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Public Sub dlTabModules_ItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs)
Dim moduleList As DataList = DirectCast(sender, DataList)
Select Case e.CommandName.ToLower
Case "edit"
Response.Redirect(EditUrl("AggregatorModuleId", DirectCast(sender, DataList).DataKeys(e.Item.ItemIndex).ToString, "EditModule"))
Case "editsettings"
Dim ReturnUrl As String = HttpContext.Current.Request.RawUrl
If ReturnUrl.IndexOf("?returnurl=") <> -1 Then
ReturnUrl = ReturnUrl.Substring(0, ReturnUrl.IndexOf("?returnurl="))
End If
ReturnUrl = HttpUtility.UrlEncode(ReturnUrl)
Dim ctrl As New AggregatorController
Dim ami As AggregatorModuleInfo = ctrl.GetAggregatorModule(Convert.ToInt32(Convert.ToString(DirectCast(sender, DataList).DataKeys(e.Item.ItemIndex))))
Response.Redirect(NavigateURL(TabId, "Module", "ModuleId=" & ami.ModuleId.ToString, "returnurl=" & ReturnUrl))
Case "delete"
Dim ctrl As New AggregatorController
ctrl.DeleteAggregatorModule(Convert.ToInt32(Convert.ToString(DirectCast(sender, DataList).DataKeys(e.Item.ItemIndex))))
BindTabGrid()
Case "moveup"
Dim ctrl As New AggregatorController
ctrl.UpdateModuleOrder(Integer.Parse(Convert.ToString(moduleList.DataKeys(e.Item.ItemIndex))), -1)
BindTabGrid()
Case "movedown"
Dim ctrl As New AggregatorController
ctrl.UpdateModuleOrder(Integer.Parse(Convert.ToString(moduleList.DataKeys(e.Item.ItemIndex))), 1)
BindTabGrid()
End Select
End Sub
#End Region
#Region " Helpers"
Public Function MaxTrim(ByVal s As String, ByVal f As String, ByVal l As Integer) As String
If s.Length > 0 Then
If s.Length > l Then Return String.Format(f, s.Substring(0, l)) Else Return String.Format(f, s)
End If
Return ""
End Function
#End Region
#Region " Custom Settings"
Public Function SettingsFilename() As String
Dim skinFolder As String = ResolveUrl(String.Format("Skins/{0}/{1}", cboTabSkin.SelectedValue, cboTabTemplate.SelectedValue))
Return IO.Path.Combine(MapPath(skinFolder), "settings.xml")
End Function
Public Sub LoadAggregatorCustomProperties(ByVal cpv As CustomPropertiesViewer)
If IO.File.Exists(SettingsFilename) Then
Dim cp As CustomProperties = CustomProperties.Load(SettingsFilename)
' load values from db
Dim values As ArrayList = CBO.FillCollection(DataProvider.Instance().GetProperties(ModuleId, -1, cboTabSkin.SelectedValue, cboTabTemplate.SelectedValue), GetType(CustomSettingsInfo))
For Each csi As CustomSettingsInfo In values
If cp.Properties.ContainsKey(csi.Name) Then
cp.Properties(csi.Name).Value = csi.Value
End If
Next
cpv.Description = cp.Description
cpv.Properties = cp.Properties
lblCustomPropertyHelp.Text = cp.Help
Exit Sub
End If
cpv.Description = ""
cpv.Properties = New Dictionary(Of String, CustomProperty)
lblCustomPropertyHelp.Text = ""
End Sub
#End Region
End Class
End Namespace