-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSettings.ascx.vb
executable file
·200 lines (149 loc) · 9.12 KB
/
Settings.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
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.FileSystem
Imports DotNetNuke.Services.Localization
Imports Ventrian.FileLinks.Common
Imports Ventrian.FileLinks.Entities
Namespace Ventrian.FileLinks
Partial Public Class Settings
Inherits ModuleSettingsBase
#Region " Private Members "
Private _linkSettings As LinkSettings
#End Region
#Region " Private Methods "
Private Sub BindCompressionType()
For Each value As Integer In System.Enum.GetValues(GetType(CompressionType))
Dim li As New ListItem
li.Value = System.Enum.GetName(GetType(CompressionType), value)
li.Text = Localization.GetString(System.Enum.GetName(GetType(CompressionType), value), Me.LocalResourceFile)
drpCompressionType.Items.Add(li)
Next
End Sub
Private Sub BindFolders()
Dim folders As ArrayList = FileSystemUtils.GetFolders(PortalId)
For Each folder As FolderInfo In folders
Dim FolderItem As New ListItem
If folder.FolderPath = Null.NullString Then
FolderItem.Text = Localization.GetString("Root", Me.LocalResourceFile)
Else
FolderItem.Text = folder.FolderPath
End If
FolderItem.Value = folder.FolderID
drpSelectFolder.Items.Add(FolderItem)
Next
End Sub
Private Sub BindSortBy()
For Each value As Integer In System.Enum.GetValues(GetType(SortType))
Dim li As New ListItem
li.Value = System.Enum.GetName(GetType(SortType), value)
li.Text = Localization.GetString(System.Enum.GetName(GetType(SortType), value) & "Sort", Me.LocalResourceFile)
drpSortBy.Items.Add(li)
Next
End Sub
Private Sub BindSortDirection()
For Each value As Integer In System.Enum.GetValues(GetType(SortDirection))
Dim li As New ListItem
li.Value = System.Enum.GetName(GetType(SortDirection), value)
li.Text = Localization.GetString(System.Enum.GetName(GetType(SortDirection), value), Me.LocalResourceFile)
drpSortDirection.Items.Add(li)
Next
End Sub
#End Region
#Region " Private Properties "
Public ReadOnly Property LinkSettings() As LinkSettings
Get
If (_linkSettings Is Nothing) Then
_linkSettings = New LinkSettings(Settings)
End If
Return _linkSettings
End Get
End Property
#End Region
#Region " Base Method Implementations "
Public Overrides Sub LoadSettings()
Try
If (Page.IsPostBack = False) Then
BindCompressionType()
BindFolders()
BindSortBy()
BindSortDirection()
If (drpSelectFolder.Items.FindByValue(LinkSettings.FolderID) IsNot Nothing) Then
drpSelectFolder.SelectedValue = LinkSettings.FolderID
End If
chkDisplayFolders.Checked = LinkSettings.DisplayFolders
chkDisplayFilesInFolders.Checked = LinkSettings.DisplayFilesInFolders
chkTrackDownloads.Checked = LinkSettings.TrackDownloads
txtExtensionFilter.Text = LinkSettings.ExtensionFilter
txtMaxFileSize.Text = LinkSettings.MaxFileSize.ToString()
txtSecureUrl.Text = LinkSettings.SecureUrl
If (drpSortBy.Items.FindByValue(LinkSettings.SortBy.ToString()) IsNot Nothing) Then
drpSortBy.SelectedValue = LinkSettings.SortBy.ToString()
End If
If (drpSortDirection.Items.FindByValue(LinkSettings.SortDirection.ToString()) IsNot Nothing) Then
drpSortDirection.SelectedValue = LinkSettings.SortDirection.ToString()
End If
chkResizeImages.Checked = LinkSettings.ResizeImages
chkRenameImages.Checked = LinkSettings.RenameImages
If Not (drpCompressionType.Items.FindByValue(LinkSettings.Compression.ToString()) Is Nothing) Then
drpCompressionType.SelectedValue = LinkSettings.Compression.ToString()
End If
txtImageWidth.Text = LinkSettings.ImageWidth.ToString()
txtImageHeight.Text = LinkSettings.ImageHeight.ToString()
txtTemplateHeader.Text = LinkSettings.TemplateHeader
txtTemplateItem.Text = LinkSettings.TemplateItem
txtTemplateSubItem.Text = LinkSettings.TemplateSubItem
txtTemplateSubEmpty.Text = LinkSettings.TemplateSubEmpty
txtTemplateFooter.Text = LinkSettings.TemplateFooter
txtTemplateEmpty.Text = LinkSettings.TemplateEmpty
chkEnableTerms.Checked = LinkSettings.TermsEnabled
txtTerms.Text = LinkSettings.TermsTemplate
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
Dim objModuleController As New ModuleController
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.FOLDER_ID, drpSelectFolder.SelectedValue)
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.DISPLAY_FOLDERS, chkDisplayFolders.Checked)
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.DISPLAY_FILES_IN_FOLDERS, chkDisplayFilesInFolders.Checked)
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.TRACK_DOWNLOADS, chkTrackDownloads.Checked)
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.EXTENSION_FILTER, txtExtensionFilter.Text)
If (Convert.ToInt32(txtMaxFileSize.Text) > 0) Then
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.MAX_FILE_SIZE, txtMaxFileSize.Text)
End If
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.SORT_BY, drpSortBy.SelectedValue)
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.SORT_DIRECTION, drpSortDirection.SelectedValue)
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.SECURE_URL, txtSecureUrl.Text)
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.RESIZE_IMAGES, chkResizeImages.Checked.ToString())
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.RENAME_IMAGES, chkRenameImages.Checked.ToString())
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.COMPRESSION, drpCompressionType.SelectedValue)
If (IsNumeric(txtImageWidth.Text)) Then
If (Convert.ToInt32(txtImageWidth.Text) > 0) Then
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.IMAGE_WIDTH, txtImageWidth.Text)
End If
End If
If (IsNumeric(txtImageHeight.Text)) Then
If (Convert.ToInt32(txtImageHeight.Text) > 0) Then
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.IMAGE_HEIGHT, txtImageHeight.Text)
End If
End If
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.TEMPLATE_HEADER, txtTemplateHeader.Text)
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.TEMPLATE_ITEM, txtTemplateItem.Text)
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.TEMPLATE_SUB_ITEM, txtTemplateSubItem.Text)
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.TEMPLATE_SUB_EMPTY, txtTemplateSubEmpty.Text)
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.TEMPLATE_FOOTER, txtTemplateFooter.Text)
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.TEMPLATE_EMPTY, txtTemplateEmpty.Text)
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.TERMS_ENABLE, chkEnableTerms.Checked.ToString())
objModuleController.UpdateModuleSetting(Me.ModuleId, Constants.TERMS_TEMPLATE, txtTerms.Text)
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
#End Region
End Class
End Namespace