forked from ventrian/News-Articles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NewsArchives.ascx.vb
executable file
·843 lines (650 loc) · 40.2 KB
/
NewsArchives.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
'
' News Articles for DotNetNuke - http://www.dotnetnuke.com
' Copyright (c) 2005-2012
' by Ventrian ( sales@ventrian.com ) ( http://www.ventrian.com )
'
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Security
Imports DotNetNuke.Entities.Users
Imports Ventrian.NewsArticles.Base
Namespace Ventrian.NewsArticles
Partial Public Class NewsArchives
Inherits NewsArticleModuleBase
#Region " Private Members "
Private _archiveSettings As ArchiveSettings
Private _articleSettings As ArticleSettings
Private _categories As List(Of CategoryInfo)
#End Region
#Region " Private Property "
Private ReadOnly Property ArchiveSettings() As ArchiveSettings
Get
If (_archiveSettings Is Nothing) Then
_archiveSettings = New ArchiveSettings(Settings)
End If
Return _archiveSettings
End Get
End Property
Public Shadows ReadOnly Property ArticleSettings() As ArticleSettings
Get
If (_articleSettings Is Nothing) Then
Dim _settings As Hashtable = Common.GetModuleSettings(ArchiveSettings.ModuleId)
Dim objModule As ModuleInfo = Common.GetModuleInfo(ArchiveSettings.ModuleId, ArchiveSettings.TabId)
If Not (objModule Is Nothing) Then
Dim tabModuleSettings As Hashtable = objModule.TabModuleSettings
For Each strKey As String In tabModuleSettings.Keys
_settings(strKey) = tabModuleSettings(strKey)
Next
End If
_articleSettings = New ArticleSettings(_settings, PortalSettings, objModule)
End If
Return _articleSettings
End Get
End Property
Private ReadOnly Property Categories() As List(Of CategoryInfo)
Get
If (_categories Is Nothing) Then
Dim objCategoryController As New CategoryController
_categories = objCategoryController.GetCategoriesAll(ArchiveSettings.ModuleId, Null.NullInteger, _articleSettings.CategorySortType)
End If
Return _categories
End Get
End Property
#End Region
#Region " Private Methods "
Private Sub BindArchive()
Select Case ArchiveSettings.Mode
Case ArchiveModeType.Date
BindDateArchive()
Case ArchiveModeType.Category
BindCategoryArchive()
Case ArchiveModeType.Author
BindAuthorArchive()
End Select
End Sub
Private Function FindSettings() As Boolean
If (ArchiveSettings.ModuleId <> Null.NullInteger) Then
Return True
End If
If (Settings.Contains("na_StartupCheck") = False) Then
Dim objModuleController As New ModuleController
Dim objModules As List(Of ModuleInfo) = Common.GetArticleModules(PortalId)
For Each objModule As ModuleInfo In objModules
If (objModule.TabID = TabId) Then
objModuleController.UpdateTabModuleSetting(TabModuleId, ArticleConstants.NEWS_ARCHIVES_TAB_ID, objModule.TabID)
objModuleController.UpdateTabModuleSetting(TabModuleId, ArticleConstants.NEWS_ARCHIVES_MODULE_ID, objModule.ModuleID)
objModuleController.UpdateModuleSetting(ModuleId, "na_StartupCheck", 1)
_archiveSettings = Nothing
Return True
End If
Next
For Each objModule As ModuleInfo In objModules
objModuleController.UpdateTabModuleSetting(TabModuleId, ArticleConstants.NEWS_ARCHIVES_TAB_ID, objModule.TabID)
objModuleController.UpdateTabModuleSetting(TabModuleId, ArticleConstants.NEWS_ARCHIVES_MODULE_ID, objModule.ModuleID)
objModuleController.UpdateModuleSetting(ModuleId, "na_StartupCheck", 1)
_archiveSettings = Nothing
Return True
Next
objModuleController.UpdateModuleSetting(ModuleId, "na_StartupCheck", 1)
End If
Return False
End Function
Private Sub BindDateArchive()
Dim objArticleController As New ArticleController
Dim objModuleSettingController As New ModuleController
Dim mi As ModuleInfo = objModuleSettingController.GetModule(ArchiveSettings.ModuleId, ArchiveSettings.TabId)
If Not (mi Is Nothing) Then
Dim authorId As Integer = Null.NullInteger
If (ArticleSettings.AuthorLoggedInUserFilter) Then
authorId = -100
If (Request.IsAuthenticated) Then
authorId = UserId
End If
End If
If (ArticleSettings.AuthorUserIDFilter) Then
If (ArticleSettings.AuthorUserIDParam <> "") Then
If (Request(ArticleSettings.AuthorUserIDParam) <> "") Then
If (IsNumeric(Request(ArticleSettings.AuthorUserIDParam))) Then
authorId = Convert.ToInt32(Request(ArticleSettings.AuthorUserIDParam))
End If
End If
End If
End If
If (ArticleSettings.AuthorUsernameFilter) Then
If (ArticleSettings.AuthorUsernameParam <> "") Then
If (Request(ArticleSettings.AuthorUsernameParam) <> "") Then
Dim objUser As UserInfo = UserController.GetUserByName(PortalId, Request(ArticleSettings.AuthorUsernameParam))
If (objUser IsNot Nothing) Then
authorId = objUser.UserID
End If
End If
End If
End If
If (ArticleSettings.FilterSingleCategory <> Null.NullInteger) Then
Dim categoriesToDisplay(1) As Integer
categoriesToDisplay(1) = ArticleSettings.FilterSingleCategory
If (ArchiveSettings.LayoutMode = LayoutModeType.Simple) Then
rptNewsArchives.DataSource = objArticleController.GetNewsArchive(ArchiveSettings.ModuleId, categoriesToDisplay, Nothing, authorId, ArchiveSettings.GroupBy, ArticleSettings.ShowPending)
rptNewsArchives.DataBind()
Else
dlNewsArchives.RepeatColumns = ArchiveSettings.ItemsPerRow
dlNewsArchives.DataSource = objArticleController.GetNewsArchive(ArchiveSettings.ModuleId, categoriesToDisplay, Nothing, authorId, ArchiveSettings.GroupBy, ArticleSettings.ShowPending)
dlNewsArchives.DataBind()
End If
Exit Sub
End If
If (ArticleSettings.FilterCategories IsNot Nothing) Then
If (ArchiveSettings.LayoutMode = LayoutModeType.Simple) Then
rptNewsArchives.DataSource = objArticleController.GetNewsArchive(ArchiveSettings.ModuleId, ArticleSettings.FilterCategories, Nothing, authorId, ArchiveSettings.GroupBy, ArticleSettings.ShowPending)
rptNewsArchives.DataBind()
Else
dlNewsArchives.RepeatColumns = ArchiveSettings.ItemsPerRow
dlNewsArchives.DataSource = objArticleController.GetNewsArchive(ArchiveSettings.ModuleId, ArticleSettings.FilterCategories, Nothing, authorId, ArchiveSettings.GroupBy, ArticleSettings.ShowPending)
dlNewsArchives.DataBind()
End If
Exit Sub
End If
Dim newsSettings As Hashtable = mi.TabModuleSettings
Dim excludeCategoriesRestrictive As New List(Of Integer)
For Each objCategory As CategoryInfo In Categories
If (objCategory.InheritSecurity = False And objCategory.CategorySecurityType = CategorySecurityType.Restrict) Then
If (Request.IsAuthenticated) Then
If (newsSettings.Contains(objCategory.CategoryID & "-" & ArticleConstants.PERMISSION_CATEGORY_VIEW_SETTING)) Then
If (PortalSecurity.IsInRoles(newsSettings(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
Dim excludeCategories As New List(Of Integer)
For Each objCategory As CategoryInfo In Categories
If (objCategory.InheritSecurity = False And objCategory.CategorySecurityType = CategorySecurityType.Loose) Then
If (Request.IsAuthenticated) Then
If (newsSettings.Contains(objCategory.CategoryID & "-" & ArticleConstants.PERMISSION_CATEGORY_VIEW_SETTING)) Then
If (PortalSecurity.IsInRoles(newsSettings(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
Dim includeCategories As New List(Of Integer)
If (excludeCategories.Count > 0) Then
For Each objCategoryToInclude As CategoryInfo In Categories
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
End If
If (ArchiveSettings.LayoutMode = LayoutModeType.Simple) Then
rptNewsArchives.DataSource = objArticleController.GetNewsArchive(ArchiveSettings.ModuleId, includeCategories.ToArray(), excludeCategoriesRestrictive.ToArray(), authorId, ArchiveSettings.GroupBy, ArticleSettings.ShowPending)
rptNewsArchives.DataBind()
Else
dlNewsArchives.RepeatColumns = ArchiveSettings.ItemsPerRow
dlNewsArchives.DataSource = objArticleController.GetNewsArchive(ArchiveSettings.ModuleId, includeCategories.ToArray(), excludeCategoriesRestrictive.ToArray(), authorId, ArchiveSettings.GroupBy, ArticleSettings.ShowPending)
dlNewsArchives.DataBind()
End If
End If
End Sub
Private Sub BindCategoryArchive()
Dim objCategoryController As New CategoryController
Dim objModuleSettingController As New ModuleController
Dim parentID As Integer = ArticleConstants.NEWS_ARCHIVES_PARENT_CATEGORY_DEFAULT
If (Settings.Contains(ArticleConstants.NEWS_ARCHIVES_PARENT_CATEGORY)) Then
parentID = Convert.ToInt32(Settings(ArticleConstants.NEWS_ARCHIVES_PARENT_CATEGORY))
End If
Dim mi As ModuleInfo = objModuleSettingController.GetModule(ArchiveSettings.ModuleId, ArchiveSettings.TabId)
If Not (mi Is Nothing) Then
Dim authorId As Integer = Null.NullInteger
If (ArticleSettings.AuthorLoggedInUserFilter) Then
authorId = -100
If (Request.IsAuthenticated) Then
authorId = UserId
End If
End If
If (ArticleSettings.AuthorUserIDFilter) Then
If (ArticleSettings.AuthorUserIDParam <> "") Then
If (Request(ArticleSettings.AuthorUserIDParam) <> "") Then
If (IsNumeric(Request(ArticleSettings.AuthorUserIDParam))) Then
authorId = Convert.ToInt32(Request(ArticleSettings.AuthorUserIDParam))
End If
End If
End If
End If
If (ArticleSettings.AuthorUsernameFilter) Then
If (ArticleSettings.AuthorUsernameParam <> "") Then
If (Request(ArticleSettings.AuthorUsernameParam) <> "") Then
Dim objUser As UserInfo = UserController.GetUserByName(PortalId, Request(ArticleSettings.AuthorUsernameParam))
If (objUser IsNot Nothing) Then
authorId = objUser.UserID
End If
End If
End If
End If
If (ArticleSettings.FilterSingleCategory <> Null.NullInteger) Then
Dim categoriesToDisplay(1) As Integer
categoriesToDisplay(1) = ArticleSettings.FilterSingleCategory
If (ArchiveSettings.LayoutMode = LayoutModeType.Simple) Then
rptNewsArchives.DataSource = objCategoryController.GetCategoriesAll(ArchiveSettings.ModuleId, parentID, categoriesToDisplay, authorId, ArchiveSettings.CategoryMaxDepth, ArticleSettings.ShowPending, ArticleSettings.CategorySortType)
rptNewsArchives.DataBind()
Else
dlNewsArchives.RepeatColumns = ArchiveSettings.ItemsPerRow
dlNewsArchives.DataSource = objCategoryController.GetCategoriesAll(ArchiveSettings.ModuleId, parentID, categoriesToDisplay, authorId, ArchiveSettings.CategoryMaxDepth, ArticleSettings.ShowPending, ArticleSettings.CategorySortType)
dlNewsArchives.DataBind()
End If
Exit Sub
End If
If (ArticleSettings.FilterCategories IsNot Nothing) Then
If (ArchiveSettings.LayoutMode = LayoutModeType.Simple) Then
rptNewsArchives.DataSource = objCategoryController.GetCategoriesAll(ArchiveSettings.ModuleId, parentID, ArticleSettings.FilterCategories, authorId, ArchiveSettings.CategoryMaxDepth, ArticleSettings.ShowPending, ArticleSettings.CategorySortType)
rptNewsArchives.DataBind()
Else
dlNewsArchives.RepeatColumns = ArchiveSettings.ItemsPerRow
dlNewsArchives.DataSource = objCategoryController.GetCategoriesAll(ArchiveSettings.ModuleId, parentID, ArticleSettings.FilterCategories, authorId, ArchiveSettings.CategoryMaxDepth, ArticleSettings.ShowPending, ArticleSettings.CategorySortType)
dlNewsArchives.DataBind()
End If
Exit Sub
End If
Dim moduleSettings As Hashtable = mi.ModuleSettings
Dim objCategoriesSelected As New List(Of CategoryInfo)
Dim objCategories As List(Of CategoryInfo) = objCategoryController.GetCategoriesAll(ArchiveSettings.ModuleId, parentID, Nothing, authorId, ArchiveSettings.CategoryMaxDepth, ArticleSettings.ShowPending, ArticleSettings.CategorySortType)
For Each objCategory As CategoryInfo In objCategories
If (objCategory.InheritSecurity) Then
objCategoriesSelected.Add(objCategory)
Else
If (Request.IsAuthenticated) Then
If (moduleSettings.Contains(objCategory.CategoryID & "-" & ArticleConstants.PERMISSION_CATEGORY_VIEW_SETTING)) Then
If (PortalSecurity.IsInRoles(moduleSettings(objCategory.CategoryID & "-" & ArticleConstants.PERMISSION_CATEGORY_VIEW_SETTING).ToString())) Then
objCategoriesSelected.Add(objCategory)
End If
End If
End If
End If
Next
If (ArchiveSettings.LayoutMode = LayoutModeType.Simple) Then
rptNewsArchives.DataSource = objCategoriesSelected
rptNewsArchives.DataBind()
Else
dlNewsArchives.RepeatColumns = ArchiveSettings.ItemsPerRow
dlNewsArchives.DataSource = objCategoriesSelected
dlNewsArchives.DataBind()
End If
End If
End Sub
Private Sub BindAuthorArchive()
Dim sortBy As String = ArticleConstants.NEWS_ARCHIVES_AUTHOR_SORT_BY_DEFAULT.ToString()
If (Settings.Contains(ArticleConstants.NEWS_ARCHIVES_AUTHOR_SORT_BY)) Then
sortBy = CType(System.Enum.Parse(GetType(AuthorSortByType), Settings(ArticleConstants.NEWS_ARCHIVES_AUTHOR_SORT_BY).ToString()), AuthorSortByType).ToString()
End If
Dim objAuthorController As New AuthorController
Dim objModuleSettingController As New ModuleController
Dim mi As ModuleInfo = objModuleSettingController.GetModule(ArchiveSettings.ModuleId, ArchiveSettings.TabId)
If Not (mi Is Nothing) Then
Dim newsSettings As Hashtable = mi.TabModuleSettings
Dim authorId As Integer = Null.NullInteger
If (ArticleSettings.AuthorLoggedInUserFilter) Then
authorId = -100
If (Request.IsAuthenticated) Then
authorId = UserId
End If
End If
If (ArticleSettings.AuthorUserIDFilter) Then
If (ArticleSettings.AuthorUserIDParam <> "") Then
If (Request(ArticleSettings.AuthorUserIDParam) <> "") Then
If (IsNumeric(Request(ArticleSettings.AuthorUserIDParam))) Then
authorID = Convert.ToInt32(Request(ArticleSettings.AuthorUserIDParam))
End If
End If
End If
End If
If (ArticleSettings.AuthorUsernameFilter) Then
If (ArticleSettings.AuthorUsernameParam <> "") Then
If (Request(ArticleSettings.AuthorUsernameParam) <> "") Then
Dim objUser As UserInfo = UserController.GetUserByName(PortalId, Request(ArticleSettings.AuthorUsernameParam))
If (objUser IsNot Nothing) Then
authorId = objUser.UserID
End If
End If
End If
End If
If (ArticleSettings.FilterSingleCategory <> Null.NullInteger) Then
Dim categoriesToDisplay(1) As Integer
categoriesToDisplay(1) = ArticleSettings.FilterSingleCategory
If (ArchiveSettings.LayoutMode = LayoutModeType.Simple) Then
rptNewsArchives.DataSource = objAuthorController.GetAuthorStatistics(ArchiveSettings.ModuleId, categoriesToDisplay, Nothing, authorId, sortBy, ArticleSettings.ShowPending)
rptNewsArchives.DataBind()
Else
dlNewsArchives.RepeatColumns = ArchiveSettings.ItemsPerRow
dlNewsArchives.DataSource = objAuthorController.GetAuthorStatistics(ArchiveSettings.ModuleId, categoriesToDisplay, Nothing, authorId, sortBy, ArticleSettings.ShowPending)
dlNewsArchives.DataBind()
End If
Exit Sub
End If
If (ArticleSettings.FilterCategories IsNot Nothing) Then
If (ArchiveSettings.LayoutMode = LayoutModeType.Simple) Then
rptNewsArchives.DataSource = objAuthorController.GetAuthorStatistics(ArchiveSettings.ModuleId, ArticleSettings.FilterCategories, Nothing, authorId, sortBy, ArticleSettings.ShowPending)
rptNewsArchives.DataBind()
Else
dlNewsArchives.RepeatColumns = ArchiveSettings.ItemsPerRow
dlNewsArchives.DataSource = objAuthorController.GetAuthorStatistics(ArchiveSettings.ModuleId, ArticleSettings.FilterCategories, Nothing, authorId, sortBy, ArticleSettings.ShowPending)
dlNewsArchives.DataBind()
End If
Exit Sub
End If
Dim objCategoryController As New CategoryController
Dim objCategories As List(Of CategoryInfo) = objCategoryController.GetCategoriesAll(ArchiveSettings.ModuleId, Null.NullInteger)
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 (newsSettings.Contains(objCategory.CategoryID & "-" & ArticleConstants.PERMISSION_CATEGORY_VIEW_SETTING)) Then
If (PortalSecurity.IsInRoles(newsSettings(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
Dim excludeCategories As New List(Of Integer)
For Each objCategory As CategoryInfo In objCategories
If (objCategory.InheritSecurity = False And objCategory.CategorySecurityType = CategorySecurityType.Loose) Then
If (Request.IsAuthenticated) Then
If (newsSettings.Contains(objCategory.CategoryID & "-" & ArticleConstants.PERMISSION_CATEGORY_VIEW_SETTING)) Then
If (PortalSecurity.IsInRoles(newsSettings(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
Dim includeCategories As New List(Of Integer)
If (excludeCategories.Count > 0) Then
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
End If
If (ArchiveSettings.LayoutMode = LayoutModeType.Simple) Then
rptNewsArchives.DataSource = objAuthorController.GetAuthorStatistics(ArchiveSettings.ModuleId, includeCategories.ToArray(), excludeCategoriesRestrictive.ToArray(), authorId, sortBy, ArticleSettings.ShowPending)
rptNewsArchives.DataBind()
Else
dlNewsArchives.RepeatColumns = ArchiveSettings.ItemsPerRow
dlNewsArchives.DataSource = objAuthorController.GetAuthorStatistics(ArchiveSettings.ModuleId, includeCategories.ToArray(), excludeCategoriesRestrictive.ToArray(), authorId, sortBy, ArticleSettings.ShowPending)
dlNewsArchives.DataBind()
End If
End If
End Sub
Private Sub ProcessBody(ByRef dataControls As ControlCollection, ByVal objArchive As ArchiveInfo)
Dim literal As New Literal
If (ArchiveSettings.LayoutMode = LayoutModeType.Simple) Then
literal.Text = ArchiveSettings.TemplateDateBody
Else
literal.Text = ArchiveSettings.TemplateDateAdvancedBody
End If
Const delimStr As String = "[]"
Dim delimiter As Char() = delimStr.ToCharArray()
ProcessArchive(dataControls, literal.Text.Split(delimiter), objArchive)
End Sub
Private Sub ProcessArchive(ByRef dataControls As ControlCollection, ByVal layoutArray As String(), ByVal objArchive As ArchiveInfo)
Dim archiveDate As DateTime = New DateTime(objArchive.Year, objArchive.Month, objArchive.Day)
For iPtr As Integer = 0 To layoutArray.Length - 1 Step 2
dataControls.Add(New LiteralControl(layoutArray(iPtr).ToString()))
If iPtr < layoutArray.Length - 1 Then
Select Case layoutArray(iPtr + 1)
Case "COUNT"
Dim objLiteral As New Literal
objLiteral.Text = objArchive.Count.ToString()
dataControls.Add(objLiteral)
Case "ISSELECTEDMONTH"
Dim isValid As Boolean = False
If (ArchiveSettings.GroupBy = GroupByType.Month) Then
If (Request("month") <> "") Then
If (Request("month") = objArchive.Month.ToString()) Then
isValid = True
End If
End If
End If
If (isValid = False) Then
While (iPtr < layoutArray.Length - 1)
If (layoutArray(iPtr + 1) = "/ISSELECTEDMONTH") Then
Exit While
End If
iPtr = iPtr + 1
End While
End If
Case "ISNOTSELECTEDMONTH"
Dim isValid As Boolean = False
If (ArchiveSettings.GroupBy = GroupByType.Month) Then
If (Request("month") <> "") Then
If (Request("month") = objArchive.Month.ToString()) Then
isValid = True
End If
End If
End If
If (isValid = True) Then
While (iPtr < layoutArray.Length - 1)
If (layoutArray(iPtr + 1) = "/ISNOTSELECTEDMONTH") Then
Exit While
End If
iPtr = iPtr + 1
End While
End If
Case "ISSELECTEDYEAR"
Dim isValid As Boolean = False
If (ArchiveSettings.GroupBy = GroupByType.Year Or ArchiveSettings.GroupBy = GroupByType.Month) Then
If (Request("year") <> "") Then
If (Request("year") = objArchive.Year.ToString()) Then
isValid = True
End If
End If
End If
If (isValid = False) Then
While (iPtr < layoutArray.Length - 1)
If (layoutArray(iPtr + 1) = "/ISSELECTEDYEAR") Then
Exit While
End If
iPtr = iPtr + 1
End While
End If
Case "ISNOTSELECTEDYEAR"
Dim isValid As Boolean = False
If (Request("year") <> "") Then
If (Request("year") = objArchive.Year.ToString()) Then
isValid = True
End If
End If
If (isValid = True) Then
While (iPtr < layoutArray.Length - 1)
If (layoutArray(iPtr + 1) = "/ISNOTSELECTEDYEAR") Then
Exit While
End If
iPtr = iPtr + 1
End While
End If
Case "LINK"
Dim objLiteral As New Literal
If (ArchiveSettings.GroupBy = GroupByType.Month) Then
objLiteral.Text = Common.GetModuleLink(ArchiveSettings.TabId, ArchiveSettings.ModuleId, "ArchiveView", ArticleSettings, "month=" & objArchive.Month.ToString(), "year=" & objArchive.Year.ToString())
Else
objLiteral.Text = Common.GetModuleLink(ArchiveSettings.TabId, ArchiveSettings.ModuleId, "ArchiveView", ArticleSettings, "year=" & objArchive.Year.ToString())
End If
dataControls.Add(objLiteral)
Case "MONTH"
Dim objLiteral As New Literal
If (ArchiveSettings.GroupBy = GroupByType.Month) Then
objLiteral.Text = archiveDate.ToString("MMMM")
Else
objLiteral.Text = ""
End If
dataControls.Add(objLiteral)
Case "YEAR"
Dim objLiteral As New Literal
objLiteral.Text = archiveDate.Year.ToString()
dataControls.Add(objLiteral)
End Select
End If
Next
End Sub
Private Sub ProcessBody(ByRef dataControls As ControlCollection, ByVal objCategory As CategoryInfo)
Dim literal As New Literal
If (ArchiveSettings.LayoutMode = LayoutModeType.Simple) Then
literal.Text = ArchiveSettings.TemplateCategoryBody
Else
literal.Text = ArchiveSettings.TemplateCategoryAdvancedBody
End If
If (literal.Text.Contains("[DEPTHABS]")) Then
For Each objCategorySelected As CategoryInfo In Categories
If (objCategorySelected.CategoryID = objCategory.CategoryID) Then
literal.Text = literal.Text.Replace("[DEPTHABS]", objCategorySelected.Level.ToString())
End If
Next
End If
literal.Text = literal.Text.Replace("[CATEGORYID]", objCategory.CategoryID.ToString())
literal.Text = literal.Text.Replace("[CATEGORY]", objCategory.NameIndented.ToString())
literal.Text = literal.Text.Replace("[CATEGORYNOTINDENTED]", objCategory.Name.ToString())
literal.Text = literal.Text.Replace("[COUNT]", objCategory.NumberOfArticles.ToString())
literal.Text = literal.Text.Replace("[DEPTHREL]", objCategory.Level.ToString())
literal.Text = literal.Text.Replace("[DESCRIPTION]", Server.HtmlDecode(objCategory.Description))
literal.Text = literal.Text.Replace("[LINK]", Common.GetCategoryLink(ArchiveSettings.TabId, ArchiveSettings.ModuleId, objCategory.CategoryID.ToString(), objCategory.Name, ArticleSettings.LaunchLinks, ArticleSettings))
If (ArchiveSettings.CategoryHideZeroCategories And objCategory.NumberOfArticles = 0) Then
Return
End If
dataControls.Add(literal)
End Sub
Private Sub ProcessBody(ByRef dataControls As ControlCollection, ByVal objAuthor As AuthorInfo)
Dim literal As New Literal
If (ArchiveSettings.LayoutMode = LayoutModeType.Simple) Then
literal.Text = ArchiveSettings.TemplateAuthorBody
Else
literal.Text = ArchiveSettings.TemplateAuthorAdvancedBody
End If
literal.Text = literal.Text.Replace("[AUTHORID]", objAuthor.UserID.ToString())
literal.Text = literal.Text.Replace("[AUTHORUSERNAME]", objAuthor.UserName.ToString())
literal.Text = literal.Text.Replace("[AUTHORDISPLAYNAME]", objAuthor.DisplayName.ToString())
literal.Text = literal.Text.Replace("[AUTHORFIRSTNAME]", objAuthor.FirstName.ToString())
literal.Text = literal.Text.Replace("[AUTHORLASTNAME]", objAuthor.LastName.ToString())
literal.Text = literal.Text.Replace("[AUTHORFULLNAME]", objAuthor.FullName.ToString())
literal.Text = literal.Text.Replace("[COUNT]", objAuthor.ArticleCount.ToString())
literal.Text = literal.Text.Replace("[LINK]", Common.GetAuthorLink(ArchiveSettings.TabId, ArchiveSettings.ModuleId, objAuthor.UserID, objAuthor.UserName, ArticleSettings.LaunchLinks, ArticleSettings))
dataControls.Add(literal)
End Sub
Private Sub ProcessTemplate(ByRef listControls As ControlCollection, ByVal li As ListItemType, ByVal obj As Object)
If (li = ListItemType.Header) Then
Dim objLiteral As New Literal
Select Case ArchiveSettings.Mode
Case ArchiveModeType.Date
If (ArchiveSettings.LayoutMode = LayoutModeType.Simple) Then
objLiteral.Text = ArchiveSettings.TemplateDateHeader
Else
objLiteral.Text = ArchiveSettings.TemplateDateAdvancedHeader
End If
Case ArchiveModeType.Category
If (ArchiveSettings.LayoutMode = LayoutModeType.Simple) Then
objLiteral.Text = ArchiveSettings.TemplateCategoryHeader
Else
objLiteral.Text = ArchiveSettings.TemplateCategoryAdvancedHeader
End If
Case ArchiveModeType.Author
If (ArchiveSettings.LayoutMode = LayoutModeType.Simple) Then
objLiteral.Text = ArchiveSettings.TemplateAuthorHeader
Else
objLiteral.Text = ArchiveSettings.TemplateAuthorAdvancedHeader
End If
End Select
listControls.Add(objLiteral)
End If
If (li = ListItemType.Item Or li = ListItemType.AlternatingItem) Then
Select Case ArchiveSettings.Mode
Case ArchiveModeType.Date
ProcessBody(listControls, CType(obj, ArchiveInfo))
Case ArchiveModeType.Category
ProcessBody(listControls, CType(obj, CategoryInfo))
Case ArchiveModeType.Author
ProcessBody(listControls, CType(obj, AuthorInfo))
End Select
End If
If (li = ListItemType.Footer) Then
Dim objLiteral As New Literal
Select Case ArchiveSettings.Mode
Case ArchiveModeType.Date
If (ArchiveSettings.LayoutMode = LayoutModeType.Simple) Then
objLiteral.Text = ArchiveSettings.TemplateDateFooter
Else
objLiteral.Text = ArchiveSettings.TemplateDateAdvancedFooter
End If
Case ArchiveModeType.Category
If (ArchiveSettings.LayoutMode = LayoutModeType.Simple) Then
objLiteral.Text = ArchiveSettings.TemplateCategoryFooter
Else
objLiteral.Text = ArchiveSettings.TemplateCategoryAdvancedFooter
End If
Case ArchiveModeType.Author
If (ArchiveSettings.LayoutMode = LayoutModeType.Simple) Then
objLiteral.Text = ArchiveSettings.TemplateAuthorFooter
Else
objLiteral.Text = ArchiveSettings.TemplateAuthorAdvancedFooter
End If
End Select
listControls.Add(objLiteral)
End If
End Sub
#End Region
#Region " Event Handlers "
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As EventArgs) Handles MyBase.Load
Try
If (FindSettings()) Then
BindArchive()
Else
divNotConfigured.Visible = True
rptNewsArchives.Visible = False
End If
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub rptNewsArchives_OnItemDataBound(ByVal sender As Object, ByVal e As RepeaterItemEventArgs) Handles rptNewsArchives.ItemDataBound
Try
ProcessTemplate(e.Item.Controls, e.Item.ItemType, e.Item.DataItem)
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub dlNewsArchives_OnItemDataBound(ByVal sender As Object, ByVal e As DataListItemEventArgs) Handles dlNewsArchives.ItemDataBound
Try
ProcessTemplate(e.Item.Controls, e.Item.ItemType, e.Item.DataItem)
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
#End Region
End Class
End Namespace