-
Notifications
You must be signed in to change notification settings - Fork 4
/
SlideShow.ascx.vb
executable file
·309 lines (230 loc) · 14.7 KB
/
SlideShow.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
'
' 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.Entities.Modules
Imports DotNetNuke.Entities.Modules.Actions
Imports DotNetNuke.Entities.Tabs
Imports DotNetNuke.Security
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.Localization
Imports Ventrian.SimpleGallery.Entities
Namespace Ventrian.SimpleGallery
Partial Public Class SlideShow
Inherits SimpleGalleryBase
#Region " Private Members "
Private _itemID As Integer = Null.NullInteger
Private _albumID As Integer = Null.NullInteger
Private _searchText As String = Null.NullString
Private _tagID As Integer = Null.NullInteger
#End Region
#Region " Private Methods "
Private Sub BindBreadCrumbs()
ucGalleryMenu.AddCrumb(Localization.GetString("AllAlbums", LocalResourceFile), NavigateURL())
If (_tagID <> Null.NullInteger) Then
ucGalleryMenu.AddCrumb(Localization.GetString("Tags", LocalResourceFile), NavigateURL(Me.TabId, "", "Tags=" & TabModuleId))
Dim objTagController As New TagController
Dim objTag As TagInfo = objTagController.Get(_tagID)
If Not (objTag Is Nothing) Then
ucGalleryMenu.AddCrumb(objTag.Name, NavigateURL(Me.TabId, "", "Tag=" & objTag.NameLowered, "Tags=" & TabModuleId))
End If
End If
If (_searchText <> Null.NullString) Then
ucGalleryMenu.AddCrumb(Localization.GetString("Search", LocalResourceFile), NavigateURL(Me.TabId, "", "SearchID=" & TabModuleId))
ucGalleryMenu.AddCrumb(_searchText, NavigateURL(Me.TabId, "", "SearchID=" & TabModuleId, "SearchText=" & System.Uri.EscapeDataString(_searchText)))
End If
End Sub
Private Sub BindNav()
Dim objPhotoController As New PhotoController
Dim photoList As ArrayList
If (_tagID <> Null.NullInteger) Then
photoList = objPhotoController.List(Me.ModuleId, Null.NullInteger, True, Null.NullInteger, False, _tagID, Null.NullString, Null.NullString, Me.GallerySettings.SortBy, Me.GallerySettings.SortDirection)
Else
If (_searchText <> "") Then
photoList = objPhotoController.List(Me.ModuleId, Null.NullInteger, True, Null.NullInteger, Null.NullBoolean, Null.NullInteger, Null.NullString, _searchText, Me.GallerySettings.SortBy, Me.GallerySettings.SortDirection)
Else
photoList = objPhotoController.List(Me.ModuleId, _albumID, True, Null.NullInteger, Null.NullBoolean, Null.NullInteger, Null.NullString, Null.NullString, Me.GallerySettings.SortBy, Me.GallerySettings.SortDirection)
End If
End If
If (photoList.Count > 0) Then
Dim i As Integer = 0
For Each objPhoto As PhotoInfo In photoList
If (objPhoto.PhotoID = _itemID) Then
If (i) = 0 Then
lnkPrevious.Visible = False
lnkPreviousTop.Visible = False
Else
If (_tagID <> Null.NullInteger) Then
lnkPrevious.NavigateUrl = NavigateURL(Me.TabId, "", "galleryType=SlideShow", "ItemID=" & CType(photoList(i - 1), PhotoInfo).PhotoID.ToString(), "TagID=" & _tagID.ToString())
lnkPreviousTop.NavigateUrl = NavigateURL(Me.TabId, "", "galleryType=SlideShow", "ItemID=" & CType(photoList(i - 1), PhotoInfo).PhotoID.ToString(), "TagID=" & _tagID.ToString())
Else
If (_searchText <> "") Then
lnkPrevious.NavigateUrl = NavigateURL(Me.TabId, "", "galleryType=SlideShow", "ItemID=" & CType(photoList(i - 1), PhotoInfo).PhotoID.ToString(), "SearchText=" & System.Uri.EscapeDataString(_searchText))
lnkPreviousTop.NavigateUrl = NavigateURL(Me.TabId, "", "galleryType=SlideShow", "ItemID=" & CType(photoList(i - 1), PhotoInfo).PhotoID.ToString(), "SearchText=" & System.Uri.EscapeDataString(_searchText))
Else
lnkPrevious.NavigateUrl = NavigateURL(Me.TabId, "", "galleryType=SlideShow", "ItemID=" & CType(photoList(i - 1), PhotoInfo).PhotoID.ToString())
lnkPreviousTop.NavigateUrl = NavigateURL(Me.TabId, "", "galleryType=SlideShow", "ItemID=" & CType(photoList(i - 1), PhotoInfo).PhotoID.ToString())
End If
End If
End If
If (i + 1) = photoList.Count Then
lnkNext.Visible = False
lnkNextTop.Visible = False
Else
If (_tagID <> Null.NullInteger) Then
lnkNext.NavigateUrl = NavigateURL(Me.TabId, "", "galleryType=SlideShow", "ItemID=" & CType(photoList(i + 1), PhotoInfo).PhotoID.ToString(), "TagID=" & _tagID.ToString())
lnkNextTop.NavigateUrl = NavigateURL(Me.TabId, "", "galleryType=SlideShow", "ItemID=" & CType(photoList(i + 1), PhotoInfo).PhotoID.ToString(), "TagID=" & _tagID.ToString())
Else
If (_searchText <> "") Then
lnkNext.NavigateUrl = NavigateURL(Me.TabId, "", "galleryType=SlideShow", "ItemID=" & CType(photoList(i + 1), PhotoInfo).PhotoID.ToString(), "SearchText=" & System.Uri.EscapeDataString(_searchText))
lnkNextTop.NavigateUrl = NavigateURL(Me.TabId, "", "galleryType=SlideShow", "ItemID=" & CType(photoList(i + 1), PhotoInfo).PhotoID.ToString(), "SearchText=" & System.Uri.EscapeDataString(_searchText))
Else
lnkNext.NavigateUrl = NavigateURL(Me.TabId, "", "galleryType=SlideShow", "ItemID=" & CType(photoList(i + 1), PhotoInfo).PhotoID.ToString())
lnkNextTop.NavigateUrl = NavigateURL(Me.TabId, "", "galleryType=SlideShow", "ItemID=" & CType(photoList(i + 1), PhotoInfo).PhotoID.ToString())
End If
End If
End If
lblPageCount.Text = String.Format(Localization.GetString("PhotoCount.Text", LocalResourceFile), (i + 1).ToString(), photoList.Count.ToString())
End If
i = i + 1
Next
End If
lnkReturnToOrigin.NavigateUrl = NavigateURL(Me.TabId, "", "AlbumID=" & Me.ModuleId.ToString() & "-" & _albumID)
End Sub
Private Function GetTagUrl(ByVal tag As String, ByVal tabID As Integer, ByVal moduleID As Integer, ByVal tabModuleID As Integer) As String
If (AllLetters(tag) = False) Then
Dim objTagController As New TagController()
Dim objTag As TagInfo = objTagController.Get(moduleID, tag.ToLower())
If Not (objTag Is Nothing) Then
Return NavigateURL(tabID, "", "TagID=" & objTag.TagID.ToString(), "Tags=" & tabModuleID.ToString())
End If
Else
Return NavigateURL(tabID, "", "Tag=" & tag, "Tags=" & tabModuleID.ToString())
End If
Return ""
End Function
Private Function AllLetters(ByVal txt As String) As Boolean
Dim reg As New Regex("^[A-Za-z]+$")
Dim ok As Boolean = True
If Not (reg.IsMatch(txt)) Then
ok = False
Else
ok = True
End If
Return ok
End Function
Private Sub BindPhoto()
Dim objPhotoController As New PhotoController
Dim objPhoto As PhotoInfo = objPhotoController.Get(_itemID)
If Not (objPhoto Is Nothing) Then
lblName.Text = objPhoto.Name
If (objPhoto.Tags <> "") Then
Dim tags As String() = objPhoto.Tags.Split(","c)
lblTags.Text = "<b>Tags:</b>"
For Each tag As String In tags
lblTags.Text = lblTags.Text & " <a href='" & GetTagUrl(tag, TabId, ModuleId, TabModuleId) & "'>" & tag & "</a>"
Next
End If
lblDescription.Text = objPhoto.Description
If (objPhoto.Name <> "") Then
Me.BasePage.Title = objPhoto.Name
End If
If (objPhoto.Description <> "") Then
Me.BasePage.Description = objPhoto.Description
End If
If (objPhoto.Tags <> "") Then
Me.BasePage.KeyWords = objPhoto.Tags.Replace(" ", ",")
End If
If (objPhoto.Width > Me.GallerySettings.ImageWidth Or objPhoto.Height > Me.GallerySettings.ImageHeight) Then
' Use Handler to Resize
Dim width As Integer = objPhoto.Width
Dim height As Integer = objPhoto.Height
If (width > GallerySettings.ImageWidth) Then
width = GallerySettings.ImageWidth
height = Convert.ToInt32(height / (objPhoto.Width / GallerySettings.ImageWidth))
End If
If (height > GallerySettings.ImageHeight) Then
height = GallerySettings.ImageHeight
width = Convert.ToInt32(objPhoto.Width / (objPhoto.Height / GallerySettings.ImageHeight))
End If
imgPhoto.Width = Unit.Pixel(width)
imgPhoto.Height = Unit.Pixel(height)
If (Me.GallerySettings.Compression = Common.CompressionType.Quality) Then
imgPhoto.ImageUrl = Me.ResolveUrl("ImageHandler.ashx?width=" & width.ToString() & "&height=" & height.ToString() & "&HomeDirectory=" & System.Uri.EscapeDataString(Me.PortalSettings.HomeDirectory & objPhoto.HomeDirectory) & "&fileName=" & System.Uri.EscapeDataString(objPhoto.FileName) & "&portalid=" & Me.PortalId.ToString() & "&q=1")
Else
imgPhoto.ImageUrl = Me.ResolveUrl("ImageHandler.ashx?width=" & width.ToString() & "&height=" & height.ToString() & "&HomeDirectory=" & System.Uri.EscapeDataString(Me.PortalSettings.HomeDirectory & objPhoto.HomeDirectory) & "&fileName=" & System.Uri.EscapeDataString(objPhoto.FileName) & "&portalid=" & Me.PortalId.ToString())
End If
lnkDownload.NavigateUrl = Me.PortalSettings.HomeDirectory & objPhoto.HomeDirectory & "/" & System.Uri.EscapeDataString(objPhoto.FileName)
Else
imgPhoto.Width = Unit.Pixel(objPhoto.Width)
imgPhoto.Height = Unit.Pixel(objPhoto.Height)
imgPhoto.ImageUrl = Me.PortalSettings.HomeDirectory & objPhoto.HomeDirectory & "/" & System.Uri.EscapeDataString(objPhoto.FileName)
lnkDownload.NavigateUrl = Me.PortalSettings.HomeDirectory & objPhoto.HomeDirectory & "/" & System.Uri.EscapeDataString(objPhoto.FileName)
End If
If (Me.GallerySettings.EnableTooltip) Then
If (objPhoto.Description.Trim().Length > 0) Then
imgPhoto.AlternateText = objPhoto.Description().Replace(Chr(34), "")
Else
imgPhoto.AlternateText = objPhoto.Name.Replace(Chr(34), "")
End If
End If
_albumID = objPhoto.AlbumID()
If (_tagID = Null.NullInteger And _searchText = Null.NullString) Then
Dim objAlbumController As New AlbumController
Dim objAlbum As AlbumInfo = objAlbumController.Get(objPhoto.AlbumID)
While Not objAlbum Is Nothing
If (GallerySettings.AlbumFilter <> objAlbum.AlbumID.ToString()) Then
ucGalleryMenu.InsertCrumb(1, objAlbum.Caption, NavigateURL(Me.TabId, "", "AlbumID=" & Me.ModuleId.ToString() & "-" & objAlbum.AlbumID.ToString()))
End If
If (objAlbum.ParentAlbumID = Null.NullInteger) Then
objAlbum = Nothing
Else
objAlbum = objAlbumController.Get(objAlbum.ParentAlbumID)
End If
End While
End If
If (_tagID <> Null.NullInteger) Then
ucGalleryMenu.AddCrumb(objPhoto.Name, NavigateURL(Me.TabId, "", "galleryType=SlideShow", "ItemID=" & objPhoto.PhotoID.ToString(), "TagID=" & _tagID.ToString()))
Else
ucGalleryMenu.AddCrumb(objPhoto.Name, NavigateURL(Me.TabId, "", "galleryType=SlideShow", "ItemID=" & objPhoto.PhotoID.ToString()))
End If
Else
Response.Redirect(NavigateURL, True)
End If
End Sub
Private Sub ReadQueryString()
If Not (Request.QueryString("ItemId") Is Nothing) Then
_itemID = Int32.Parse(Request.QueryString("ItemId"))
Else
Response.Redirect(NavigateURL, True)
End If
If Not (Request.QueryString("TagID") Is Nothing) Then
_tagID = Int32.Parse(Request.QueryString("TagID"))
End If
If Not (Request.QueryString("SearchText") Is Nothing) Then
_searchText = Server.UrlDecode(Request.QueryString("SearchText"))
End If
End Sub
#End Region
#Region " Protected Methods "
Protected Function GetWidth() As String
Return GallerySettings.StandardWidth.ToString() & "px"
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
ReadQueryString()
BindBreadCrumbs()
BindPhoto()
BindNav()
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
#End Region
End Class
End Namespace