-
Notifications
You must be signed in to change notification settings - Fork 4
/
Search.ascx.vb
executable file
·144 lines (101 loc) · 5.77 KB
/
Search.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
Imports DotNetNuke.Common
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.Localization
Imports Ventrian.SimpleGallery.Common
Namespace Ventrian.SimpleGallery
Partial Public Class Search
Inherits SimpleGalleryBase
#Region " Private Members "
Private _tabID As Integer = Null.NullInteger
Private _moduleID As Integer = Null.NullInteger
Private _tabModuleID As Integer = Null.NullInteger
#End Region
#Region " Private Methods "
Private Sub BindSearch()
If (Settings.Contains(Constants.SETTING_SEARCH_TAB_ID)) Then
_tabID = Convert.ToInt32(Settings(Constants.SETTING_SEARCH_TAB_ID).ToString())
End If
If (Settings.Contains(Constants.SETTING_SEARCH_MODULE_ID)) Then
_moduleID = Convert.ToInt32(Settings(Constants.SETTING_SEARCH_MODULE_ID).ToString())
End If
If (Settings.Contains(Constants.SETTING_SEARCH_TAB_MODULE_ID)) Then
_tabModuleID = Convert.ToInt32(Settings(Constants.SETTING_SEARCH_TAB_MODULE_ID).ToString())
End If
If (_moduleID <> Null.NullInteger) Then
Dim delimStr As String = "[]"
Dim delimiter As Char() = delimStr.ToCharArray()
Dim template As String = Me.GallerySettings.SearchTemplate
Dim templateTokens As String() = Me.GallerySettings.SearchTemplate.Split(delimiter)
For iPtr As Integer = 0 To templateTokens.Length - 1 Step 2
pnlSearch.Controls.Add(New LiteralControl(templateTokens(iPtr).ToString()))
If iPtr < templateTokens.Length - 1 Then
Select Case templateTokens(iPtr + 1)
Case "BUTTON"
Dim objButton As New Button
objButton.ID = Globals.CreateValidID("SearchButton-" & ModuleId.ToString() & "-" & iPtr.ToString())
objButton.CssClass = "Normal"
objButton.ValidationGroup = "Search-" & ModuleId.ToString()
objButton.Text = Localization.GetString("Search", Me.LocalResourceFile)
AddHandler objButton.Click, AddressOf Search_OnClick
pnlSearch.DefaultButton = objButton.ID
pnlSearch.Controls.Add(objButton)
Case "LINKBUTTON"
Dim objLinkButton As New LinkButton
objLinkButton.ID = Globals.CreateValidID("SearchButton-" & ModuleId.ToString() & "-" & iPtr.ToString())
objLinkButton.CssClass = "CommandButton"
objLinkButton.ValidationGroup = "Search-" & ModuleId.ToString()
objLinkButton.Text = Localization.GetString("Search", Me.LocalResourceFile)
AddHandler objLinkButton.Click, AddressOf Search_OnClick
pnlSearch.DefaultButton = objLinkButton.ID
pnlSearch.Controls.Add(objLinkButton)
Case "TEXTBOX"
Dim objTextBox As New TextBox
objTextBox.ID = Globals.CreateValidID("SearchText-" & ModuleId.ToString() & "-" & iPtr.ToString())
objTextBox.CssClass = "Normal"
objTextBox.ValidationGroup = "Search-" & ModuleId.ToString()
If (Request("SearchText") <> "" And Request("SearchID") = _tabModuleID.ToString()) Then
objTextBox.Text = Server.HtmlEncode(Request("SearchText"))
End If
pnlSearch.Controls.Add(objTextBox)
End Select
End If
Next
Else
Dim objLabel As New Label
objLabel.ID = Globals.CreateValidID("Search-" & Me.ModuleId.ToString())
objLabel.CssClass = "Normal"
objLabel.Text = Localization.GetString("Configure", Me.LocalResourceFile)
pnlSearch.Controls.Add(objLabel)
End If
End Sub
#End Region
#Region " Event Handlers "
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
Try
BindSearch()
Catch exc As Exception
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub Search_OnClick(ByVal sender As System.Object, ByVal e As System.EventArgs)
Try
Dim searchText As String = ""
For Each objControl As Control In pnlSearch.Controls
If (objControl IsNot Nothing) Then
If (objControl.ID <> "" AndAlso objControl.ID.StartsWith("SearchText")) Then
Dim objTextBox As TextBox = CType(objControl, TextBox)
searchText = objTextBox.Text
End If
End If
Next
If (searchText.Trim() <> "") Then
Response.Redirect(NavigateURL(_tabID, "", "SearchID=" & _tabModuleID.ToString(), "SearchText=" & Server.UrlEncode(searchText)), True)
End If
Catch exc As Exception
ProcessModuleLoadException(Me, exc)
End Try
End Sub
#End Region
End Class
End Namespace