-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathSearchSmall.ascx.vb
executable file
·3255 lines (2644 loc) · 211 KB
/
SearchSmall.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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Imports DotNetNuke.Common
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Framework
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.Localization
Imports DotNetNuke.Security
Namespace Ventrian.PropertyAgent
Partial Public Class SearchSmall
Inherits PropertyAgentSearchBase
#Region " Private Members "
Dim _customFieldIDs As String = Null.NullString
Dim _propertyTypeID As String = Null.NullString
Dim _propertyAgentID As String = Null.NullString
Dim _propertyBrokerID As String = Null.NullString
Dim _searchValues As String = Null.NullString
Dim _location As String = Null.NullString
#End Region
#Region " Private Properties "
Private ReadOnly Property EditPropertyResourceFile() As String
Get
Return "~/DesktopModules/PropertyAgent/App_LocalResources/EditProperty"
End Get
End Property
#End Region
#Region " Private Methods "
Private Sub ReadQueryString()
If Not (Request("CustomFieldIDs") Is Nothing) Then
_customFieldIDs = Request("CustomFieldIDs")
End If
Dim propertyTypeIDParam As String = PropertySettings.SEOPropertyTypeID
If (Request(propertyTypeIDParam) = "") Then
propertyTypeIDParam = "PropertyTypeID"
End If
If Not (Request(propertyTypeIDParam) Is Nothing) Then
_propertyTypeID = Request(propertyTypeIDParam)
End If
If Not (Request("PropertyAgentID") Is Nothing) Then
_propertyAgentID = Request("PropertyAgentID")
End If
If Not (Request("PropertyBrokerID") Is Nothing) Then
_propertyBrokerID = Request("PropertyBrokerID")
End If
If Not (Request("SearchValues") Is Nothing) Then
_searchValues = Request("SearchValues")
End If
If Not (Request("Location") Is Nothing) Then
_location = Request("Location")
End If
If (Page.IsPostBack) Then
If (IsNumeric(Request(drpPropertyTypes.ClientID.ToString().Replace("_", "$")))) Then
_propertyTypeID = Convert.ToInt32(Request(drpPropertyTypes.ClientID.ToString().Replace("_", "$")))
End If
End If
End Sub
Private Sub BindSearch()
If (Me.PropertySettingsSearch.LayoutMode = SearchLayoutMode.CustomLayout) Then
phLayoutStandard.Visible = False
Dim delimStr As String = "[]"
Dim delimiter As Char() = delimStr.ToCharArray()
ProcessSearch(phSearch.Controls, Me.PropertySettingsSearch.SearchTemplate.Split(delimiter))
Else
trWildcard.Visible = Me.PropertySettingsSearch.SearchWildcard
trWildcard2.Visible = Me.PropertySettingsSearch.SearchWildcard
trTypes.Visible = Me.PropertySettingsSearch.SearchTypes
trTypes2.Visible = Me.PropertySettingsSearch.SearchTypes
trLocation.Visible = Me.PropertySettingsSearch.SearchLocation
trLocation2.Visible = Me.PropertySettingsSearch.SearchLocation
trAgents.Visible = Me.PropertySettingsSearch.SearchAgents
trAgents2.Visible = Me.PropertySettingsSearch.SearchAgents
trBrokers.Visible = Me.PropertySettingsSearch.SearchBrokers
trBrokers2.Visible = Me.PropertySettingsSearch.SearchBrokers
If (Me.PropertySettingsSearch.SearchWildcard) Then
DotNetNuke.UI.Utilities.DNNClientAPI.EnableMinMax(cmdHelpSearch, pnlHelpSearch, True, DotNetNuke.UI.Utilities.DNNClientAPI.MinMaxPersistanceType.None)
cmdHelpSearch.Visible = Not Me.PropertySettingsSearch.HideHelpIcon
lblLabelSearch.Text = GetResourceString("Search", Me.EditPropertyResourceFile, Me.PropertySettings)
lblHelpSearch.Text = GetResourceString("SearchHelp", Me.EditPropertyResourceFile, Me.PropertySettings)
imgHelpSearch.AlternateText = GetResourceString("SearchHelp", Me.EditPropertyResourceFile, Me.PropertySettings)
txtWildcard.Text = GetSearchValue(-1)
txtWildcard.Width = Unit.Pixel(Me.PropertySettingsSearch.Width)
End If
If (Me.PropertySettingsSearch.SearchLocation) Then
DotNetNuke.UI.Utilities.DNNClientAPI.EnableMinMax(cmdHelpLocation, pnlHelpLocation, True, DotNetNuke.UI.Utilities.DNNClientAPI.MinMaxPersistanceType.None)
cmdHelpLocation.Visible = Not Me.PropertySettingsSearch.HideHelpIcon
lblLabelLocation.Text = GetResourceString("Location", Me.EditPropertyResourceFile, Me.PropertySettings)
lblHelpLocation.Text = GetResourceString("LocationHelp", Me.EditPropertyResourceFile, Me.PropertySettings)
imgHelpLocation.AlternateText = GetResourceString("LocationHelp", Me.EditPropertyResourceFile, Me.PropertySettings)
txtLocation.Text = _location
txtLocation.Width = Unit.Pixel(Me.PropertySettingsSearch.Width)
End If
If (Me.PropertySettingsSearch.SearchTypes) Then
DotNetNuke.UI.Utilities.DNNClientAPI.EnableMinMax(cmdHelpTypes, pnlHelpTypes, True, DotNetNuke.UI.Utilities.DNNClientAPI.MinMaxPersistanceType.None)
cmdHelpTypes.Visible = Not Me.PropertySettingsSearch.HideHelpIcon
lblLabelTypes.Text = GetResourceString("PropertyTypes", Me.EditPropertyResourceFile, Me.PropertySettings)
lblHelpTypes.Text = GetResourceString("PropertyTypesHelp", Me.EditPropertyResourceFile, Me.PropertySettings)
imgHelpTypes.AlternateText = GetResourceString("PropertyTypesHelp", Me.EditPropertyResourceFile, Me.PropertySettings)
Dim objPropertyTypeController As New PropertyTypeController
Dim objTypes As List(Of PropertyTypeInfo) = objPropertyTypeController.ListAll(Me.PropertySettingsSearch.PropertyAgentModuleID, True, Me.PropertySettings.TypesSortBy, Null.NullString())
If (Me.PropertySettingsSearch.HideTypeCount) Then
drpPropertyTypes.DataTextField = "NameIndented"
End If
If (Me.PropertySettingsSearch.HideZeroCount) Then
Dim objTypesSelected As New List(Of PropertyTypeInfo)
For Each objType As PropertyTypeInfo In objTypes
If (objType.PropertyCount > 0) Then
objTypesSelected.Add(objType)
End If
Next
drpPropertyTypes.DataSource = objTypesSelected
drpPropertyTypes.DataBind()
Else
drpPropertyTypes.DataSource = objTypes
drpPropertyTypes.DataBind()
End If
Dim selectText As String = GetResourceString("SelectType", Me.EditPropertyResourceFile, Me.PropertySettings)
drpPropertyTypes.Items.Insert(0, New ListItem(selectText, "-1"))
If Not (drpPropertyTypes.Items.FindByValue(_propertyTypeID.ToString()) Is Nothing) Then
drpPropertyTypes.SelectedValue = _propertyTypeID.ToString()
End If
drpPropertyTypes.Width = Unit.Pixel(Me.PropertySettingsSearch.Width)
For Each objCustomField As CustomFieldInfo In Me.CustomFields
If (objCustomField.IsPublished AndAlso objCustomField.FieldType = CustomFieldType.DropDownList AndAlso objCustomField.FieldElementType = FieldElementType.LinkedToPropertyType) Then
For Each item As String In Me.PropertySettingsSearch.CustomFields.Split(","c)
If (item = objCustomField.CustomFieldID.ToString()) Then
drpPropertyTypes.AutoPostBack = True
End If
Next
End If
Next
End If
If (Me.PropertySettingsSearch.SearchBrokers) Then
DotNetNuke.UI.Utilities.DNNClientAPI.EnableMinMax(cmdHelpBrokers, pnlHelpBrokers, True, DotNetNuke.UI.Utilities.DNNClientAPI.MinMaxPersistanceType.None)
cmdHelpBrokers.Visible = Not Me.PropertySettingsSearch.HideHelpIcon
lblLabelBrokers.Text = GetResourceString("PropertyBrokers", Me.EditPropertyResourceFile, Me.PropertySettings)
lblHelpBrokers.Text = GetResourceString("PropertyBrokersHelp", Me.EditPropertyResourceFile, Me.PropertySettings)
imgHelpBrokers.AlternateText = GetResourceString("PropertyBrokersHelp", Me.EditPropertyResourceFile, Me.PropertySettings)
Dim objAgentController As New AgentController(PortalSettings, PropertySettings, PortalId)
drpPropertyBrokers.DataSource = objAgentController.ListOwners(Me.PortalId, Me.PropertySettingsSearch.PropertyAgentModuleID, PropertySettings.PermissionBroker)
drpPropertyBrokers.DataBind()
Dim selectText As String = GetResourceString("SelectBroker", Me.EditPropertyResourceFile, PropertySettings)
drpPropertyBrokers.Items.Insert(0, New ListItem(selectText, "-1"))
If Not (drpPropertyBrokers.Items.FindByValue(_propertyBrokerID.ToString()) Is Nothing) Then
drpPropertyBrokers.SelectedValue = _propertyBrokerID.ToString()
End If
drpPropertyBrokers.Width = Unit.Pixel(Me.PropertySettingsSearch.Width)
End If
BindAgents()
cmdSearch.CssClass = Me.PropertySettingsSearch.SearchStyle
Dim objCustomFieldController As New CustomFieldController
rptDetails.DataSource = Me.CustomFields
rptDetails.DataBind()
End If
End Sub
Private Sub BindAgents()
If (Me.PropertySettingsSearch.SearchAgents) Then
DotNetNuke.UI.Utilities.DNNClientAPI.EnableMinMax(cmdHelpAgents, pnlHelpAgents, True, DotNetNuke.UI.Utilities.DNNClientAPI.MinMaxPersistanceType.None)
cmdHelpAgents.Visible = Not Me.PropertySettingsSearch.HideHelpIcon
lblLabelAgents.Text = GetResourceString("PropertyAgents", Me.EditPropertyResourceFile, Me.PropertySettings)
lblHelpAgents.Text = GetResourceString("PropertyAgentsHelp", Me.EditPropertyResourceFile, Me.PropertySettings)
imgHelpAgents.AlternateText = GetResourceString("PropertyAgentsHelp", Me.EditPropertyResourceFile, Me.PropertySettings)
Dim objAgentController As New AgentController(PortalSettings, PropertySettings, PortalId)
If (trBrokers.Visible AndAlso drpPropertyBrokers.SelectedValue <> "-1") Then
drpPropertyAgents.DataSource = objAgentController.ListSelected(Me.PortalId, Me.PropertySettingsSearch.PropertyAgentModuleID, Convert.ToInt32(drpPropertyBrokers.SelectedValue))
Else
drpPropertyAgents.DataSource = objAgentController.ListActive(Me.PortalId, Me.PropertySettingsSearch.PropertyAgentModuleID)
End If
drpPropertyAgents.DataBind()
Dim selectText As String = GetResourceString("SelectAgent", Me.EditPropertyResourceFile, PropertySettings)
drpPropertyAgents.Items.Insert(0, New ListItem(selectText, "-1"))
If Not (drpPropertyAgents.Items.FindByValue(_propertyAgentID.ToString()) Is Nothing) Then
drpPropertyAgents.SelectedValue = _propertyAgentID.ToString()
End If
drpPropertyAgents.Width = Unit.Pixel(Me.PropertySettingsSearch.Width)
End If
End Sub
Private Function BuildCustomFieldIDs(ByVal customFieldIDs As String, ByVal value As String) As String
If (customFieldIDs.Length = 0) Then
Return value
Else
Return customFieldIDs & "," & value
End If
End Function
Private Function BuildSearchValues(ByVal searchValues As String, ByVal value As String) As String
Dim objSecurity As New PortalSecurity
If (searchValues.Length = 0) Then
Return Server.UrlEncode(objSecurity.InputFilter(value, PortalSecurity.FilterFlag.NoScripting).Replace(",", "^"))
Else
Return searchValues & "," & Server.UrlEncode(objSecurity.InputFilter(value, PortalSecurity.FilterFlag.NoScripting).Replace(",", "^"))
End If
End Function
Public Function GetTypeLink(ByVal tabID As Integer, ByVal moduleID As Integer, ByVal propertyTypeID As Integer) As String
Dim objTypesParam As New List(Of String)
objTypesParam.Add(PropertySettings.SEOAgentType & "=ViewType")
objTypesParam.Add(PropertySettings.SEOPropertyTypeID & "=" & propertyTypeID.ToString())
If (Me.PropertySettings.TypeParams) Then
Dim types As New List(Of String)
Dim objPropertyTypeController As New PropertyTypeController
Dim objTypes As List(Of PropertyTypeInfo) = objPropertyTypeController.ListAll(moduleID, True, PropertyTypeSortByType.Standard, Null.NullString())
For Each objType As PropertyTypeInfo In objTypes
If (objType.PropertyTypeID = propertyTypeID) Then
types.Add(objType.Name)
Dim i As Integer = 2
While objType.ParentID <> Null.NullInteger
For Each objParentType As PropertyTypeInfo In objTypes
If (objParentType.PropertyTypeID = objType.ParentID) Then
types.Add(objParentType.Name)
objType = objParentType
i = i + 1
End If
Next
End While
End If
Next
Dim length As Integer = types.Count
For Each t As String In types
objTypesParam.Insert(2, "Type" & length.ToString() & "=" & t)
length = length - 1
Next
End If
Return NavigateURL(tabID, "", objTypesParam.ToArray())
End Function
Private Sub ProcessHeaderFooter(ByRef objPlaceHolder As ControlCollection, ByVal layoutArray As String())
For iPtr As Integer = 0 To layoutArray.Length - 1 Step 2
objPlaceHolder.Add(New LiteralControl(layoutArray(iPtr).ToString()))
If iPtr < layoutArray.Length - 1 Then
Select Case layoutArray(iPtr + 1)
Case "ISMOBILEDEVICE"
If LayoutController.IsMobileBrowser() = False Then
While (iPtr < layoutArray.Length - 1)
If (layoutArray(iPtr + 1) = "/ISMOBILEDEVICE") Then
Exit While
End If
iPtr = iPtr + 1
End While
End If
Case "/ISMOBILEDEVICE"
' Do Nothing
Case "ISNOTMOBILEDEVICE"
If LayoutController.IsMobileBrowser() = True Then
While (iPtr < layoutArray.Length - 1)
If (layoutArray(iPtr + 1) = "/ISNOTMOBILEDEVICE") Then
Exit While
End If
iPtr = iPtr + 1
End While
End If
Case "/ISNOTMOBILEDEVICE"
' Do Nothing
End Select
End If
Next
End Sub
Private Sub ProcessSearch(ByRef objPlaceHolder As ControlCollection, ByVal layoutArray As String())
Dim htFields As New Hashtable
For iPtr As Integer = 0 To layoutArray.Length - 1 Step 2
objPlaceHolder.Add(New LiteralControl(layoutArray(iPtr).ToString()))
If iPtr < layoutArray.Length - 1 Then
Select Case layoutArray(iPtr + 1)
Case "AGENT"
Dim drpPropertyAgent As New DropDownList
drpPropertyAgent.ID = Globals.CreateValidID(ModuleKey & "-Search-" & iPtr.ToString() & "-Agent")
drpPropertyAgent.CssClass = "NormalTextBox"
drpPropertyAgent.Width = PropertySettingsSearch.Width
drpPropertyAgent.DataTextField = "DisplayName"
drpPropertyAgent.DataValueField = "UserId"
Dim objAgentController As New AgentController(PortalSettings, PropertySettings, PortalId)
Dim arrAgents As ArrayList
If (IsPostBack = False AndAlso _propertyBrokerID <> Null.NullString) Then
arrAgents = objAgentController.ListSelected(PortalId, Me.PropertySettingsSearch.PropertyAgentModuleID, Convert.ToInt32(_propertyBrokerID))
Else
arrAgents = objAgentController.ListActive(PortalId, Me.PropertySettingsSearch.PropertyAgentModuleID)
End If
drpPropertyAgent.DataSource = arrAgents
drpPropertyAgent.DataBind()
Dim selectText As String = GetResourceString("SelectAgent", "~/DesktopModules/PropertyAgent/App_LocalResources/EditProperty", PropertySettings)
drpPropertyAgent.Items.Insert(0, New ListItem(selectText, "-1"))
If Not (drpPropertyAgent.Items.FindByValue(_propertyAgentID.ToString()) Is Nothing) Then
drpPropertyAgent.SelectedValue = _propertyAgentID.ToString()
End If
objPlaceHolder.Add(drpPropertyAgent)
Case "BROKER"
Dim drpPropertyBrokers As New DropDownList
drpPropertyBrokers.ID = Globals.CreateValidID(ModuleKey & "-Search-" & iPtr.ToString() & "-Broker")
Dim objAgentController As New AgentController(PortalSettings, _
PropertySettings, _
PortalId)
Dim arrBrokers As ArrayList = objAgentController.ListOwners(PortalId, Me.PropertySettingsSearch.PropertyAgentModuleID, PropertySettings.PermissionBroker)
drpPropertyBrokers.AutoPostBack = True
drpPropertyBrokers.CssClass = "NormalTextBox"
drpPropertyBrokers.Width = PropertySettingsSearch.Width
drpPropertyBrokers.DataSource = arrBrokers
drpPropertyBrokers.DataTextField = "DisplayName"
drpPropertyBrokers.DataValueField = "UserId"
drpPropertyBrokers.DataBind()
AddHandler drpPropertyBrokers.SelectedIndexChanged, AddressOf drpPropertyBrokersCustom_SelectedIndexChanged
Dim selectText As String = GetResourceString("SelectBroker", "~/DesktopModules/PropertyAgent/App_LocalResources/EditProperty", PropertySettings)
drpPropertyBrokers.Items.Insert(0, New ListItem(selectText, "-1"))
If Not (drpPropertyBrokers.Items.FindByValue(_propertyBrokerID.ToString()) Is Nothing) Then
drpPropertyBrokers.SelectedValue = _propertyBrokerID.ToString()
End If
objPlaceHolder.Add(drpPropertyBrokers)
Case "LOCATION"
Dim txtLocation As New TextBox
txtLocation.Width = PropertySettingsSearch.Width
txtLocation.CssClass = "NormalTextBox"
txtLocation.ID = Globals.CreateValidID(ModuleKey & "-Search-" & iPtr.ToString() & "-Location")
txtLocation.EnableViewState = False
txtLocation.Text = _location
objPlaceHolder.Add(txtLocation)
Case "SEARCHLINK"
Dim cmdSearch As New LinkButton
cmdSearch.ID = Globals.CreateValidID(ModuleKey & "-Search-" & iPtr.ToString())
cmdSearch.Text = Localization.GetString("Search", Me.LocalResourceFile)
cmdSearch.EnableViewState = False
cmdSearch.CssClass = PropertySettingsSearch.SearchStyle
cmdSearch.BorderStyle = BorderStyle.None
AddHandler cmdSearch.Click, AddressOf Search_Click
objPlaceHolder.Add(cmdSearch)
Case "SEARCHBUTTON"
Dim btnSearch As New Button
btnSearch.ID = Globals.CreateValidID(ModuleKey & "-Search-" & iPtr.ToString())
btnSearch.Text = Localization.GetString("Search", Me.LocalResourceFile)
btnSearch.EnableViewState = False
AddHandler btnSearch.Click, AddressOf Search_Click
objPlaceHolder.Add(btnSearch)
Case "TYPE"
Dim drpPropertyTypes As New DropDownList
drpPropertyTypes.ID = Globals.CreateValidID(ModuleKey & "-Search-" & iPtr.ToString() & "-Type")
drpPropertyTypes.EnableViewState = False
drpPropertyTypes.Width = PropertySettingsSearch.Width
Dim objPropertyTypeController As New PropertyTypeController
drpPropertyTypes.CssClass = "NormalTextBox"
drpPropertyTypes.DataTextField = "NameIndentedWithCount"
drpPropertyTypes.DataValueField = "PropertyTypeID"
Dim objTypes As List(Of PropertyTypeInfo) = objPropertyTypeController.ListAll(Me.PropertySettingsSearch.PropertyAgentModuleID, True, Me.PropertySettings.TypesSortBy, Null.NullString())
If (Me.PropertySettingsSearch.HideTypeCount) Then
drpPropertyTypes.DataTextField = "NameIndented"
End If
If (Me.PropertySettingsSearch.HideZeroCount) Then
Dim objTypesSelected As New List(Of PropertyTypeInfo)
For Each objType As PropertyTypeInfo In objTypes
If (objType.PropertyCount > 0) Then
objTypesSelected.Add(objType)
End If
Next
drpPropertyTypes.DataSource = objTypesSelected
drpPropertyTypes.DataBind()
Else
drpPropertyTypes.DataSource = objTypes
drpPropertyTypes.DataBind()
End If
For Each objCustomField As CustomFieldInfo In CustomFields
If (objCustomField.IsPublished AndAlso objCustomField.FieldType = CustomFieldType.DropDownList AndAlso objCustomField.FieldElementType = FieldElementType.LinkedToPropertyType) Then
drpPropertyTypes.AutoPostBack = True
AddHandler drpPropertyTypes.SelectedIndexChanged, AddressOf drpPropertyType_SelectedIndexChanged
End If
Next
Dim selectText As String = GetResourceString("SelectType", "~/DesktopModules/PropertyAgent/App_LocalResources/EditProperty", PropertySettings)
drpPropertyTypes.Items.Insert(0, New ListItem(selectText, "-1"))
objPlaceHolder.Add(drpPropertyTypes)
If Not (drpPropertyTypes.Items.FindByValue(_propertyTypeID.ToString()) Is Nothing) Then
drpPropertyTypes.SelectedValue = _propertyTypeID.ToString()
End If
Case "TYPECASCADE"
Dim objPropertyTypeController As New PropertyTypeController
Dim objTypesAll As List(Of PropertyTypeInfo) = objPropertyTypeController.ListAll(Me.PropertySettingsSearch.PropertyAgentModuleID, True, Me.PropertySettings.TypesSortBy, Null.NullString())
Dim maxLevel As Integer = 1
For Each objPropertyType As PropertyTypeInfo In objTypesAll
Dim currentLevel = 1
Dim typeIndented As String = objPropertyType.NameIndented
While typeIndented.StartsWith("..")
currentLevel = currentLevel + 1
typeIndented = typeIndented.Substring(2, typeIndented.Length - 2)
End While
If (currentLevel > maxLevel) Then
maxLevel = currentLevel
End If
Next
Dim typesListParam As New List(Of Integer)
If (IsPostBack = False And (_propertyTypeID <> Null.NullString)) Then
Dim objType As PropertyTypeInfo = objPropertyTypeController.Get(PropertySettingsSearch.PropertyAgentModuleID, _propertyTypeID)
If (objType IsNot Nothing) Then
typesListParam.Add(objType.PropertyTypeID)
While objType.ParentID <> Null.NullInteger
objType = objPropertyTypeController.Get(PropertySettingsSearch.PropertyAgentModuleID, objType.ParentID)
If (objType Is Nothing) Then
Exit While
End If
typesListParam.Insert(0, objType.PropertyTypeID)
End While
End If
End If
Dim bReset As Boolean = False
Dim typesListCurrent As New Hashtable
For i As Integer = 1 To maxLevel
Dim drpPropertyTypesCascade As New DropDownList
drpPropertyTypesCascade.ID = Globals.CreateValidID(ModuleKey & "-Search-" & iPtr.ToString() & "-TypeCascade-" & i.ToString())
drpPropertyTypesCascade.EnableViewState = False
drpPropertyTypesCascade.Width = PropertySettingsSearch.Width
drpPropertyTypesCascade.CssClass = "NormalTextBox"
drpPropertyTypesCascade.DataTextField = "NameWithCount"
drpPropertyTypesCascade.DataValueField = "PropertyTypeID"
If (Me.PropertySettingsSearch.HideTypeCount) Then
drpPropertyTypesCascade.DataTextField = "Name"
End If
If (i = 1) Then
Dim objTypes As List(Of PropertyTypeInfo) = objPropertyTypeController.List(Me.PropertySettingsSearch.PropertyAgentModuleID, True, Me.PropertySettings.TypesSortBy, Null.NullString(), Null.NullInteger)
If (Me.PropertySettingsSearch.HideZeroCount) Then
Dim objTypesSelected As New List(Of PropertyTypeInfo)
For Each objType As PropertyTypeInfo In objTypes
If (objType.PropertyCount > 0) Then
objTypesSelected.Add(objType)
End If
Next
drpPropertyTypesCascade.DataSource = objTypesSelected
drpPropertyTypesCascade.DataBind()
Else
drpPropertyTypesCascade.DataSource = objTypes
drpPropertyTypesCascade.DataBind()
End If
drpPropertyTypesCascade.AutoPostBack = True
If (typesListParam.Count > 0) Then
If Not (drpPropertyTypesCascade.Items.FindByValue(typesListParam(0).ToString()) Is Nothing) Then
drpPropertyTypesCascade.SelectedValue = typesListParam(0).ToString()
End If
End If
For Each li As ListItem In drpPropertyTypesCascade.Items
typesListCurrent.Add(li.Value, li.Value)
Next
Else
Dim parentID As Integer = Null.NullInteger
If (IsPostBack) Then
If (bReset = False) Then
Dim id As String = "dnn$ctr" & ModuleId.ToString() & "$SearchSmall$" & Globals.CreateValidID(ModuleKey & "-Search-" & iPtr.ToString() & "-TypeCascade-" & (i - 1).ToString())
If (Request(id) <> "") Then
If (IsNumeric(Request(id))) Then
If (Convert.ToInt32(Request(id)) <> -1) Then
parentID = Convert.ToInt32(Request(id))
If (id = Page.Request.Params.Get("__EVENTTARGET")) Then
bReset = True
End If
End If
End If
End If
End If
Else
If (typesListParam.Count > 0) Then
If ((i - 2) < (typesListParam.Count)) Then
parentID = typesListParam(i - 2)
End If
End If
End If
If (parentID <> Null.NullInteger) Then
Dim objTypes As List(Of PropertyTypeInfo) = objPropertyTypeController.List(Me.PropertySettingsSearch.PropertyAgentModuleID, True, Me.PropertySettings.TypesSortBy, Null.NullString(), parentID)
If (Me.PropertySettingsSearch.HideZeroCount) Then
Dim objTypesSelected As New List(Of PropertyTypeInfo)
For Each objType As PropertyTypeInfo In objTypes
If (objType.PropertyCount > 0) Then
objTypesSelected.Add(objType)
End If
Next
drpPropertyTypesCascade.DataSource = objTypesSelected
drpPropertyTypesCascade.DataBind()
Else
drpPropertyTypesCascade.DataSource = objTypes
drpPropertyTypesCascade.DataBind()
End If
If (typesListParam.Count >= i) Then
If Not (drpPropertyTypesCascade.Items.FindByValue(typesListParam(i - 1).ToString()) Is Nothing) Then
drpPropertyTypesCascade.SelectedValue = typesListParam(i - 1).ToString()
End If
End If
For Each li As ListItem In drpPropertyTypesCascade.Items
typesListCurrent.Add(li.Value, li.Value)
Next
End If
If (i < maxLevel) Then
drpPropertyTypesCascade.AutoPostBack = True
End If
If (drpPropertyTypesCascade.Items.Count = 0) Then
drpPropertyTypesCascade.Enabled = False
End If
End If
Dim selectText As String = GetResourceString("SelectType" + i.ToString(), "~/DesktopModules/PropertyAgent/App_LocalResources/EditProperty", PropertySettings)
If (selectText = ("RESX:" & "SelectType" & i.ToString() & ".Text") Or selectText = "" Or selectText = "-1") Then
selectText = GetResourceString("SelectType", "~/DesktopModules/PropertyAgent/App_LocalResources/EditProperty", PropertySettings)
End If
drpPropertyTypesCascade.Items.Insert(0, New ListItem(selectText, "-1"))
objPlaceHolder.Add(drpPropertyTypesCascade)
Next
Case "WILDCARD"
Dim txtWildcard As New TextBox
txtWildcard.Width = PropertySettingsSearch.Width
txtWildcard.CssClass = "NormalTextBox"
txtWildcard.ID = Globals.CreateValidID(ModuleKey & "-Search-" & iPtr.ToString() & "-Wildcard")
txtWildcard.EnableViewState = False
objPlaceHolder.Add(txtWildcard)
Case Else
If (layoutArray(iPtr + 1).ToUpper().StartsWith("CAPTION:")) Then
Dim field As String = layoutArray(iPtr + 1).Substring(8, layoutArray(iPtr + 1).Length - 8)
For Each objCustomField As CustomFieldInfo In CustomFields
If (objCustomField.Name.ToLower() = field.ToLower()) Then
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID(ModuleKey & "-Search-" & iPtr.ToString())
objLiteral.Text = objCustomField.Caption
objLiteral.EnableViewState = False
objPlaceHolder.Add(objLiteral)
Exit For
End If
Next
End If
If (layoutArray(iPtr + 1).ToUpper().StartsWith("CUSTOM:")) Then
Dim field As String = layoutArray(iPtr + 1).Substring(7, layoutArray(iPtr + 1).Length - 7)
For Each objCustomField As CustomFieldInfo In CustomFields
If (objCustomField.Name.ToLower() = field.ToLower()) Then
If (htFields.Contains(objCustomField.CustomFieldID) = False) Then
RenderCustomField(phSearch.Controls, objCustomField)
htFields.Add(objCustomField.CustomFieldID, objCustomField.CustomFieldID)
Exit For
End If
End If
Next
End If
End Select
End If
Next
End Sub
Private Sub RenderCustomField(ByRef objPlaceHolder As ControlCollection, ByVal objCustomField As CustomFieldInfo)
Dim OnlyForAuthenticated As Boolean = Null.NullBoolean
If Me.UserId = -1 Then OnlyForAuthenticated = True
Select Case (objCustomField.FieldType)
Case CustomFieldType.OneLineTextBox
Select Case objCustomField.SearchType
Case SearchType.Default
Dim objTextBox As New TextBox
objTextBox.CssClass = "NormalTextBox"
objTextBox.ID = objCustomField.CustomFieldID.ToString()
objTextBox.Width = Unit.Pixel(Me.PropertySettingsSearch.Width)
objPlaceHolder.Add(objTextBox)
objTextBox.Text = GetSearchValue(objCustomField.CustomFieldID)
Case SearchType.DropDown
Dim objDropDown As New DropDownList
objDropDown.CssClass = "NormalTextBox"
objDropDown.ID = objCustomField.CustomFieldID.ToString()
objDropDown.Width = Unit.Pixel(Me.PropertySettingsSearch.Width)
Dim objPropertyValueController As New PropertyValueController
Dim objPropertyValues As List(Of PropertyValueInfo) = objPropertyValueController.ListByCustomField(objCustomField.CustomFieldID)
For Each objPropertyValue As PropertyValueInfo In objPropertyValues
objDropDown.Items.Add(New ListItem(objPropertyValue.CustomValue, objPropertyValue.CustomValue))
Next
objDropDown.Items.Insert(0, New ListItem(Localization.GetString("SelectItem", Me.EditPropertyResourceFile), "-1"))
objPlaceHolder.Add(objDropDown)
Case SearchType.Range
If (objCustomField.FieldElementsFrom <> "") Then
Dim objDropDownFrom As New DropDownList
objDropDownFrom.CssClass = "NormalTextBox"
objDropDownFrom.ID = "From" & objCustomField.CustomFieldID.ToString()
Dim values As String() = objCustomField.FieldElementsFrom.Split(Convert.ToChar("|"))
For Each value As String In values
Dim item As New ListItem
item.Value = value
item.Text = value
Select Case objCustomField.ValidationType
Case CustomFieldValidationType.Currency
Try
Dim culture As String = "en-US"
Select Case PropertySettings.Currency
Case CurrencyType.AUD
culture = "en-AU"
Exit Select
Case CurrencyType.BRL
culture = "pt-BR"
Exit Select
Case CurrencyType.CAD
culture = "en-CA"
Exit Select
Case CurrencyType.CHF
culture = "de-CH"
Exit Select
Case CurrencyType.CNY
culture = "zh-CN"
Exit Select
Case CurrencyType.CZK
culture = "cs-CZ"
Exit Select
Case CurrencyType.EUR
culture = "fr-FR"
Select Case PropertySettings.EuroType
Case EuroType.Dutch
culture = "nl-NL"
Exit Select
Case EuroType.English
culture = "en-IE"
Exit Select
Case EuroType.French
culture = "fr-FR"
Exit Select
End Select
Exit Select
Case CurrencyType.GBP
culture = "en-GB"
Exit Select
Case CurrencyType.JPY
culture = "ja-JP"
Exit Select
Case CurrencyType.USD
culture = "en-US"
Exit Select
Case CurrencyType.MYR
culture = "en-MY"
Exit Select
Case CurrencyType.NZD
culture = "en-NZ"
Exit Select
Case CurrencyType.NOK
culture = "nb-NO"
Exit Select
Case CurrencyType.THB
culture = "th-TH"
Exit Select
Case CurrencyType.ZAR
culture = "en-ZA"
Exit Select
End Select
Dim portalFormat As System.Globalization.CultureInfo = New System.Globalization.CultureInfo(culture)
Dim format As String = "{0:C" & PropertySettings.CurrencyDecimalPlaces.ToString() & "}"
item.Text = String.Format(portalFormat.NumberFormat, format, Double.Parse(value))
Catch
End Try
Case CustomFieldValidationType.Date
Try
item.Text = DateTime.Parse(value).ToShortDateString()
Catch
End Try
End Select
objDropDownFrom.Items.Add(item)
Next
objDropDownFrom.Width = Unit.Pixel(Me.PropertySettingsSearch.Width / 2)
objPlaceHolder.Add(objDropDownFrom)
objDropDownFrom.Items.Insert(0, New ListItem(Localization.GetString("SelectFrom", Me.EditPropertyResourceFile), "-1"))
If Not (objDropDownFrom.Items.FindByValue(GetSearchValueRange(objCustomField.CustomFieldID, True)) Is Nothing) Then
objDropDownFrom.SelectedValue = GetSearchValueRange(objCustomField.CustomFieldID, True)
End If
Else
Dim objTextBoxFrom As New TextBox
objTextBoxFrom.CssClass = "NormalTextBox"
objTextBoxFrom.ID = "From" & objCustomField.CustomFieldID.ToString()
objTextBoxFrom.Width = Unit.Pixel(Me.PropertySettingsSearch.Width / 2)
objPlaceHolder.Add(objTextBoxFrom)
If (objCustomField.ValidationType <> CustomFieldValidationType.None) Then
Dim valCompare As New CompareValidator
valCompare.ControlToValidate = objTextBoxFrom.ID
Select Case objCustomField.ValidationType
Case CustomFieldValidationType.Currency
valCompare.Type = ValidationDataType.Integer
valCompare.Operator = ValidationCompareOperator.DataTypeCheck
valCompare.ErrorMessage = Localization.GetString("valValidateCurrency", Me.EditPropertyResourceFile)
Case CustomFieldValidationType.Date
valCompare.Type = ValidationDataType.Date
valCompare.Operator = ValidationCompareOperator.DataTypeCheck
valCompare.ErrorMessage = Localization.GetString("valValidateDate", Me.EditPropertyResourceFile)
Case CustomFieldValidationType.Double
valCompare.Type = ValidationDataType.Double
valCompare.Operator = ValidationCompareOperator.DataTypeCheck
valCompare.ErrorMessage = Localization.GetString("valValidateDecimal", Me.EditPropertyResourceFile)
Case CustomFieldValidationType.Integer
valCompare.Type = ValidationDataType.Integer
valCompare.Operator = ValidationCompareOperator.DataTypeCheck
valCompare.ErrorMessage = Localization.GetString("valValidateNumber", Me.EditPropertyResourceFile)
End Select
valCompare.CssClass = "NormalRed"
valCompare.Display = ValidatorDisplay.Dynamic
objPlaceHolder.Add(valCompare)
End If
objTextBoxFrom.Text = GetSearchValueRange(objCustomField.CustomFieldID, True)
End If
If (objCustomField.FieldElementsFrom = "" Or objCustomField.FieldElementsTo = "") Then
Dim objLabelTo As New Label
objLabelTo.CssClass = "Normal"
objLabelTo.Text = Localization.GetString("To", Me.EditPropertyResourceFile)
objPlaceHolder.Add(objLabelTo)
End If
If (objCustomField.FieldElementsTo <> "") Then
Dim objDropDownTo As New DropDownList
objDropDownTo.CssClass = "NormalTextBox"
objDropDownTo.ID = "To" & objCustomField.CustomFieldID.ToString()
Dim values As String() = objCustomField.FieldElementsTo.Split(Convert.ToChar("|"))
For Each value As String In values
Dim item As New ListItem
item.Value = value
item.Text = value
Select Case objCustomField.ValidationType
Case CustomFieldValidationType.Currency
Try
Dim culture As String = "en-US"
Select Case PropertySettings.Currency
Case CurrencyType.AUD
culture = "en-AU"
Exit Select
Case CurrencyType.BRL
culture = "pt-BR"
Exit Select
Case CurrencyType.CAD
culture = "en-CA"
Exit Select
Case CurrencyType.CHF
culture = "de-CH"
Exit Select
Case CurrencyType.CNY
culture = "zh-CN"
Exit Select
Case CurrencyType.CZK
culture = "cs-CZ"
Exit Select
Case CurrencyType.EUR
culture = "fr-FR"
Select Case PropertySettings.EuroType
Case EuroType.Dutch
culture = "nl-NL"
Exit Select
Case EuroType.English
culture = "en-IE"
Exit Select
Case EuroType.French
culture = "fr-FR"
Exit Select
End Select
Exit Select
Case CurrencyType.GBP
culture = "en-GB"
Exit Select
Case CurrencyType.JPY
culture = "ja-JP"
Exit Select
Case CurrencyType.USD
culture = "en-US"
Exit Select
Case CurrencyType.MYR
culture = "en-MY"
Exit Select
Case CurrencyType.NZD
culture = "en-NZ"
Exit Select
Case CurrencyType.NOK
culture = "nb-NO"
Exit Select
Case CurrencyType.THB
culture = "th-TH"
Exit Select
Case CurrencyType.ZAR
culture = "en-ZA"
Exit Select
End Select
Dim portalFormat As System.Globalization.CultureInfo = New System.Globalization.CultureInfo(culture)
Dim format As String = "{0:C" & PropertySettings.CurrencyDecimalPlaces.ToString() & "}"
item.Text = String.Format(portalFormat.NumberFormat, format, Double.Parse(value))
Catch
End Try
Case CustomFieldValidationType.Date
Try
item.Text = DateTime.Parse(value).ToShortDateString()
Catch
End Try
End Select