-
Notifications
You must be signed in to change notification settings - Fork 24
/
LatestArticles.ascx.vb
executable file
·1383 lines (1132 loc) · 71.8 KB
/
LatestArticles.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
'
' News Articles for DotNetNuke - http://www.dotnetnuke.com
' Copyright (c) 2005-2012
' 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.Services.Exceptions
Imports DotNetNuke.Services.Localization
Imports DotNetNuke.Security
Imports Ventrian.NewsArticles.Components.CustomFields
Imports Ventrian.NewsArticles.Base
Namespace Ventrian.NewsArticles
Partial Public Class LatestArticles
Inherits NewsArticleModuleBase
#Region " Controls "
Protected WithEvents rptLatestArticles As System.Web.UI.WebControls.Repeater
Protected WithEvents dlLatestArticles As System.Web.UI.WebControls.DataList
Protected WithEvents lblNotConfigured As System.Web.UI.WebControls.Label
#End Region
#Region " Private Members "
Private _objLayoutController As LayoutController
Private _objLayoutHeader As LayoutInfo
Private _objLayoutItem As LayoutInfo
Private _objLayoutFooter As LayoutInfo
Private _articleTabID As Integer = Null.NullInteger
Private _articleTabInfo As DotNetNuke.Entities.Tabs.TabInfo
Private _articleModuleID As Integer = Null.NullInteger
Private _rssLink As String = Null.NullString
Private _layoutMode As LayoutModeType
Private _pageNumber As Integer = 1
Private _serverTimeZone As Integer = Null.NullInteger
Private _articleSettings As ArticleSettings
Private _settings As Hashtable
#End Region
#Region " Private Properties "
Public Shadows ReadOnly Property ArticleSettings() As ArticleSettings
Get
If (_articleSettings Is Nothing) Then
Dim objModuleController As New ModuleController
Dim objModule As ModuleInfo = objModuleController.GetModule(_articleModuleID, _articleTabID)
_settings = objModule.ModuleSettings
If Not (objModule Is Nothing) Then
Dim objSettings As Hashtable = objModule.TabModuleSettings
For Each key As String In objSettings.Keys
If (_settings.ContainsKey(key) = False) Then
_settings.Add(key, objSettings(key))
End If
Next
End If
_articleSettings = New ArticleSettings(_settings, Me.PortalSettings, Me.ModuleConfiguration)
End If
Return _articleSettings
End Get
End Property
Private ReadOnly Property ArticleTabInfo() As DotNetNuke.Entities.Tabs.TabInfo
Get
If (_articleTabInfo Is Nothing) Then
Dim objTabController As New DotNetNuke.Entities.Tabs.TabController
_articleTabInfo = objTabController.GetTab(_articleTabID, Me.PortalId, False)
End If
Return _articleTabInfo
End Get
End Property
Private ReadOnly Property LatestAuthorID() As Integer
Get
Dim id As Integer = Null.NullInteger
If (Request("laauth-" & TabModuleId.ToString()) <> "") Then
If (IsNumeric(Request("laauth-" & TabModuleId.ToString()))) Then
id = Convert.ToInt32(Request("laauth-" & TabModuleId.ToString()))
End If
End If
Return id
End Get
End Property
Private ReadOnly Property CategoryID() As Integer
Get
Dim id As Integer = Null.NullInteger
If (Request("lacat-" & TabModuleId.ToString()) <> "") Then
If (IsNumeric(Request("lacat-" & TabModuleId.ToString()))) Then
id = Convert.ToInt32(Request("lacat-" & TabModuleId.ToString()))
End If
End If
Return id
End Get
End Property
Private Shadows ReadOnly Property ServerTimeZone() As Integer
Get
If (_serverTimeZone = Null.NullInteger) Then
_serverTimeZone = PortalSettings.TimeZone.GetUtcOffset(DateTime.Now).TotalHours
Dim objModuleSettingController As New ModuleController
Dim newsSettings As Hashtable = Common.GetModuleSettings(_articleModuleID)
If Not (newsSettings Is Nothing) Then
If (newsSettings.Contains(ArticleConstants.SERVER_TIMEZONE)) Then
If (IsNumeric(newsSettings(ArticleConstants.SERVER_TIMEZONE).ToString())) Then
_serverTimeZone = Convert.ToInt32(newsSettings(ArticleConstants.SERVER_TIMEZONE).ToString())
End If
End If
End If
End If
Return _serverTimeZone
End Get
End Property
Private ReadOnly Property SortBy() As String
Get
Dim sort As String = ArticleConstants.DEFAULT_SORT_BY
If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_SORT_BY)) Then
sort = Settings(ArticleConstants.LATEST_ARTICLES_SORT_BY).ToString()
End If
If (Request("lasort-" & TabModuleId.ToString()) <> "") Then
Select Case Request("lasort-" & TabModuleId.ToString()).ToLower()
Case "publishdate"
sort = "StartDate"
Exit Select
Case "expirydate"
sort = "EndDate"
Exit Select
Case "lastupdate"
sort = "LastUpdate"
Exit Select
Case "rating"
sort = "Rating DESC, RatingCount"
Exit Select
Case "commentcount"
sort = "CommentCount"
Exit Select
Case "numberofviews"
sort = "NumberOfViews"
Exit Select
Case "random"
sort = "NewID()"
Exit Select
Case "title"
sort = "Title"
Exit Select
End Select
End If
Return sort
End Get
End Property
Private ReadOnly Property StartPoint() As Integer
Get
If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_START_POINT)) Then
Return Convert.ToInt32(Settings(ArticleConstants.LATEST_ARTICLES_START_POINT).ToString())
Else
Return 0
End If
End Get
End Property
Private ReadOnly Property Time() As String
Get
Dim val As String = ""
If (Request("latime-" & TabModuleId.ToString()) <> "") Then
val = Request("latime-" & TabModuleId.ToString())
End If
Return val
End Get
End Property
#End Region
#Region " Private Methods "
Private Sub BindArticles()
Dim objArticleController As New ArticleController
_rssLink = "~/DesktopModules/DnnForge - NewsArticles/Rss.aspx?TabID=" & _articleTabID.ToString() & "&ModuleID=" & _articleModuleID.ToString()
Dim cats As Integer() = Nothing
Dim showRelated As Boolean = False
If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_SHOW_RELATED)) Then
showRelated = Convert.ToBoolean(Settings(ArticleConstants.LATEST_ARTICLES_SHOW_RELATED).ToString())
End If
If (showRelated And Request("CategoryID") <> "") Then
If (IsNumeric(Request("CategoryID"))) Then
Dim categories As New List(Of Integer)
categories.Add(Convert.ToInt32(Request("CategoryID")))
cats = categories.ToArray()
_rssLink = _rssLink & "&CategoryID=" & Request("CategoryID")
Else
showRelated = False
End If
End If
If (showRelated And (ArticleSettings.UrlModeType = Components.Types.UrlModeType.Classic) And Request("ArticleID") <> "") Then
If (IsNumeric(Request("ArticleID"))) Then
Dim categories As ArrayList = objArticleController.GetArticleCategories(Convert.ToInt32(Request("ArticleID")))
Dim categoriesRSS As String = ""
Dim categoriesList As New List(Of Integer)
For Each objCategory As CategoryInfo In categories
categoriesList.Add(objCategory.CategoryID)
If (categoriesRSS = "") Then
categoriesRSS = objCategory.CategoryID.ToString()
Else
categoriesRSS = categoriesRSS & "," & objCategory.CategoryID.ToString()
End If
Next
cats = categoriesList.ToArray()
If (categoriesList.Count > 0) Then
_rssLink = _rssLink & "&CategoryID=" & categoriesRSS
End If
End If
End If
If (showRelated And (ArticleSettings.UrlModeType = Components.Types.UrlModeType.Shorterned) And Request(ArticleSettings.ShortenedID) <> "") Then
If (IsNumeric(Request(ArticleSettings.ShortenedID))) Then
Dim categories As ArrayList = objArticleController.GetArticleCategories(Convert.ToInt32(Request(ArticleSettings.ShortenedID)))
Dim categoriesRSS As String = ""
Dim categoriesList As New List(Of Integer)
For Each objCategory As CategoryInfo In categories
categoriesList.Add(objCategory.CategoryID)
If (categoriesRSS = "") Then
categoriesRSS = objCategory.CategoryID.ToString()
Else
categoriesRSS = categoriesRSS & "," & objCategory.CategoryID.ToString()
End If
Next
cats = categoriesList.ToArray()
If (categoriesList.Count > 0) Then
_rssLink = _rssLink & "&CategoryID=" & categoriesRSS
End If
End If
End If
Dim catsExclude As Integer() = Nothing
If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_CATEGORIES_EXCLUDE)) Then
If Not (Settings(ArticleConstants.LATEST_ARTICLES_CATEGORIES_EXCLUDE).ToString = Null.NullString Or Settings(ArticleConstants.LATEST_ARTICLES_CATEGORIES_EXCLUDE).ToString = "-1") Then
Dim categories As String() = Settings(ArticleConstants.LATEST_ARTICLES_CATEGORIES_EXCLUDE).ToString().Split(Char.Parse(","))
Dim categoriesToExclude(categories.Length - 1) As Integer
For i As Integer = 0 To categories.Length - 1
categoriesToExclude(i) = Convert.ToInt32(categories(i))
Next
If (categories.Length > 0) Then
_rssLink = _rssLink & "&CategoryIDExclude=" & Settings(ArticleConstants.LATEST_ARTICLES_CATEGORIES_EXCLUDE).ToString()
End If
catsExclude = categoriesToExclude
End If
End If
Dim objCategoryController As CategoryController = New CategoryController
Dim objCategories As List(Of CategoryInfo) = objCategoryController.GetCategoriesAll(_articleModuleID, Null.NullInteger, ArticleSettings.CategorySortType)
Dim excludeCategoriesRestrictive As New List(Of Integer)
For Each objCategory As CategoryInfo In objCategories
If (objCategory.InheritSecurity = False And objCategory.CategorySecurityType = CategorySecurityType.Restrict) Then
If (Request.IsAuthenticated) Then
If (_settings.Contains(objCategory.CategoryID & "-" & ArticleConstants.PERMISSION_CATEGORY_VIEW_SETTING)) Then
If (PortalSecurity.IsInRoles(_settings(objCategory.CategoryID & "-" & ArticleConstants.PERMISSION_CATEGORY_VIEW_SETTING).ToString()) = False) Then
excludeCategoriesRestrictive.Add(objCategory.CategoryID)
End If
End If
Else
excludeCategoriesRestrictive.Add(objCategory.CategoryID)
End If
End If
Next
If (catsExclude Is Nothing) Then
If (excludeCategoriesRestrictive.Count > 0) Then
catsExclude = excludeCategoriesRestrictive.ToArray()
End If
End If
Dim excludeCategories As New List(Of Integer)
If (catsExclude Is Nothing) Then
For Each objCategory As CategoryInfo In objCategories
If (objCategory.InheritSecurity = False) Then
If (Request.IsAuthenticated) Then
If (_settings.Contains(objCategory.CategoryID & "-" & ArticleConstants.PERMISSION_CATEGORY_VIEW_SETTING)) Then
If (PortalSecurity.IsInRoles(_settings(objCategory.CategoryID & "-" & ArticleConstants.PERMISSION_CATEGORY_VIEW_SETTING).ToString()) = False) Then
excludeCategories.Add(objCategory.CategoryID)
End If
End If
Else
excludeCategories.Add(objCategory.CategoryID)
End If
End If
Next
End If
If (showRelated = False) Then
If (CategoryID = Null.NullInteger) Then
If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_CATEGORIES)) Then
If Not (Settings(ArticleConstants.LATEST_ARTICLES_CATEGORIES).ToString = Null.NullString Or Settings(ArticleConstants.LATEST_ARTICLES_CATEGORIES).ToString = "-1") Then
Dim categories As String() = Settings(ArticleConstants.LATEST_ARTICLES_CATEGORIES).ToString().Split(Char.Parse(","))
Dim categoriesToDisplay(categories.Length - 1) As Integer
For i As Integer = 0 To categories.Length - 1
categoriesToDisplay(i) = Convert.ToInt32(categories(i))
Next
If (categories.Length > 0) Then
_rssLink = _rssLink & "&CategoryID=" & Settings(ArticleConstants.LATEST_ARTICLES_CATEGORIES).ToString()
End If
cats = categoriesToDisplay
Else
If (excludeCategories.Count > 0) Then
Dim includeCategories As New List(Of Integer)
For Each objCategoryToInclude As CategoryInfo In objCategories
Dim includeCategory As Boolean = True
For Each exclCategory As Integer In excludeCategories
If (exclCategory = objCategoryToInclude.CategoryID) Then
includeCategory = False
End If
Next
If (includeCategory) Then
includeCategories.Add(objCategoryToInclude.CategoryID)
End If
Next
cats = includeCategories.ToArray()
End If
End If
Else
If (excludeCategories.Count > 0) Then
Dim includeCategories As New List(Of Integer)
For Each objCategoryToInclude As CategoryInfo In objCategories
Dim includeCategory As Boolean = True
For Each exclCategory As Integer In excludeCategories
If (exclCategory = objCategoryToInclude.CategoryID) Then
includeCategory = False
End If
Next
If (includeCategory) Then
includeCategories.Add(objCategoryToInclude.CategoryID)
End If
Next
If (includeCategories.Count > 0) Then
includeCategories.Add(-1)
End If
cats = includeCategories.ToArray()
End If
End If
Else
Dim categoriesToDisplay(1) As Integer
categoriesToDisplay(1) = CategoryID
cats = categoriesToDisplay
_rssLink = _rssLink & "&CategoryID=" & CategoryID.ToString()
End If
End If
Dim matchOperator As MatchOperatorType = MatchOperatorType.MatchAny
If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_MATCH_OPERATOR)) Then
matchOperator = CType(System.Enum.Parse(GetType(MatchOperatorType), Settings(ArticleConstants.LATEST_ARTICLES_MATCH_OPERATOR).ToString()), MatchOperatorType)
End If
Dim matchAll As Boolean = False
If (matchOperator = MatchOperatorType.MatchAll) Then
matchAll = True
_rssLink = _rssLink & "&MatchCat=1"
End If
Dim count As Integer = 10
If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_COUNT)) Then
count = Convert.ToInt32(Settings(ArticleConstants.LATEST_ARTICLES_COUNT).ToString())
End If
_rssLink = _rssLink & "&MaxCount=" & count.ToString()
Dim maxAge As Integer = Null.NullInteger
If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_MAX_AGE)) Then
If (Settings(ArticleConstants.LATEST_ARTICLES_MAX_AGE).ToString() <> "") Then
maxAge = Convert.ToInt32(Settings(ArticleConstants.LATEST_ARTICLES_MAX_AGE).ToString()) * -1
End If
End If
Dim featuredOnly As Boolean = False
If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_FEATURED_ONLY)) Then
featuredOnly = Convert.ToBoolean(Settings(ArticleConstants.LATEST_ARTICLES_FEATURED_ONLY).ToString())
End If
If (featuredOnly) Then
_rssLink = _rssLink & "&FeaturedOnly=" & featuredOnly.ToString()
End If
Dim notFeaturedOnly As Boolean = False
If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_NOT_FEATURED_ONLY)) Then
notFeaturedOnly = Convert.ToBoolean(Settings(ArticleConstants.LATEST_ARTICLES_NOT_FEATURED_ONLY).ToString())
End If
If (notFeaturedOnly) Then
_rssLink = _rssLink & "&NotFeaturedOnly=" & notFeaturedOnly.ToString()
End If
Dim securedOnly As Boolean = False
If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_SECURED_ONLY)) Then
securedOnly = Convert.ToBoolean(Settings(ArticleConstants.LATEST_ARTICLES_SECURED_ONLY).ToString())
End If
If (securedOnly) Then
_rssLink = _rssLink & "&SecuredOnly=" & securedOnly.ToString()
End If
Dim notSecuredOnly As Boolean = False
If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_NOT_SECURED_ONLY)) Then
notSecuredOnly = Convert.ToBoolean(Settings(ArticleConstants.LATEST_ARTICLES_NOT_SECURED_ONLY).ToString())
End If
If (notFeaturedOnly) Then
_rssLink = _rssLink & "&NotSecuredOnly=" & notSecuredOnly.ToString()
End If
Dim sort As String = SortBy
_rssLink = _rssLink & "&sortBy=" & sort
Dim sortDirection As String = ArticleConstants.DEFAULT_SORT_DIRECTION
If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_SORT_DIRECTION)) Then
sortDirection = Settings(ArticleConstants.LATEST_ARTICLES_SORT_DIRECTION).ToString()
End If
If (sort = "Title" And Request("lasort-" & TabModuleId.ToString()) <> "") Then
sortDirection = "ASC"
End If
If (sort <> "Title" And Request("lasort-" & TabModuleId.ToString()) <> "") Then
sortDirection = "DESC"
End If
_rssLink = _rssLink & "&sortDirection=" & sortDirection
_layoutMode = ArticleConstants.LATEST_ARTICLES_LAYOUT_MODE_DEFAULT
If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_LAYOUT_MODE)) Then
_layoutMode = CType(System.Enum.Parse(GetType(LayoutModeType), Settings(ArticleConstants.LATEST_ARTICLES_LAYOUT_MODE).ToString()), LayoutModeType)
End If
Dim itemsPerRow As Integer = ArticleConstants.LATEST_ARTICLES_ITEMS_PER_ROW_DEFAULT
If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_ITEMS_PER_ROW)) Then
itemsPerRow = Convert.ToInt32(Settings(ArticleConstants.LATEST_ARTICLES_ITEMS_PER_ROW).ToString())
End If
Dim showPending As Boolean = False
If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_SHOW_PENDING)) Then
showPending = Convert.ToBoolean(Settings(ArticleConstants.LATEST_ARTICLES_SHOW_PENDING).ToString())
End If
Dim authorID As Integer = ArticleConstants.LATEST_ARTICLES_AUTHOR_DEFAULT
If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_AUTHOR)) Then
authorID = Convert.ToInt32(Settings(ArticleConstants.LATEST_ARTICLES_AUTHOR).ToString())
End If
Dim userIDFilter As String = ""
If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_QUERY_STRING_FILTER) And Settings.Contains(ArticleConstants.LATEST_ARTICLES_QUERY_STRING_PARAM)) Then
If (Convert.ToBoolean(Settings(ArticleConstants.LATEST_ARTICLES_QUERY_STRING_FILTER).ToString())) Then
authorID = -100
Dim param As String = Settings(ArticleConstants.LATEST_ARTICLES_QUERY_STRING_PARAM).ToString()
If (param <> "") Then
If (Request.QueryString(param) <> "" AndAlso IsNumeric(Request.QueryString(param))) Then
userIDFilter = param & "=" & Request.QueryString(param)
authorID = Convert.ToInt32(Request(param))
End If
End If
End If
End If
Dim usernameFilter As String = ""
If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_USERNAME_FILTER) And Settings.Contains(ArticleConstants.LATEST_ARTICLES_USERNAME_PARAM)) Then
If (Convert.ToBoolean(Settings(ArticleConstants.LATEST_ARTICLES_USERNAME_FILTER).ToString())) Then
authorID = -100
Dim param As String = Settings(ArticleConstants.LATEST_ARTICLES_USERNAME_PARAM).ToString()
If (param <> "") Then
If (Request.QueryString(param) <> "") Then
usernameFilter = param & "=" & Request.QueryString(param)
Dim objUser As DotNetNuke.Entities.Users.UserInfo = DotNetNuke.Entities.Users.UserController.GetUserByName(Me.PortalId, Request.QueryString(param))
If (objUser IsNot Nothing) Then
authorID = objUser.UserID
End If
End If
End If
End If
End If
If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_LOGGED_IN_USER_FILTER)) Then
If (Convert.ToBoolean(Settings(ArticleConstants.LATEST_ARTICLES_LOGGED_IN_USER_FILTER).ToString())) Then
authorID = -100
If (Request.IsAuthenticated) Then
authorID = Me.UserId
End If
End If
End If
If (authorID = Null.NullInteger) Then
authorID = LatestAuthorID
End If
Dim startDate As DateTime = DateTime.Now
If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_START_DATE)) Then
If (Settings(ArticleConstants.LATEST_ARTICLES_START_DATE).ToString() <> "") Then
startDate = Convert.ToDateTime(Settings(ArticleConstants.LATEST_ARTICLES_START_DATE).ToString())
End If
End If
Dim bubbleFeatured As Boolean = False
If (Settings.Contains(ArticleConstants.BUBBLE_FEATURED_ARTICLES)) Then
bubbleFeatured = Convert.ToBoolean(Settings(ArticleConstants.BUBBLE_FEATURED_ARTICLES).ToString())
If (bubbleFeatured) Then
sort = "IsFeatured DESC, " & sort
End If
End If
Dim articleIDs As String = ""
If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_IDS)) Then
If (Settings(ArticleConstants.LATEST_ARTICLES_IDS).ToString() <> "") Then
_rssLink = _rssLink & "&ArticleIDs=" & Settings(ArticleConstants.LATEST_ARTICLES_IDS).ToString()
articleIDs = Settings(ArticleConstants.LATEST_ARTICLES_IDS).ToString()
End If
End If
Dim agedDate As DateTime = Null.NullDate
If (maxAge <> Null.NullInteger) Then
If (startDate = Null.NullDate) Then
agedDate = DateTime.Now.AddDays(maxAge)
Else
agedDate = startDate.AddDays(maxAge)
End If
Else
If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_MAX_AGE)) Then
If (Settings(ArticleConstants.LATEST_ARTICLES_MAX_AGE).ToString() = "1") Then
agedDate = startDate.AddDays(-1)
End If
End If
End If
If (Time <> "") Then
If (Time.ToLower() = "today") Then
startDate = DateTime.Now
agedDate = DateTime.Today
End If
If (Time.ToLower() = "yesterday") Then
startDate = DateTime.Today
agedDate = DateTime.Today.AddDays(-1)
End If
If (Time.ToLower() = "threedays") Then
startDate = DateTime.Now
agedDate = DateTime.Today.AddDays(-3)
End If
If (Time.ToLower() = "sevendays") Then
startDate = DateTime.Now
agedDate = DateTime.Today.AddDays(-7)
End If
If (Time.ToLower() = "thirtydays") Then
startDate = DateTime.Now
agedDate = DateTime.Today.AddDays(-30)
End If
If (Time.ToLower() = "ninetydays") Then
startDate = DateTime.Now
agedDate = DateTime.Today.AddDays(-90)
End If
If (Time.ToLower() = "thisyear") Then
startDate = DateTime.Now
agedDate = DateTime.Today.AddYears(-1)
End If
End If
Dim tagIDs() As Integer = Nothing
If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_TAGS)) Then
Dim objTags As New List(Of Integer)
Dim objTagController As New TagController
Dim tags As String = Settings(ArticleConstants.LATEST_ARTICLES_TAGS).ToString()
If (tags <> "") Then
For Each tag As String In tags.Split(","c)
objTags.Add(Convert.ToInt32(tag))
Next
If (objTags.Count > 0) Then
tagIDs = objTags.ToArray()
Dim rssTags As String = ""
For Each tagID As Integer In tagIDs
If (rssTags = "") Then
rssTags = tagID.ToString()
Else
rssTags = rssTags & "," & tagID.ToString()
End If
Next
If (rssTags <> "") Then
_rssLink = _rssLink & "&TagIDs=" & rssTags
End If
End If
End If
End If
Dim matchOperatorTags As MatchOperatorType = MatchOperatorType.MatchAny
If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_TAGS_MATCH_OPERATOR)) Then
matchOperatorTags = CType(System.Enum.Parse(GetType(MatchOperatorType), Settings(ArticleConstants.LATEST_ARTICLES_TAGS_MATCH_OPERATOR).ToString()), MatchOperatorType)
End If
Dim matchAllTags As Boolean = False
If (tagIDs IsNot Nothing) Then
If (matchOperatorTags = MatchOperatorType.MatchAll) Then
matchAllTags = True
_rssLink = _rssLink & "&MatchTag=1"
End If
End If
Dim customFieldID As Integer = Null.NullInteger
Dim customValue As String = Null.NullString
If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_CUSTOM_FIELD_FILTER) And Settings.Contains(ArticleConstants.LATEST_ARTICLES_CUSTOM_FIELD_VALUE)) Then
If (IsNumeric(Settings(ArticleConstants.LATEST_ARTICLES_CUSTOM_FIELD_FILTER).ToString())) Then
customFieldID = Convert.ToInt32(Settings(ArticleConstants.LATEST_ARTICLES_CUSTOM_FIELD_FILTER).ToString())
End If
customValue = Settings(ArticleConstants.LATEST_ARTICLES_CUSTOM_FIELD_VALUE).ToString()
End If
Dim linkFilter As String = Null.NullString
If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_LINK_FILTER)) Then
linkFilter = Settings(ArticleConstants.LATEST_ARTICLES_LINK_FILTER).ToString()
End If
If (Request("lacust-" & Me.TabModuleId.ToString()) <> "") Then
Dim val As String = Request("lacust-" & Me.TabModuleId.ToString())
If (val.Split("-"c).Length = 2) Then
If (IsNumeric(val.Split("-"c)(0))) Then
customFieldID = Convert.ToInt32(val.Split("-"c)(0))
customValue = val.Split("-"c)(1)
End If
End If
End If
Dim doPaging As Boolean = False
If (Settings.Contains(ArticleConstants.LATEST_ENABLE_PAGER)) Then
doPaging = Convert.ToBoolean(Settings(ArticleConstants.LATEST_ENABLE_PAGER).ToString())
End If
Dim pageSize As Integer = count
If (doPaging) Then
If (Settings.Contains(ArticleConstants.LATEST_PAGE_SIZE)) Then
pageSize = Convert.ToInt32(Settings(ArticleConstants.LATEST_PAGE_SIZE).ToString())
Else
pageSize = ArticleConstants.LATEST_PAGE_SIZE_DEFAULT
End If
End If
Dim objModuleController As New ModuleController()
Dim objModule As ModuleInfo = objModuleController.GetModule(_articleModuleID, _articleTabID)
' _objLayoutController = New LayoutController(PortalSettings, ArticleSettings, Page, Me.IsEditable, _articleTabID, _articleModuleID, Me.TabModuleId, Me.PortalId, Null.NullInteger, Me.UserId, Me.ModuleKey)
_objLayoutController = New LayoutController(PortalSettings, ArticleSettings, objModule, Page)
Dim objLatestLayoutController As New LatestLayoutController()
_objLayoutHeader = objLatestLayoutController.GetLayout(LatestLayoutType.Listing_Header_Html, ModuleId, Settings)
_objLayoutItem = objLatestLayoutController.GetLayout(LatestLayoutType.Listing_Item_Html, ModuleId, Settings)
_objLayoutFooter = objLatestLayoutController.GetLayout(LatestLayoutType.Listing_Footer_Html, ModuleId, Settings)
Dim articleCount As Integer = 0
Dim objArticles As List(Of ArticleInfo) = objArticleController.GetArticleList(_articleModuleID, startDate, agedDate, cats, matchAll, catsExclude, count, _pageNumber, pageSize, sort, sortDirection, True, False, Null.NullString, authorID, showPending, False, featuredOnly, notFeaturedOnly, securedOnly, notSecuredOnly, articleIDs, tagIDs, matchAllTags, Null.NullString, customFieldID, customValue, linkFilter, articleCount)
If (count < articleCount) Then
articleCount = count
End If
If (_layoutMode = LayoutModeType.Simple) Then
rptLatestArticles.DataSource = objArticles
rptLatestArticles.DataBind()
rptLatestArticles.Visible = (objArticles.Count > 0)
Else
dlLatestArticles.RepeatColumns = itemsPerRow
dlLatestArticles.DataSource = objArticles
dlLatestArticles.DataBind()
dlLatestArticles.Visible = (objArticles.Count > 0)
End If
Dim pageCount As Integer = ((articleCount - 1) \ pageSize) + 1
If ((objArticles.Count > 0) AndAlso pageCount > 1) Then
ctlPagingControl.Visible = True
ctlPagingControl.PageParam = "lapg-" & Me.TabModuleId.ToString()
Dim params As New List(Of String)
If (userIDFilter <> "") Then
params.Add(userIDFilter)
End If
If (usernameFilter <> "") Then
params.Add(usernameFilter)
End If
If (Request("lasort-" & TabModuleId.ToString()) <> "") Then
params.Add("lasort-" & TabModuleId.ToString() & "=" & Request("lasort-" & TabModuleId.ToString()))
End If
If (Request("laauth-" & TabModuleId.ToString()) <> "") Then
params.Add("laauth-" & TabModuleId.ToString() & "=" & Request("laauth-" & TabModuleId.ToString()))
End If
If (Request("lacat-" & TabModuleId.ToString()) <> "") Then
params.Add("lacat-" & TabModuleId.ToString() & "=" & Request("lacat-" & TabModuleId.ToString()))
End If
If (Request("lacust-" & TabModuleId.ToString()) <> "") Then
params.Add("lacust-" & TabModuleId.ToString() & "=" & Request("lacust-" & TabModuleId.ToString()))
End If
If (Request("latime-" & TabModuleId.ToString()) <> "") Then
params.Add("latime-" & TabModuleId.ToString() & "=" & Request("latime-" & TabModuleId.ToString()))
End If
For Each item As String In params
If (ctlPagingControl.QuerystringParams <> "") Then
ctlPagingControl.QuerystringParams = ctlPagingControl.QuerystringParams & "&" & item
Else
ctlPagingControl.QuerystringParams = item
End If
Next
ctlPagingControl.TotalRecords = articleCount
ctlPagingControl.PageSize = pageSize
ctlPagingControl.CurrentPage = _pageNumber
ctlPagingControl.TabID = TabId
ctlPagingControl.EnableViewState = False
End If
If (objArticles.Count = 0) Then
Dim objNoArticles As LayoutInfo = objLatestLayoutController.GetLayout(LatestLayoutType.Listing_Empty_Html, ModuleId, Settings)
ProcessHeaderFooter(phNoArticles.Controls, objNoArticles.Tokens)
End If
End Sub
Private Function FindSettings() As Boolean
If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_TAB_ID)) Then
If (IsNumeric(Settings(ArticleConstants.LATEST_ARTICLES_TAB_ID).ToString())) Then
_articleTabID = Convert.ToInt32(Settings(ArticleConstants.LATEST_ARTICLES_TAB_ID).ToString())
End If
End If
If (Settings.Contains(ArticleConstants.LATEST_ARTICLES_MODULE_ID)) Then
If (IsNumeric(Settings(ArticleConstants.LATEST_ARTICLES_MODULE_ID).ToString())) Then
_articleModuleID = Convert.ToInt32(Settings(ArticleConstants.LATEST_ARTICLES_MODULE_ID).ToString())
If (_articleModuleID <> Null.NullInteger) Then
Return True
End If
End If
End If
Return False
End Function
Private Sub ProcessHeaderFooter(ByRef controls As ControlCollection, ByVal layoutArray As String())
Dim moduleKey As String = "la-" & Me.TabModuleId.ToString() & "-Header-"
For iPtr As Integer = 0 To layoutArray.Length - 1 Step 2
controls.Add(New LiteralControl(layoutArray(iPtr).ToString()))
If iPtr < layoutArray.Length - 1 Then
Select Case layoutArray(iPtr + 1)
Case "AUTHOR"
Dim objAuthorController As New AuthorController()
Dim drpAuthor As New DropDownList
drpAuthor.ID = Globals.CreateValidID(moduleKey & "-" & iPtr.ToString())
drpAuthor.DataTextField = "DisplayName"
drpAuthor.DataValueField = "UserID"
drpAuthor.DataSource = objAuthorController.GetAuthorList(_articleModuleID)
drpAuthor.DataBind()
drpAuthor.Items.Insert(0, New ListItem(Localization.GetString("SelectAuthor", Me.LocalResourceFile), "-1"))
drpAuthor.AutoPostBack = True
If (LatestAuthorID <> Null.NullInteger) Then
If (drpAuthor.Items.FindByValue(LatestAuthorID.ToString()) IsNot Nothing) Then
drpAuthor.SelectedValue = LatestAuthorID.ToString()
End If
End If
Dim objHandler As New System.EventHandler(AddressOf drpAuthor_SelectedIndexChanged)
AddHandler drpAuthor.SelectedIndexChanged, objHandler
controls.Add(drpAuthor)
Case "CATEGORY"
Dim objCategoryController As New CategoryController()
Dim drpCategory As New DropDownList
drpCategory.ID = Globals.CreateValidID(moduleKey & "-" & iPtr.ToString())
drpCategory.DataTextField = "NameIndented"
drpCategory.DataValueField = "CategoryID"
drpCategory.DataSource = objCategoryController.GetCategoriesAll(_articleModuleID, Null.NullInteger, _articleSettings.CategorySortType)
drpCategory.DataBind()
drpCategory.Items.Insert(0, New ListItem(Localization.GetString("SelectCategory", Me.LocalResourceFile), "-1"))
drpCategory.AutoPostBack = True
If (CategoryID <> Null.NullInteger) Then
If (drpCategory.Items.FindByValue(CategoryID.ToString()) IsNot Nothing) Then
drpCategory.SelectedValue = CategoryID.ToString()
End If
End If
Dim objHandler As New System.EventHandler(AddressOf drpCategory_SelectedIndexChanged)
AddHandler drpCategory.SelectedIndexChanged, objHandler
controls.Add(drpCategory)
Case "RSSLINK"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID(moduleKey & "-" & iPtr.ToString())
objLiteral.Text = Me.ResolveUrl(_rssLink)
controls.Add(objLiteral)
Case "SORT"
Dim drpSort As New DropDownList
drpSort.ID = Globals.CreateValidID(moduleKey & "-" & iPtr.ToString())
drpSort.Items.Add(New ListItem(Localization.GetString("PublishDate.Text", Me.LocalResourceFile), "PublishDate"))
drpSort.Items.Add(New ListItem(Localization.GetString("ExpiryDate.Text", Me.LocalResourceFile), "ExpiryDate"))
drpSort.Items.Add(New ListItem(Localization.GetString("LastUpdate.Text", Me.LocalResourceFile), "LastUpdate"))
drpSort.Items.Add(New ListItem(Localization.GetString("HighestRated.Text", Me.LocalResourceFile), "Rating"))
drpSort.Items.Add(New ListItem(Localization.GetString("MostCommented.Text", Me.LocalResourceFile), "CommentCount"))
drpSort.Items.Add(New ListItem(Localization.GetString("MostViewed.Text", Me.LocalResourceFile), "NumberOfViews"))
drpSort.Items.Add(New ListItem(Localization.GetString("Random.Text", Me.LocalResourceFile), "Random"))
drpSort.Items.Add(New ListItem(Localization.GetString("SortTitle.Text", Me.LocalResourceFile), "Title"))
drpSort.AutoPostBack = True
If (Request("lasort-" & TabModuleId.ToString()) <> "") Then
If (drpSort.Items.FindByValue(Request("lasort-" & TabModuleId.ToString())) IsNot Nothing) Then
drpSort.SelectedValue = Request("lasort-" & TabModuleId.ToString())
End If
Else
Dim sort As String = SortBy
Select Case SortBy.ToLower()
Case "startdate"
sort = "PublishDate"
Exit Select
Case "enddate"
sort = "ExpiryDate"
Exit Select
Case "newid()"
sort = "random"
Exit Select
End Select
If (drpSort.Items.FindByValue(sort) IsNot Nothing) Then
drpSort.SelectedValue = sort
End If
End If
Dim objHandler As New System.EventHandler(AddressOf drpSort_SelectedIndexChanged)
AddHandler drpSort.SelectedIndexChanged, objHandler
controls.Add(drpSort)
Case "TIME"
Dim drpTime As New DropDownList
drpTime.ID = Globals.CreateValidID(moduleKey & "-" & iPtr.ToString())
drpTime.Items.Add(New ListItem(Localization.GetString("Today", Me.LocalResourceFile), "Today"))
drpTime.Items.Add(New ListItem(Localization.GetString("Yesterday", Me.LocalResourceFile), "Yesterday"))
drpTime.Items.Add(New ListItem(Localization.GetString("ThreeDays", Me.LocalResourceFile), "ThreeDays"))
drpTime.Items.Add(New ListItem(Localization.GetString("SevenDays", Me.LocalResourceFile), "SevenDays"))
drpTime.Items.Add(New ListItem(Localization.GetString("ThirtyDays", Me.LocalResourceFile), "ThirtyDays"))
drpTime.Items.Add(New ListItem(Localization.GetString("NinetyDays", Me.LocalResourceFile), "NinetyDays"))
drpTime.Items.Add(New ListItem(Localization.GetString("ThisYear", Me.LocalResourceFile), "ThisYear"))
drpTime.Items.Add(New ListItem(Localization.GetString("AllTime", Me.LocalResourceFile), "AllTime"))
drpTime.AutoPostBack = True
If (Time <> "") Then
If (drpTime.Items.FindByValue(Time) IsNot Nothing) Then
drpTime.SelectedValue = Time
End If
Else
drpTime.SelectedValue = "AllTime"
End If
Dim objHandler As New System.EventHandler(AddressOf drpTime_SelectedIndexChanged)
AddHandler drpTime.SelectedIndexChanged, objHandler
controls.Add(drpTime)
Case Else
If (layoutArray(iPtr + 1).ToUpper().StartsWith("CUSTOM:")) Then
Dim customField As String = layoutArray(iPtr + 1).Substring(7, layoutArray(iPtr + 1).Length - 7)
Dim objCustomFieldController As New CustomFieldController()
Dim objCustomFields As ArrayList = objCustomFieldController.List(_articleModuleID)
For Each objCustomField As CustomFieldInfo In objCustomFields
If (objCustomField.Name.ToLower() = customField.ToLower()) Then
If (objCustomField.FieldType = CustomFieldType.DropDownList) Then
Dim drpCustom As New DropDownList
drpCustom.ID = Globals.CreateValidID(moduleKey & "-" & iPtr.ToString())
For Each val As String In objCustomField.FieldElements.Split("|"c)
drpCustom.Items.Add(val)
Next
Dim sel As String = Localization.GetString("SelectCustom", Me.LocalResourceFile)
If (sel.IndexOf("{0}") <> -1) Then
sel = sel.Replace("{0}", objCustomField.Caption)
End If
drpCustom.Items.Insert(0, New ListItem(sel, "-1"))
drpCustom.Attributes.Add("CustomFieldID", objCustomField.CustomFieldID.ToString())
drpCustom.AutoPostBack = True
If (Request("lacust-" & TabModuleId.ToString()) <> "") Then
Dim val As String = Request("lacust-" & TabModuleId.ToString())
If (val.Split("-"c).Length = 2) Then
If (val.Split("-"c)(0) = objCustomField.CustomFieldID.ToString()) Then
If (drpCustom.Items.FindByValue(val.Split("-"c)(1).ToString()) IsNot Nothing) Then
drpCustom.SelectedValue = val.Split("-"c)(1).ToString()
End If
End If
End If
End If
Dim objHandler As New System.EventHandler(AddressOf drpCustom_SelectedIndexChanged)
AddHandler drpCustom.SelectedIndexChanged, objHandler
controls.Add(drpCustom)
End If
Exit For
End If
Next
Exit Select
End If
If (layoutArray(iPtr + 1).ToUpper().StartsWith("SORT:")) Then
Dim params As New List(Of String)
Dim sortItem As String = layoutArray(iPtr + 1).Substring(5, layoutArray(iPtr + 1).Length - 5)
Dim sortValue As String = sortItem
Select Case sortItem.ToLower()
Case "highestrated"
sortValue = "Rating"
Exit Select
Case "mostcommented"
sortValue = "CommentCount"
Exit Select
Case "mostviewed"
sortValue = "NumberOfViews"
Exit Select
Case "sorttitle"
sortValue = "Title"
Exit Select
End Select
Dim sort As String = SortBy
Select Case sort.ToLower()
Case "startdate"
sort = "PublishDate"
Exit Select
Case "enddate"