forked from ventrian/Simple-Gallery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SearchOptions.ascx.vb
executable file
·145 lines (100 loc) · 5.79 KB
/
SearchOptions.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
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Entities.Tabs
Imports DotNetNuke.Security
Imports DotNetNuke.Security.Permissions
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.Localization
Imports Ventrian.SimpleGallery.Common
Imports Ventrian.SimpleGallery.Entities
Namespace Ventrian.SimpleGallery
Partial Public Class SearchOptions
Inherits ModuleSettingsBase
#Region " Private Methods "
Private Sub BindModules()
Dim objDesktopModuleInfo As DesktopModuleInfo = DesktopModuleController.GetDesktopModuleByModuleName("SimpleGallery", PortalId)
If Not (objDesktopModuleInfo Is Nothing) Then
Dim objTabController As New TabController()
Dim objTabs As TabCollection = objTabController.GetTabsByPortal(PortalId)
For Each objTab As TabInfo In objTabs.Values
If Not (objTab Is Nothing) Then
If (objTab.IsDeleted = False) Then
Dim objModules As New ModuleController
For Each pair As KeyValuePair(Of Integer, ModuleInfo) In objModules.GetTabModules(objTab.TabID)
Dim objModule As ModuleInfo = pair.Value
If (objModule.IsDeleted = False) Then
If (objModule.DesktopModuleID = objDesktopModuleInfo.DesktopModuleID) Then
If ModulePermissionController.CanEditModuleContent(objModule) = True And objModule.IsDeleted = False Then
Dim strPath As String = objTab.TabName
Dim objTabSelected As TabInfo = objTab
While objTabSelected.ParentId <> Null.NullInteger
objTabSelected = objTabController.GetTab(objTabSelected.ParentId, objTab.PortalID, False)
If (objTabSelected Is Nothing) Then
Exit While
End If
strPath = objTabSelected.TabName & " -> " & strPath
End While
Dim objListItem As New ListItem
objListItem.Value = objModule.TabID.ToString() & "-" & objModule.ModuleID.ToString()
objListItem.Text = strPath & " -> " & objModule.ModuleTitle
drpModuleID.Items.Add(objListItem)
End If
End If
End If
Next
End If
End If
Next
End If
End Sub
Private Sub BindSettings()
If (Settings.Contains(Constants.SETTING_SEARCH_MODULE_ID) And Settings.Contains(Constants.SETTING_SEARCH_TAB_ID)) Then
If Not (drpModuleID.Items.FindByValue(Settings(Constants.SETTING_SEARCH_TAB_ID).ToString() & "-" & Settings(Constants.SETTING_SEARCH_MODULE_ID).ToString()) Is Nothing) Then
drpModuleID.SelectedValue = Settings(Constants.SETTING_SEARCH_TAB_ID).ToString() & "-" & Settings(Constants.SETTING_SEARCH_MODULE_ID).ToString()
End If
End If
If (Settings.Contains(Constants.SETTING_SEARCH_TEMPLATE)) Then
txtSearchTemplate.Text = Settings(Constants.SETTING_SEARCH_TEMPLATE).ToString()
Else
txtSearchTemplate.Text = Constants.DEFAULT_SEARCH_TEMPLATE
End If
End Sub
Private Sub SaveSettings()
Dim objModuleController As New ModuleController
If (drpModuleID.Items.Count > 0) Then
Dim values As String() = drpModuleID.SelectedValue.Split(Convert.ToChar("-"))
If (values.Length = 2) Then
objModuleController.UpdateTabModuleSetting(Me.TabModuleId, Constants.SETTING_SEARCH_TAB_ID, values(0))
objModuleController.UpdateTabModuleSetting(Me.TabModuleId, Constants.SETTING_SEARCH_MODULE_ID, values(1))
Dim objModule As ModuleInfo = objModuleController.GetModule(Convert.ToInt32(values(1)), Convert.ToInt32(values(0)))
If Not (objModule Is Nothing) Then
objModuleController.UpdateTabModuleSetting(Me.TabModuleId, Constants.SETTING_SEARCH_TAB_MODULE_ID, objModule.TabModuleID.ToString())
End If
End If
End If
objModuleController.UpdateTabModuleSetting(Me.TabModuleId, Constants.SETTING_SEARCH_TEMPLATE, txtSearchTemplate.Text)
End Sub
#End Region
#Region " Base Method Implementations "
Public Overrides Sub LoadSettings()
Try
If (Page.IsPostBack = False) Then
BindModules()
BindSettings()
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Public Overrides Sub UpdateSettings()
Try
If (Page.IsValid) Then
SaveSettings()
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
#End Region
End Class
End Namespace