forked from ventrian/Simple-Gallery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEditTemplate.ascx.vb
executable file
·257 lines (182 loc) · 9.48 KB
/
EditTemplate.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
'
' Simple Gallery for DotNetNuke - http://www.dotnetnuke.com
' Copyright (c) 2002-2007
' by Ventrian ( [email protected] ) ( http://www.ventrian.com )
'
Imports DotNetNuke.Common
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.Localization
Imports Ventrian.SimpleGallery.Common
Imports Ventrian.SimpleGallery.Entities
Namespace Ventrian.SimpleGallery
Partial Public Class EditTemplate
Inherits SimpleGalleryBase
#Region " Private Methods "
Private Sub BindCrumbs()
Dim crumbs As New ArrayList
Dim crumbAllAlbums As New CrumbInfo
crumbAllAlbums.Caption = Localization.GetString("AllAlbums", LocalResourceFile)
crumbAllAlbums.Url = NavigateURL()
crumbs.Add(crumbAllAlbums)
Dim currentCrumb As New CrumbInfo
currentCrumb.Caption = Localization.GetString("EditTemplates", LocalResourceFile)
currentCrumb.Url = Request.Url.ToString()
crumbs.Add(currentCrumb)
rptBreadCrumbs.DataSource = crumbs
rptBreadCrumbs.DataBind()
End Sub
Private Sub BindTemplates()
For Each value As Integer In System.Enum.GetValues(GetType(TemplateType))
Dim li As New ListItem
li.Value = System.Enum.GetName(GetType(TemplateType), value)
li.Text = Localization.GetString(System.Enum.GetName(GetType(TemplateType), value), Me.LocalResourceFile)
drpTemplates.Items.Add(li)
Next
End Sub
Private Sub BindTemplate()
Dim objTemplateController As New TemplateController
Dim objTemplateInfo As TemplateInfo = objTemplateController.Get(Me.ModuleId, drpTemplates.SelectedValue)
If (objTemplateInfo Is Nothing) Then
DisplayDefault()
Else
Dim objTemplateInfoHeader As TemplateInfo = objTemplateController.Get(Me.ModuleId, drpTemplates.SelectedValue & "Header")
Dim objTemplateInfoFooter As TemplateInfo = objTemplateController.Get(Me.ModuleId, drpTemplates.SelectedValue & "Footer")
txtTemplate.Text = objTemplateInfo.Template
If (objTemplateInfoHeader Is Nothing) Then
txtTemplateHeader.Text = ""
Else
txtTemplateHeader.Text = objTemplateInfoHeader.Template
End If
If (objTemplateInfoFooter Is Nothing) Then
txtTemplateFooter.Text = ""
Else
txtTemplateFooter.Text = objTemplateInfoFooter.Template
End If
End If
End Sub
Private Sub BindTokens()
Select Case CType(System.Enum.Parse(GetType(TemplateType), drpTemplates.SelectedValue), TemplateType)
Case TemplateType.AlbumInfo
rptTemplateTokens.DataSource = System.Enum.GetValues(GetType(TemplateTokenAlbumInfo))
rptTemplateTokens.DataBind()
rptTemplateTokens.Visible = True
Case TemplateType.PhotoInfo
rptTemplateTokens.DataSource = System.Enum.GetValues(GetType(TemplateTokenPhotoInfo))
rptTemplateTokens.DataBind()
rptTemplateTokens.Visible = True
Case TemplateType.AddToCart
rptTemplateTokens.DataSource = System.Enum.GetValues(GetType(TemplateTokenAddToCartInfo))
rptTemplateTokens.DataBind()
rptTemplateTokens.Visible = True
Case TemplateType.ViewCart
rptTemplateTokens.Visible = False
End Select
End Sub
Private Sub DisplayDefault()
Select Case CType(System.Enum.Parse(GetType(TemplateType), drpTemplates.SelectedValue), TemplateType)
Case TemplateType.AddToCart
txtTemplate.Text = "AddToCart"
txtTemplateHeader.Text = ""
txtTemplateFooter.Text = ""
Case TemplateType.ViewCart
txtTemplate.Text = "ViewCart"
txtTemplateHeader.Text = ""
txtTemplateFooter.Text = ""
Case TemplateType.AlbumInfo
txtTemplate.Text = Constants.DEFAULT_TEMPLATE_ALBUM_INFO
txtTemplateHeader.Text = ""
txtTemplateFooter.Text = ""
Case TemplateType.PhotoInfo
txtTemplate.Text = Constants.DEFAULT_TEMPLATE_PHOTO_INFO
txtTemplateHeader.Text = ""
txtTemplateFooter.Text = ""
Case TemplateType.AddToCart
txtTemplate.Text = "AddToCart"
Case TemplateType.ViewCart
txtTemplate.Text = "ViewCart"
End Select
End Sub
#End Region
#Region " Protected Methods "
Protected Function GetLocalizedValue(ByVal key As String) As String
If (key = "DATECREATED" AndAlso CType(System.Enum.Parse(GetType(TemplateType), drpTemplates.SelectedValue), TemplateType) = TemplateType.AlbumInfo) Then
Return Localization.GetString("ALBUM-" & key, Me.LocalResourceFile)
Else
Return Localization.GetString(key, Me.LocalResourceFile)
End If
End Function
#End Region
#Region " Event Handlers "
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
BindCrumbs()
If (Page.IsPostBack = False) Then
BindTemplates()
BindTemplate()
BindTokens()
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
Response.Redirect(NavigateURL(Me.TabId), True)
End Sub
Private Sub cmdUpdate_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdUpdate.Click
If (Page.IsValid) Then
Dim objTemplateController As New TemplateController
Dim objTemplateInfo As TemplateInfo = objTemplateController.Get(Me.ModuleId, drpTemplates.SelectedValue)
''Body
If (objTemplateInfo Is Nothing) Then
objTemplateInfo = New TemplateInfo
objTemplateInfo.ModuleID = Me.ModuleId
objTemplateInfo.Name = drpTemplates.SelectedValue
objTemplateInfo.Template = txtTemplate.Text
objTemplateController.Add(objTemplateInfo)
Else
objTemplateInfo.Template = txtTemplate.Text
objTemplateController.Update(objTemplateInfo)
End If
Dim cacheKey As String = TabModuleId.ToString() & objTemplateInfo.Name
DotNetNuke.Common.Utilities.DataCache.RemoveCache(cacheKey)
'Header
objTemplateInfo = objTemplateController.Get(Me.ModuleId, drpTemplates.SelectedValue & "Header")
If (objTemplateInfo Is Nothing) Then
objTemplateInfo = New TemplateInfo
objTemplateInfo.ModuleID = Me.ModuleId
objTemplateInfo.Name = drpTemplates.SelectedValue & "Header"
objTemplateInfo.Template = txtTemplateHeader.Text
objTemplateController.Add(objTemplateInfo)
Else
objTemplateInfo.Template = txtTemplateHeader.Text
objTemplateController.Update(objTemplateInfo)
End If
cacheKey = TabModuleId.ToString() & objTemplateInfo.Name
DotNetNuke.Common.Utilities.DataCache.RemoveCache(cacheKey)
'Footer
objTemplateInfo = objTemplateController.Get(Me.ModuleId, drpTemplates.SelectedValue & "Footer")
If (objTemplateInfo Is Nothing) Then
objTemplateInfo = New TemplateInfo
objTemplateInfo.ModuleID = Me.ModuleId
objTemplateInfo.Name = drpTemplates.SelectedValue & "Footer"
objTemplateInfo.Template = txtTemplateFooter.Text
objTemplateController.Add(objTemplateInfo)
Else
objTemplateInfo.Template = txtTemplateFooter.Text
objTemplateController.Update(objTemplateInfo)
End If
cacheKey = TabModuleId.ToString() & objTemplateInfo.Name
DotNetNuke.Common.Utilities.DataCache.RemoveCache(cacheKey)
End If
End Sub
Private Sub drpTemplates_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles drpTemplates.SelectedIndexChanged
BindTemplate()
BindTokens()
End Sub
Private Sub cmdRestoreDefault_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdRestoreDefault.Click
DisplayDefault()
End Sub
#End Region
End Class
End Namespace