-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathViewType.ascx.vb
executable file
·1430 lines (1155 loc) · 74.7 KB
/
ViewType.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.Services.Exceptions
Imports DotNetNuke.Services.Localization
Imports DotNetNuke.Security
Imports Ventrian.PropertyAgent.Mapping
Imports System.Globalization
Namespace Ventrian.PropertyAgent
Partial Public Class ViewType
Inherits PropertyAgentBase
#Region " Private Members "
Private _agentType As String = Null.NullString
Private _agentFilter As String = Null.NullString
Private _currentPage As Integer = 1
Private _pageRecords As Integer = 10
Private _propertyTypeID As Integer = Null.NullInteger
Private _propertyAgentID As Integer = Null.NullInteger
Private _propertyAgentName As String = Null.NullInteger
Private _propertyBrokerID As Integer = Null.NullInteger
Private _location As String = Null.NullString
Private _layoutController As LayoutController
Private _objLayout As LayoutInfo
Private _objLayoutAlternating As LayoutInfo
Private _objLayoutHeader As LayoutInfo
Private _objLayoutFooter As LayoutInfo
Private _objLayoutSeparator As LayoutInfo
Private _objLayoutSearch As LayoutInfo
Private _objLayoutSearchHeader As LayoutInfo
Private _objLayoutSearchFooter As LayoutInfo
Private _objLayoutType As LayoutInfo
Private _objLayoutTypeHeader As LayoutInfo
Private _objLayoutTypeFooter As LayoutInfo
Private _objLayoutTypeTitle As LayoutInfo
Private _objLayoutTypeDescription As LayoutInfo
Private _objLayoutTypeKeyword As LayoutInfo
Private _objLayoutTypePageHead As LayoutInfo
Private _objMessage As LayoutInfo
Private _objProperties As List(Of PropertyInfo)
Private _totalRecords As Integer = 0
Private _customFieldIDs As String = Null.NullString
Private _searchValues As String = Null.NullString
Private _sortBy As String = ""
Private _sortDirection As String = ""
#End Region
#Region " Private Properties "
Private ReadOnly Property SortBy() As SortByType
Get
Try
If (drpSortBy.SelectedValue.StartsWith("cf")) Then
Return SortByType.CustomField
Else
If (drpSortBy.SelectedValue.StartsWith("rf")) Then
Return SortByType.ReviewField
Else
Return CType(System.Enum.Parse(GetType(SortByType), drpSortBy.SelectedValue), SortByType)
End If
End If
Catch
Return Me.PropertySettings.ListingSortBy
End Try
End Get
End Property
Private ReadOnly Property SortByCustomField() As Integer
Get
Try
If (SortBy = SortByType.CustomField Or SortBy = SortByType.ReviewField) Then
Return Convert.ToInt32(drpSortBy.SelectedValue.Replace("cf", "").Replace("rf", ""))
End If
Catch
Return Me.PropertySettings.ListingSortByCustomField
End Try
End Get
End Property
Private ReadOnly Property SortDirection() As SortDirectionType
Get
Try
Return CType(System.Enum.Parse(GetType(SortDirectionType), drpSortDirection.SelectedValue), SortDirectionType)
Catch
Return Me.PropertySettings.ListingSortDirection
End Try
End Get
End Property
#End Region
#Region " Private Methods "
Private Function OnlyAlphaNumericChars(ByVal OrigString As String) As String
'***********************************************************
'INPUT: Any String
'OUTPUT: The Input String with all non-alphanumeric characters
' removed
'EXAMPLE Debug.Print OnlyAlphaNumericChars("Hello World!")
'output = "HelloWorld")
'NOTES: Not optimized for speed and will run slow on long
' strings. If you plan on using long strings, consider
' using alternative method of appending to output string,
' such as the method at
' http://www.freevbcode.com/ShowCode.Asp?ID=154
'***********************************************************
Dim lLen As Integer
Dim sAns As String = ""
Dim lCtr As Integer
Dim sChar As String
OrigString = RemoveDiacritics(Trim(OrigString))
lLen = Len(OrigString)
For lCtr = 1 To lLen
sChar = Mid(OrigString, lCtr, 1)
If IsAlphaNumeric(Mid(OrigString, lCtr, 1)) Or Mid(OrigString, lCtr, 1) = "-" Or Mid(OrigString, lCtr, 1) = "_" Then
sAns = sAns & sChar
End If
Next
If (PropertySettings.SEOTitleReplacement = TitleReplacementType.Dash) Then
OnlyAlphaNumericChars = Replace(sAns, " ", "-")
Else
OnlyAlphaNumericChars = Replace(sAns, " ", "_")
End If
End Function
Private Function RemoveDiacritics(ByVal s As String) As String
s = s.Normalize(System.Text.NormalizationForm.FormD)
Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder()
Dim i As Integer
For i = 0 To s.Length - 1
If s(i) = ChrW(305) Then
sb.Append("i"c)
Else
If CharUnicodeInfo.GetUnicodeCategory(s(i)) <> UnicodeCategory.NonSpacingMark Then
sb.Append(s(i))
End If
End If
Next
Return sb.ToString()
End Function
Private Function IsAlphaNumeric(ByVal sChr As String) As Boolean
IsAlphaNumeric = sChr Like "[0-9A-Za-z ]"
End Function
Private Sub ReadQueryString()
Dim agentTypeParam As String = PropertySettings.SEOAgentType
If (Request(agentTypeParam) = "") Then
agentTypeParam = "agentType"
End If
If Not (Request(agentTypeParam) Is Nothing) Then
_agentType = Request(agentTypeParam)
End If
Dim propertyTypeIDParam As String = PropertySettings.SEOPropertyTypeID
If (Request(propertyTypeIDParam) = "") Then
propertyTypeIDParam = "PropertyTypeID"
End If
If Not (Request(propertyTypeIDParam) Is Nothing) Then
Integer.TryParse(Request(propertyTypeIDParam), _propertyTypeID)
If (_propertyTypeID = 0) Then
Response.Redirect(NavigateURL(Me.TabId), True)
End If
End If
If Not (Request("AgentFilter") Is Nothing) Then
_agentFilter = Server.UrlDecode(Request("AgentFilter"))
End If
If Not (Request("PropertyAgentID") Is Nothing) Then
_propertyAgentID = Convert.ToInt32(Request("PropertyAgentID"))
End If
If Not (Request("PropertyAgentName") Is Nothing) Then
_propertyAgentName = Request("PropertyAgentName")
End If
If Not (Request("PropertyBrokerID") Is Nothing) Then
_propertyBrokerID = Convert.ToInt32(Request("PropertyBrokerID"))
End If
If Not (Request("Location") Is Nothing) Then
_location = Server.UrlDecode(Request("Location"))
End If
If Not (Request("CurrentPage") Is Nothing) Then
_currentPage = Convert.ToInt32(Request("CurrentPage"))
End If
If Not (Request("CustomFieldIDs") Is Nothing) Then
_customFieldIDs = Request("CustomFieldIDs").Trim()
End If
If Not (Request("SearchValues") Is Nothing) Then
_searchValues = Request("SearchValues").Trim()
End If
If Not (Request("sortBy") Is Nothing) Then
_sortBy = Request("sortBy").Trim()
End If
If Not (Request("sortDir") Is Nothing) Then
_sortDirection = Request("sortDir").Trim()
End If
_pageRecords = Me.PropertySettings.ListingItemsPerPage
End Sub
Private Sub InitializeTemplate()
_layoutController = New LayoutController(Me.PortalSettings, Me.PropertySettings, Me.Page, Me, Me.IsEditable, Me.TabId, Me.ModuleId, Me.ModuleKey)
_objLayout = _layoutController.GetLayout(Me.PropertySettings.Template, LayoutType.Listing_Item_Html)
_objLayoutAlternating = _layoutController.GetLayout(Me.PropertySettings.Template, LayoutType.Listing_Alternate_Html)
_objLayoutHeader = _layoutController.GetLayout(Me.PropertySettings.Template, LayoutType.Listing_Header_Html)
_objLayoutFooter = _layoutController.GetLayout(Me.PropertySettings.Template, LayoutType.Listing_Footer_Html)
_objLayoutSeparator = _layoutController.GetLayout(Me.PropertySettings.Template, LayoutType.Listing_Separator_Html)
_objLayoutSearch = _layoutController.GetLayout(Me.PropertySettings.Template, LayoutType.Search_Item_Html)
_objLayoutSearchHeader = _layoutController.GetLayout(Me.PropertySettings.Template, LayoutType.Search_Header_Html)
_objLayoutSearchFooter = _layoutController.GetLayout(Me.PropertySettings.Template, LayoutType.Search_Footer_Html)
_objLayoutType = _layoutController.GetLayout(Me.PropertySettings.Template, LayoutType.Type_Item_Html)
_objLayoutTypeHeader = _layoutController.GetLayout(Me.PropertySettings.Template, LayoutType.Type_Header_Html)
_objLayoutTypeFooter = _layoutController.GetLayout(Me.PropertySettings.Template, LayoutType.Type_Footer_Html)
_objLayoutTypeTitle = _layoutController.GetLayout(Me.PropertySettings.Template, LayoutType.Type_PageTitle_Html)
_objLayoutTypeDescription = _layoutController.GetLayout(Me.PropertySettings.Template, LayoutType.Type_PageDescription_Html)
_objLayoutTypeKeyword = _layoutController.GetLayout(Me.PropertySettings.Template, LayoutType.Type_PageKeyword_Html)
_objLayoutTypePageHead = _layoutController.GetLayout(Me.PropertySettings.Template, LayoutType.Type_PageHeader_Html)
_objMessage = _layoutController.GetLayout(Me.PropertySettings.Template, LayoutType.Message_Item_Html)
End Sub
Private Sub InitializeStylesheet()
_layoutController.LoadStyleSheet(Me.PropertySettings.Template)
End Sub
Private Sub BindSortBy()
If (PropertySettings.ListingSortFields <> "") Then
For Each value As Integer In System.Enum.GetValues(GetType(SortByType))
Dim objSortByType As SortByType = CType(System.Enum.Parse(GetType(SortByType), value.ToString()), SortByType)
If (objSortByType = SortByType.CustomField) Then
For Each item As String In PropertySettings.ListingSortFields.Split(","c)
If (item = System.Enum.GetName(GetType(SortByType), value)) Then
Dim objCustomFieldController As New CustomFieldController
Dim objCustomFields As List(Of CustomFieldInfo) = objCustomFieldController.List(Me.ModuleId, True)
For Each objCustomField As CustomFieldInfo In objCustomFields
If (objCustomField.IsSortable) Then
Dim li As New ListItem
li.Value = "cf" & objCustomField.CustomFieldID.ToString()
li.Text = objCustomField.Caption
drpSortBy.Items.Add(li)
End If
Next
End If
Next
Else
If (objSortByType = SortByType.ReviewField) Then
Dim objReviewFieldController As New ReviewFieldController
Dim objReviewFields As List(Of ReviewFieldInfo) = objReviewFieldController.List(Me.ModuleId)
For Each objReviewField As ReviewFieldInfo In objReviewFields
If (objReviewField.FieldType = ReviewFieldType.Rating) Then
Dim li As New ListItem
li.Value = "rf" & objReviewField.ReviewFieldID.ToString()
li.Text = objReviewField.Caption
drpSortBy.Items.Add(li)
End If
Next
Else
For Each item As String In PropertySettings.ListingSortFields.Split(","c)
If (item = System.Enum.GetName(GetType(SortByType), value)) Then
Dim li As New ListItem
li.Value = System.Enum.GetName(GetType(SortByType), value)
li.Text = Localization.GetString(System.Enum.GetName(GetType(SortByType), value), Me.LocalResourceFile)
drpSortBy.Items.Add(li)
End If
Next
End If
End If
Next
If (_sortBy <> "") Then
Dim objSortBy As SortByType = Me.PropertySettings.ListingSortBy
If (_sortBy.StartsWith("cf")) Then
objSortBy = SortByType.CustomField
If Not (drpSortBy.Items.FindByValue(_sortBy) Is Nothing) Then
drpSortBy.SelectedValue = _sortBy
End If
Else
If (_sortBy.StartsWith("rf")) Then
objSortBy = SortByType.CustomField
If Not (drpSortBy.Items.FindByValue(_sortBy) Is Nothing) Then
drpSortBy.SelectedValue = _sortBy
End If
Else
objSortBy = CType(System.Enum.Parse(GetType(SortByType), _sortBy, True), SortByType)
If Not (drpSortBy.Items.FindByValue(objSortBy.ToString) Is Nothing) Then
drpSortBy.SelectedValue = objSortBy.ToString
End If
End If
End If
Else
If (Me.PropertySettings.ListingSortBy <> SortByType.CustomField And Me.PropertySettings.ListingSortBy <> SortByType.ReviewField) Then
If Not (drpSortBy.Items.FindByValue(Me.PropertySettings.ListingSortBy.ToString()) Is Nothing) Then
drpSortBy.SelectedValue = Me.PropertySettings.ListingSortBy.ToString()
Else
For Each value As Integer In System.Enum.GetValues(GetType(SortByType))
If (Me.PropertySettings.ListingSortBy.ToString() = System.Enum.GetName(GetType(SortByType), value)) Then
Dim li As New ListItem
li.Value = System.Enum.GetName(GetType(SortByType), value)
li.Text = Localization.GetString(System.Enum.GetName(GetType(SortByType), value), Me.LocalResourceFile)
li.Selected = True
drpSortBy.Items.Add(li)
End If
Next
End If
Else
If (Me.PropertySettings.ListingSortBy = SortByType.CustomField) Then
If Not (drpSortBy.Items.FindByValue("cf" & Me.PropertySettings.ListingSortByCustomField.ToString()) Is Nothing) Then
drpSortBy.SelectedValue = "cf" & Me.PropertySettings.ListingSortByCustomField.ToString()
Else
' Sort by value not shown, now add it.
Dim objCustomFieldController As New CustomFieldController
Dim objCustomField As CustomFieldInfo = objCustomFieldController.Get(Convert.ToInt32(Me.PropertySettings.ListingSortByCustomField.ToString()))
If (objCustomField IsNot Nothing) Then
If (objCustomField.IsSortable) Then
Dim li As New ListItem
li.Value = "cf" & objCustomField.CustomFieldID.ToString()
li.Text = objCustomField.Caption
li.Selected = True
drpSortBy.Items.Add(li)
End If
End If
End If
End If
If (Me.PropertySettings.ListingSortBy = SortByType.ReviewField) Then
If Not (drpSortBy.Items.FindByValue("rf" & Me.PropertySettings.ListingSortByCustomField.ToString()) Is Nothing) Then
drpSortBy.SelectedValue = "rf" & Me.PropertySettings.ListingSortByCustomField.ToString()
Else
' Sort by value not shown, now add it.
Dim objReviewFieldController As New ReviewFieldController
Dim objReviewField As ReviewFieldInfo = objReviewFieldController.Get(Convert.ToInt32(Me.PropertySettings.ListingSortByCustomField.ToString()))
If (objReviewField IsNot Nothing) Then
Dim li As New ListItem
li.Value = "rf" & objReviewField.ReviewFieldID.ToString()
li.Text = objReviewField.Caption
li.Selected = True
drpSortBy.Items.Add(li)
End If
End If
End If
End If
End If
End If
End Sub
Private Sub BindSortDirection()
For Each value As Integer In System.Enum.GetValues(GetType(SortDirectionType))
Dim li As New ListItem
li.Value = System.Enum.GetName(GetType(SortDirectionType), value)
li.Text = Localization.GetString(System.Enum.GetName(GetType(SortDirectionType), value), Me.LocalResourceFile)
If (value = SortDirectionType.Descending) Then
li.Selected = True
End If
drpSortDirection.Items.Add(li)
Next
If (_sortDirection <> "") Then
Dim objSortDirection As SortDirectionType = CType(System.Enum.Parse(GetType(SortDirectionType), _sortDirection, True), SortDirectionType)
If Not (drpSortDirection.Items.FindByValue(objSortDirection.ToString()) Is Nothing) Then
drpSortDirection.SelectedValue = objSortDirection.ToString()
Else
If Not (drpSortDirection.Items.FindByValue(Me.PropertySettings.ListingSortDirection.ToString()) Is Nothing) Then
drpSortDirection.SelectedValue = Me.PropertySettings.ListingSortDirection.ToString()
End If
End If
Else
If Not (drpSortDirection.Items.FindByValue(Me.PropertySettings.ListingSortDirection.ToString()) Is Nothing) Then
drpSortDirection.SelectedValue = Me.PropertySettings.ListingSortDirection.ToString()
End If
End If
End Sub
Private Sub BindProperty()
Dim crumbs As New ArrayList
Dim objCrumbMain As New CrumbInfo
objCrumbMain.Caption = PropertySettings.MainLabel
objCrumbMain.Url = NavigateURL()
crumbs.Add(objCrumbMain)
Dim showMessage As Boolean = True
Select Case _agentType.ToLower()
Case "viewfeatured"
Dim objCrumbFeatured As New CrumbInfo
objCrumbFeatured.Caption = Localization.GetString("Featured", Me.LocalResourceFile)
objCrumbFeatured.Url = NavigateURL(Me.TabId, "", PropertySettings.SEOAgentType & "=" & _agentType)
crumbs.Add(objCrumbFeatured)
Case "viewsearch"
Dim objCrumbSearch As New CrumbInfo
objCrumbSearch.Caption = Localization.GetString("SearchResults", Me.LocalResourceFile)
objCrumbSearch.Url = GetListingUrl(_currentPage)
crumbs.Add(objCrumbSearch)
Case "viewtype"
Dim objPropertyTypeController As New PropertyTypeController
Dim objPropertyType As PropertyTypeInfo = objPropertyTypeController.Get(Me.ModuleId, _propertyTypeID)
If Not (objPropertyType Is Nothing) Then
Dim sortByParam As String = Null.NullString
Dim sortDirParam As String = Null.NullString
If (Me.PropertySettings.ListingUserSortable) Then
If (SortBy <> Me.PropertySettings.ListingSortBy) Then
sortByParam = drpSortBy.SelectedValue
End If
End If
If (SortDirection <> Me.PropertySettings.ListingSortDirection) Then
sortDirParam = drpSortDirection.SelectedValue
End If
Dim typeUrl As String = ""
If (_currentPage = Null.NullInteger Or _currentPage = 1) Then
typeUrl = _layoutController.GetExternalLink(_layoutController.GetTypeLink(Me.TabId, Me.ModuleId, objPropertyType, "", Null.NullInteger, sortByParam, sortDirParam))
Else
typeUrl = _layoutController.GetExternalLink(_layoutController.GetTypeLink(Me.TabId, Me.ModuleId, objPropertyType, "", _currentPage, sortByParam, sortDirParam))
End If
If (PropertySettings.SEORedirect) Then
If (typeUrl.ToLower() <> _layoutController.GetExternalLink(Request.RawUrl).ToLower()) Then
Response.Status = "301 Moved Permanently"
Response.AddHeader("Location", typeUrl)
Response.End()
End If
End If
Dim parentID As Integer = objPropertyType.ParentID
Do
Dim objCrumbType As New CrumbInfo
objCrumbType.Caption = objPropertyType.Name
objCrumbType.Url = _layoutController.GetExternalLink(_layoutController.GetTypeLink(Me.TabId, Me.ModuleId, objPropertyType, "", Null.NullInteger))
If (_propertyTypeID = objPropertyType.PropertyTypeID) Then
crumbs.Add(objCrumbType)
Else
crumbs.Insert(1, objCrumbType)
End If
objPropertyType = objPropertyTypeController.Get(Me.ModuleId, objPropertyType.ParentID)
If (objPropertyType Is Nothing) Then
parentID = Null.NullInteger
Else
parentID = objPropertyType.PropertyTypeID
End If
Loop While (parentID <> Null.NullInteger)
End If
Dim objPropertyTypes As List(Of PropertyTypeInfo) = objPropertyTypeController.List(Me.ModuleId, True, PropertySettings.TypesSortBy, Null.NullString(), _propertyTypeID)
Dim objTypesSelected As New List(Of PropertyTypeInfo)
For Each objType As PropertyTypeInfo In objPropertyTypes
If (PropertySettings.TypesHideZero) Then
If (objType.PropertyCount > 0) Then
objTypesSelected.Add(objType)
End If
Else
objTypesSelected.Add(objType)
End If
Next
If (objTypesSelected.Count > 0) Then
showMessage = False
ProcessHeaderFooter(phProperty.Controls, _objLayoutTypeHeader.Tokens)
If (PropertySettings.ListingLayoutType = LatestLayoutType.TableLayout) Then
Dim objDataList As New System.Web.UI.WebControls.DataList
Dim objHandler As New DataListItemEventHandler(AddressOf dlTypes_ItemDataBound)
AddHandler objDataList.ItemDataBound, objHandler
objDataList.CellPadding = 0
objDataList.CellSpacing = 0
objDataList.RepeatColumns = Me.PropertySettings.TypesItemsPerRow
objDataList.RepeatDirection = Me.PropertySettings.TypesRepeatDirection
objDataList.DataSource = objTypesSelected
objDataList.DataBind()
phProperty.Controls.Add(objDataList)
Else
Dim objRepeater As New System.Web.UI.WebControls.Repeater
Dim objHandler As New RepeaterItemEventHandler(AddressOf rptTypes_ItemDataBound)
AddHandler objRepeater.ItemDataBound, objHandler
objRepeater.DataSource = objTypesSelected
objRepeater.DataBind()
phProperty.Controls.Add(objRepeater)
End If
ProcessHeaderFooter(phProperty.Controls, _objLayoutTypeFooter.Tokens)
Else
ProcessHeaderFooter(phProperty.Controls, _objLayoutTypeHeader.Tokens)
End If
End Select
If (PropertySettings.BreadcrumbPlacement = BreadcrumbType.Portal) Then
For i As Integer = 0 To crumbs.Count - 1
Dim objCrumb As CrumbInfo = crumbs(i)
If (i > 0) Then
Dim objTab As New DotNetNuke.Entities.Tabs.TabInfo
objTab.TabID = -8888 + i
objTab.TabName = objCrumb.Caption
objTab.Url = objCrumb.Url
PortalSettings.ActiveTab.BreadCrumbs.Add(objTab)
End If
Next
End If
If (PropertySettings.BreadcrumbPlacement = BreadcrumbType.Module) Then
rptBreadCrumbs.DataSource = crumbs
rptBreadCrumbs.DataBind()
End If
Dim latitude As Double = Null.NullDouble
Dim longitude As Double = Null.NullDouble
If (_location <> "") Then
Dim objGeoCodeInfo As GeocodeInfo = Geocoder.GeoCode(_location, PropertySettings)
If (objGeoCodeInfo.Latitude <> 0 And objGeoCodeInfo.Longitude <> 0) Then
latitude = objGeoCodeInfo.Latitude
longitude = objGeoCodeInfo.Longitude
End If
End If
If (SortBy = SortByType.Distance And latitude = Null.NullDouble And longitude = Null.NullDouble) Then
Dim objGeoCodeInfo As GeocodeInfo = UserGeoLocator.GetUserLocation(Request.UserHostAddress)
If (objGeoCodeInfo IsNot Nothing) Then
latitude = objGeoCodeInfo.Latitude
longitude = objGeoCodeInfo.Longitude
End If
End If
Dim objPropertyController As New PropertyController
Dim OnlyForAuthenticated As Boolean = Null.NullBoolean
If Me.UserId = -1 Then OnlyForAuthenticated = True
Select Case _agentType.ToLower()
Case "viewfeatured"
divSearch.Visible = False
_objProperties = objPropertyController.List(Me.ModuleId, Null.NullInteger, SearchStatusType.PublishedActive, Null.NullInteger, Null.NullInteger, True, OnlyForAuthenticated, SortBy, SortByCustomField, SortDirection, PropertySettings.ListingSortBy2, PropertySettings.ListingSortByCustomField2, PropertySettings.ListingSortDirection2, PropertySettings.ListingSortBy3, PropertySettings.ListingSortByCustomField3, PropertySettings.ListingSortDirection3, Null.NullString, Null.NullString, _currentPage - 1, _pageRecords, _totalRecords, False, False, Null.NullInteger, Null.NullInteger, latitude, longitude, Null.NullDate, Null.NullString, Null.NullInteger)
Case "viewsearch"
If (SortBy = SortByType.Distance And latitude = Null.NullDouble And longitude = Null.NullDouble) Then
divSearch.Visible = False
divExport.Visible = False
lnkExport.Visible = False
_layoutController.ProcessMessage(phProperty.Controls, _objMessage.Tokens, Localization.GetString("DistanceSortError.Text", Me.LocalResourceFile))
Return
End If
If (_customFieldIDs.Trim() <> "" And _searchValues.Trim() <> "") Then
divSearch.Visible = True
lnkSearchAgain.NavigateUrl = NavigateURL(Me.TabId)
If (_customFieldIDs.Trim() <> "" And _searchValues.Trim() <> "") Or _propertyAgentID <> Null.NullInteger Or _propertyBrokerID <> Null.NullInteger Then
lnkNarrowThisSearch.NavigateUrl = NavigateURL(Me.TabId, "", GetAdditionalParams("", 1, ""))
Else
lnkNarrowThisSearch.Visible = False
End If
Else
divSearch.Visible = False
End If
If _propertyAgentName <> "-1" Then
_propertyAgentID = 0
Dim objAgentController As New AgentController(PortalSettings, PropertySettings, PortalId)
Dim arrAgents As ArrayList
arrAgents = objAgentController.ListActive(PortalId, ModuleId)
For Each Agent As DotNetNuke.Entities.Users.UserInfo In arrAgents
If Agent.Username = _propertyAgentName Then
_propertyAgentID = Agent.UserID
Exit For
End If
Next
'Dim TheAgent As New DotNetNuke.Entities.Users.UserInfo
'TheAgent = Array.Find(TheAgent, Function(c As DotNetNuke.Entities.Users.UserInfo) c.Username = _propertyAgentName)
End If
_objProperties = objPropertyController.List(Me.ModuleId, _propertyTypeID, SearchStatusType.PublishedActive, _propertyAgentID, _propertyBrokerID, False, OnlyForAuthenticated, SortBy, SortByCustomField, SortDirection, PropertySettings.ListingSortBy2, PropertySettings.ListingSortByCustomField2, PropertySettings.ListingSortDirection2, PropertySettings.ListingSortBy3, PropertySettings.ListingSortByCustomField3, PropertySettings.ListingSortDirection3, _customFieldIDs, _searchValues, _currentPage - 1, _pageRecords, _totalRecords, PropertySettings.ListingBubbleFeatured, True, Null.NullInteger, Null.NullInteger, latitude, longitude, Null.NullDate, Null.NullString, Null.NullInteger)
Case "viewtype"
divSearch.Visible = False
_objProperties = objPropertyController.List(Me.ModuleId, _propertyTypeID, SearchStatusType.PublishedActive, Null.NullInteger, Null.NullInteger, False, OnlyForAuthenticated, SortBy, SortByCustomField, SortDirection, PropertySettings.ListingSortBy2, PropertySettings.ListingSortByCustomField2, PropertySettings.ListingSortDirection2, PropertySettings.ListingSortBy3, PropertySettings.ListingSortByCustomField3, PropertySettings.ListingSortDirection3, Null.NullString, Null.NullString, _currentPage - 1, _pageRecords, _totalRecords, PropertySettings.ListingBubbleFeatured, Me.PropertySettings.ListingSearchSubTypes, Null.NullInteger, Null.NullInteger, latitude, longitude, Null.NullDate, _agentFilter, Null.NullInteger)
Case Else
If (SortBy = SortByType.Distance And latitude = Null.NullDouble And longitude = Null.NullDouble) Then
divSearch.Visible = False
divExport.Visible = False
lnkExport.Visible = False
_layoutController.ProcessMessage(phProperty.Controls, _objMessage.Tokens, Localization.GetString("DistanceSortError.Text", Me.LocalResourceFile))
Return
End If
divSearch.Visible = (PropertySettings.LandingPageMode = LandingPageType.Standard)
lnkSearchAgain.NavigateUrl = NavigateURL(Me.TabId)
If (_customFieldIDs.Trim() <> "" And _searchValues.Trim() <> "") Or _propertyAgentID <> Null.NullInteger Or _propertyBrokerID <> Null.NullInteger Then
lnkNarrowThisSearch.NavigateUrl = NavigateURL(Me.TabId, "", GetAdditionalParams("", 1, ""))
Else
lnkNarrowThisSearch.Visible = False
End If
_objProperties = objPropertyController.List(Me.ModuleId, _propertyTypeID, SearchStatusType.PublishedActive, _propertyAgentID, _propertyBrokerID, False, OnlyForAuthenticated, SortBy, SortByCustomField, SortDirection, PropertySettings.ListingSortBy2, PropertySettings.ListingSortByCustomField2, PropertySettings.ListingSortDirection2, PropertySettings.ListingSortBy3, PropertySettings.ListingSortByCustomField3, PropertySettings.ListingSortDirection3, _customFieldIDs, _searchValues, _currentPage - 1, _pageRecords, _totalRecords, PropertySettings.ListingBubbleFeatured, True, Null.NullInteger, Null.NullInteger, latitude, longitude, Null.NullDate, Null.NullString, Null.NullInteger)
End Select
lnkExport.NavigateUrl = NavigateURL(Me.TabId, "", GetAdditionalParams("Export", 1, ""))
If (PropertySettings.RssEnable) Then
If (_agentType.ToLower() = "viewtype") Then
Dim objPropertyTypeController As New PropertyTypeController
Dim objPropertyType As PropertyTypeInfo = objPropertyTypeController.Get(Me.ModuleId, _propertyTypeID)
If Not (objPropertyType Is Nothing) Then
HttpContext.Current.Items.Add("RSS-PropertyAgent", NavigateURL(Me.TabId, "", GetAdditionalParams("rss", 1, PropertySettings.RssTitleType(objPropertyType.Name, True))))
HttpContext.Current.Items.Add("RSS-PropertyAgent-Title", PropertySettings.RssTitleType(objPropertyType.Name, True))
Else
HttpContext.Current.Items.Add("RSS-PropertyAgent", NavigateURL(Me.TabId, "", GetAdditionalParams("rss", 1, "")))
HttpContext.Current.Items.Add("RSS-PropertyAgent-Title", PropertySettings.RssTitleType("", True))
End If
Else
HttpContext.Current.Items.Add("RSS-PropertyAgent", NavigateURL(Me.TabId, "", GetAdditionalParams("rss", 1, PropertySettings.RssTitleSearchResult(True))))
HttpContext.Current.Items.Add("RSS-PropertyAgent-Title", PropertySettings.RssTitleSearchResult(True))
End If
End If
If (_objProperties.Count > 0) Then
If (PropertySettings.ListingLayoutType = LatestLayoutType.TableLayout) Then
dlProperty.RepeatColumns = Me.PropertySettings.ListingItemsPerRow
dlProperty.RepeatDirection = RepeatDirection.Horizontal
dlProperty.DataSource = _objProperties
dlProperty.DataBind()
Else
rptProperty.DataSource = _objProperties
rptProperty.DataBind()
End If
Else
divSort.Visible = False
If (showMessage) Then
_layoutController.ProcessMessage(phProperty.Controls, _objMessage.Tokens, Localization.GetString("NoResults", Me.LocalResourceFile))
End If
End If
End Sub
Private Sub ProcessSearch(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 "SEARCH"
Dim objSearch As PropertyAgent.Search = CType(Me.LoadControl("Search.ascx"), PropertyAgent.Search)
objPlaceHolder.Add(objSearch)
End Select
End If
Next
End Sub
Private Sub ProcessHeaderFooter(ByRef objPlaceHolder As ControlCollection, ByVal layoutArray As String())
Dim hostSettings As Dictionary(Of String, String) = DotNetNuke.Entities.Controllers.HostController.Instance.GetSettingsDictionary()
Dim searchValueQuery As String = ""
Dim customFieldIDsQuery As String = ""
If (_searchValues <> "") Then
searchValueQuery = "SearchValues=" & _searchValues
End If
If (_customFieldIDs <> "") Then
customFieldIDsQuery = "CustomFieldIDs=" & _customFieldIDs
End If
For iPtr As Integer = 0 To layoutArray.Length - 1 Step 2
objPlaceHolder.Add(New LiteralControl(layoutArray(iPtr).ToString()))
Dim value As Double = CDbl(_totalRecords) / CDbl(_pageRecords)
Dim count As Integer = Fix(value - (value \ 1 <> value))
If iPtr < layoutArray.Length - 1 Then
Select Case layoutArray(iPtr + 1)
Case "QUADRA-APERTA"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID("PropertyAgent-Header" & "-" & iPtr.ToString())
objLiteral.Text = "["
objPlaceHolder.Add(objLiteral)
Case "QUADRA-CHIUSA"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID("PropertyAgent-Header" & "-" & iPtr.ToString())
objLiteral.Text = "]"
objPlaceHolder.Add(objLiteral)
Case "CURRENTPAGE"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID("PropertyAgent-Header" & "-" & iPtr.ToString())
objLiteral.Text = (_currentPage).ToString()
objPlaceHolder.Add(objLiteral)
Case "HASMULTIPLEPAGES"
If (_totalRecords <= _pageRecords) Then
While (iPtr < layoutArray.Length - 1)
If (layoutArray(iPtr + 1) = "/HASMULTIPLEPAGES") Then
Exit While
End If
iPtr = iPtr + 1
End While
End If
Case "/HASMULTIPLEPAGES"
' Do Nothing
Case "HASPAGING"
If (_totalRecords <= _pageRecords) Then
While (iPtr < layoutArray.Length - 1)
If (layoutArray(iPtr + 1) = "/HASPAGING") Then
Exit While
End If
iPtr = iPtr + 1
End While
End If
Case "/HASPAGING"
' Do Nothing
Case "HASNEXTPAGE"
If (_currentPage = count) Then
While (iPtr < layoutArray.Length - 1)
If (layoutArray(iPtr + 1) = "/HASNEXTPAGE") Then
Exit While
End If
iPtr = iPtr + 1
End While
End If
Case "/HASNEXTPAGE"
' Do Nothing
Case "HASPREVPAGE"
If (_currentPage = 1) Then
While (iPtr < layoutArray.Length - 1)
If (layoutArray(iPtr + 1) = "/HASPREVPAGE") Then
Exit While
End If
iPtr = iPtr + 1
End While
End If
Case "/HASPREVPAGE"
' Do Nothing
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
Case "HASTYPE"
If (_agentType.ToLower() <> "viewtype") Then
While (iPtr < layoutArray.Length - 1)
If (layoutArray(iPtr + 1) = "/HASTYPE") Then
Exit While
End If
iPtr = iPtr + 1
End While
End If
Case "/HASTYPE"
' Do Nothing
Case "LINKFIRST"
Dim objLink As New HyperLink
objLink.ID = Globals.CreateValidID("PropertyAgent-Header" & "-" & iPtr.ToString())
objLink.CssClass = "CommandButton"
objLink.Enabled = Not (_currentPage = 1)
objLink.NavigateUrl = GetListingUrl(1)
objLink.Text = Localization.GetString("First", Me.LocalResourceFile)
objPlaceHolder.Add(objLink)
Case "LINKLAST"
Dim objLink As New HyperLink
objLink.ID = Globals.CreateValidID("PropertyAgent-Header" & "-" & iPtr.ToString())
objLink.CssClass = "CommandButton"
objLink.Enabled = Not (_currentPage = count)
objLink.NavigateUrl = GetListingUrl(count)
objLink.Text = Localization.GetString("Last", Me.LocalResourceFile)
objPlaceHolder.Add(objLink)
Case "LINKNEXT"
Dim objLink As New HyperLink
objLink.ID = Globals.CreateValidID("PropertyAgent-Header" & "-" & iPtr.ToString())
objLink.CssClass = "CommandButton"
objLink.Enabled = Not (_currentPage = count)
objLink.NavigateUrl = GetListingUrl(_currentPage + 1)
objLink.Text = Localization.GetString("Next", Me.LocalResourceFile)
objPlaceHolder.Add(objLink)
Case "LINKPREVIOUS"
Dim objLink As New HyperLink
objLink.ID = Globals.CreateValidID("PropertyAgent-Header" & "-" & iPtr.ToString())
objLink.CssClass = "CommandButton"
objLink.Enabled = Not (_currentPage = 1)
objLink.NavigateUrl = GetListingUrl(_currentPage - 1)
objLink.Text = Localization.GetString("Previous", Me.LocalResourceFile)
objPlaceHolder.Add(objLink)
Case "LINKXML"
Dim objLiteral As New Literal
objLiteral.Text = GetXmlUrl()
objPlaceHolder.Add(objLiteral)
Case "MARKERS"
Dim objLiteral As New Literal
objLiteral.Text = "var paItems = [" & vbCrLf
Dim bAdded As Boolean = False
Dim i As Integer = 1
For Each objProperty As PropertyInfo In _objProperties
If (objProperty.Latitude <> Null.NullDouble And objProperty.Longitude <> Null.NullDouble) Then
Dim objCustomFieldController As New CustomFieldController()
Dim objCustomFields As List(Of CustomFieldInfo) = objCustomFieldController.List(ModuleId, True)
Dim fields As String = ""
For Each objCustomField As CustomFieldInfo In objCustomFields
If (fields = "") Then
fields = ",'" & objProperty.PropertyList(objCustomField.CustomFieldID).ToString() & "'"
Else
fields = fields & ",'" & objProperty.PropertyList(objCustomField.CustomFieldID).ToString() & "'"
End If
Next
objLiteral.Text = objLiteral.Text & "[" & objProperty.Latitude.ToString() & "," & objProperty.Longitude.ToString() & "," & i.ToString() & fields & "]," & vbCrLf
bAdded = True
i = i + 1
End If
Next
objLiteral.Text = objLiteral.Text & vbCrLf _
& "];"
If (bAdded) Then
objPlaceHolder.Add(objLiteral)
End If
Case "PAGECOUNT"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID("PropertyAgent-Header" & "-" & iPtr.ToString())
objLiteral.Text = count.ToString()
objPlaceHolder.Add(objLiteral)
Case "PAGER"
If (count > 1) Then
Dim ctlPagingControl As New Ventrian.PropertyAgent.PagingControl
ctlPagingControl.Visible = True
ctlPagingControl.TotalRecords = _totalRecords
ctlPagingControl.PageSize = _pageRecords
ctlPagingControl.CurrentPage = _currentPage
ctlPagingControl.PageParam = "currentpage"
Dim params() As String = GetAdditionalParams(_agentType, _currentPage, "")
For Each param As String In params
If (param.ToLower().StartsWith("currentpage") = False) Then
If (ctlPagingControl.QuerystringParams <> "") Then
ctlPagingControl.QuerystringParams += "&" & param
Else
ctlPagingControl.QuerystringParams = param
End If
End If
Next
ctlPagingControl.TabID = TabId
ctlPagingControl.EnableViewState = False
ctlPagingControl.Title = "Default.aspx"
If (Request(PropertySettings.SEOAgentType) <> "") Then
If (Request(PropertySettings.SEOAgentType).ToLower() = "viewtype") Then
If (PropertySettings.SEOViewTypeTitle <> "") Then
If hostSettings("UseFriendlyUrls") = "Y" Then
If (PropertySettings.SEOViewTypeTitle <> "") Then
Dim objTypeController As New PropertyTypeController()
Dim objType As PropertyTypeInfo = objTypeController.Get(Me.ModuleId, _propertyTypeID)
If (objType IsNot Nothing) Then
Dim delimStr As String = "[]"
Dim delimiter As Char() = delimStr.ToCharArray()
Dim phPageTitle As New PlaceHolder()
_layoutController.ProcessType(phPageTitle.Controls, PropertySettings.SEOViewTypeTitle.Split(delimiter), objType, Null.NullString)
Dim title As String = OnlyAlphaNumericChars(RenderControlToString(phPageTitle))
If (title Is Nothing OrElse title.Trim() = "") Then
ctlPagingControl.Title = "Default.aspx"
Else
ctlPagingControl.Title = title.Replace("--", "-") & ".aspx"
End If
End If
End If
End If
End If
End If
End If
objPlaceHolder.Add(ctlPagingControl)
End If
Case "PAGES"
For i As Integer = 1 To count
Dim objLink As New HyperLink
objLink.ID = Globals.CreateValidID("PropertyAgent-Header" & "-" & iPtr.ToString() & "-" & i.ToString())
objLink.CssClass = "CommandButton"
If (i <> _currentPage) Then
objLink.Text = i.ToString()
objLink.Enabled = True
objLink.NavigateUrl = GetListingUrl(i)
Else
objLink.Text = "[" & i.ToString() & "]"
objLink.Enabled = False
End If
objPlaceHolder.Add(objLink)
If (i < count) Then
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID("PropertyAgent-Header" & "-" & iPtr.ToString() & "-spacer-" & i.ToString())
objLiteral.Text = " "
objPlaceHolder.Add(objLiteral)
End If
Next