-
Notifications
You must be signed in to change notification settings - Fork 24
/
ViewCategory.ascx.vb
executable file
·996 lines (803 loc) · 56.9 KB
/
ViewCategory.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
'
' News Articles for DotNetNuke - http://www.dotnetnuke.com
' Copyright (c) 2002-2007
' by Ventrian ( [email protected] ) ( http://www.ventrian.com )
'
Imports DotNetNuke.Common
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.Localization
Imports DotNetNuke.Security
Imports DotNetNuke.Services.FileSystem
Imports Ventrian.NewsArticles.Base
Namespace Ventrian.NewsArticles
Partial Public Class ViewCategory
Inherits NewsArticleModuleBase
#Region " Constants "
Private Const PARAM_CATEGORY_ID As String = "CategoryID"
#End Region
#Region " Private Members "
Private _layoutController As LayoutController
Private _objCategoriesAll As List(Of CategoryInfo)
Private _categoryID As Integer = Null.NullInteger
#End Region
#Region " Private Methods "
Private Sub BindCategory()
If (_categoryID = Null.NullInteger) Then
' Category not specified
Return
End If
Dim objCategoryController As New CategoryController
Dim objCategory As CategoryInfo = objCategoryController.GetCategory(_categoryID, ModuleId)
If Not (objCategory Is Nothing) Then
If (objCategory.ModuleID <> Me.ModuleId) Then
' Category does not belong to this module.
Response.Redirect(NavigateURL(), True)
End If
ProcessCategory(objCategory, phCategory.Controls)
Else
Response.Redirect(NavigateURL(), True)
End If
End Sub
Private Sub ProcessCategoryChild(ByVal objCategory As CategoryInfo, ByRef objPlaceHolder As ControlCollection, ByVal moduleKey As String, ByVal templateArray As String(), ByVal level As Integer)
For iPtr As Integer = 0 To templateArray.Length - 1 Step 2
objPlaceHolder.Add(New LiteralControl(_layoutController.ProcessImages(templateArray(iPtr).ToString())))
If iPtr < templateArray.Length - 1 Then
Select Case templateArray(iPtr + 1)
Case "ARTICLECOUNT"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID(moduleKey & "-" & iPtr.ToString())
objLiteral.Text = objCategory.NumberOfArticles.ToString()
objPlaceHolder.Add(objLiteral)
Case "CATEGORYID"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID(moduleKey & "-" & iPtr.ToString())
objLiteral.Text = objCategory.CategoryID.ToString()
objPlaceHolder.Add(objLiteral)
Case "DEPTHABS"
For Each objCategoryItem As CategoryInfo In _objCategoriesAll
If (objCategoryItem.CategoryID = objCategory.CategoryID) Then
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID(moduleKey & "-" & iPtr.ToString())
objLiteral.Text = objCategoryItem.Level.ToString()
objPlaceHolder.Add(objLiteral)
End If
Next
Case "DEPTHREL"
For Each objCategoryItem As CategoryInfo In _objCategoriesAll
If (objCategoryItem.CategoryID = objCategory.CategoryID) Then
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID(moduleKey & "-" & iPtr.ToString())
objLiteral.Text = (objCategoryItem.Level - level).ToString()
objPlaceHolder.Add(objLiteral)
End If
Next
Case "DESCRIPTION"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID(moduleKey & "-" & iPtr.ToString())
objLiteral.Text = Server.HtmlDecode(objCategory.Description)
objPlaceHolder.Add(objLiteral)
Case "HASIMAGE"
If (objCategory.Image = "") Then
While (iPtr < templateArray.Length - 1)
If (templateArray(iPtr + 1) = "/HASIMAGE") Then
Exit While
End If
iPtr = iPtr + 1
End While
End If
Case "/HASIMAGE"
' Do Nothing
Case "HASNOIMAGE"
If (objCategory.Image <> "") Then
While (iPtr < templateArray.Length - 1)
If (templateArray(iPtr + 1) = "/HASNOIMAGE") Then
Exit While
End If
iPtr = iPtr + 1
End While
End If
Case "/HASNOIMAGE"
' Do Nothing
Case "IMAGE"
If (objCategory.Image <> "") Then
If (objCategory.Image.Split("="c).Length = 2) Then
If (IsNumeric(objCategory.Image.Split("="c)(1))) Then
Dim objFile As DotNetNuke.Services.FileSystem.FileInfo = FileManager.Instance.GetFile(Convert.ToInt32(objCategory.Image.Split("="c)(1)))
If (objFile IsNot Nothing) Then
Dim objImage As New Image
objImage.ID = Globals.CreateValidID("Category-" & iPtr.ToString())
objImage.ImageUrl = PortalSettings.HomeDirectory & objFile.Folder & objFile.FileName
objPlaceHolder.Add(objImage)
End If
End If
End If
End If
Case "IMAGELINK"
If (objCategory.Image <> "") Then
If (objCategory.Image.Split("="c).Length = 2) Then
If (IsNumeric(objCategory.Image.Split("="c)(1))) Then
Dim objFile As DotNetNuke.Services.FileSystem.FileInfo = FileManager.Instance.GetFile(Convert.ToInt32(objCategory.Image.Split("="c)(1)))
If (objFile IsNot Nothing) Then
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID("Category-" & iPtr.ToString())
objLiteral.Text = PortalSettings.HomeDirectory & objFile.Folder & objFile.FileName
objPlaceHolder.Add(objLiteral)
End If
End If
End If
End If
Case "LINK"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID(moduleKey & "-" & iPtr.ToString())
objLiteral.Text = Common.GetCategoryLink(TabId, ModuleId, objCategory.CategoryID.ToString(), objCategory.Name, ArticleSettings.LaunchLinks, ArticleSettings)
objPlaceHolder.Add(objLiteral)
Case "METADESCRIPTION"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID(moduleKey & "-" & iPtr.ToString())
objLiteral.Text = objCategory.MetaDescription.ToString()
objPlaceHolder.Add(objLiteral)
Case "NAME"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID(moduleKey & "-" & iPtr.ToString())
objLiteral.Text = objCategory.Name
objPlaceHolder.Add(objLiteral)
Case "RSSLINK"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID(moduleKey & "-" & iPtr.ToString())
objLiteral.Text = Page.ResolveUrl("~/DesktopModules/DnnForge - NewsArticles/RSS.aspx?TabID=" & TabId.ToString() & "&ModuleID=" & ModuleId.ToString() & "&CategoryID=" & objCategory.CategoryID.ToString())
objPlaceHolder.Add(objLiteral)
Case "ORDER"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID(moduleKey & "-" & iPtr.ToString())
objLiteral.Text = objCategory.SortOrder.ToString()
objPlaceHolder.Add(objLiteral)
Case "VIEWS"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID(moduleKey & "-" & iPtr.ToString())
objLiteral.Text = objCategory.NumberOfViews.ToString()
objPlaceHolder.Add(objLiteral)
Case Else
If (templateArray(iPtr + 1).ToUpper().StartsWith("DESCRIPTION:")) Then
Dim description As String = Server.HtmlDecode(objCategory.Description)
If (IsNumeric(templateArray(iPtr + 1).Substring(12, templateArray(iPtr + 1).Length - 12))) Then
Dim length As Integer = Convert.ToInt32(templateArray(iPtr + 1).Substring(12, templateArray(iPtr + 1).Length - 12))
If (StripHtml(Server.HtmlDecode(objCategory.Description)).TrimStart().Length > length) Then
description = Left(StripHtml(Server.HtmlDecode(objCategory.Description)).TrimStart(), length) & "..."
Else
description = Left(StripHtml(Server.HtmlDecode(objCategory.Description)).TrimStart(), length)
End If
End If
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID(moduleKey & "-" & iPtr.ToString())
objLiteral.Text = description
objPlaceHolder.Add(objLiteral)
Exit Select
End If
If (templateArray(iPtr + 1).ToUpper().StartsWith("IFORDER:")) Then
Dim depth As String = templateArray(iPtr + 1).Substring(8, templateArray(iPtr + 1).Length - 8)
Dim isOrder As Boolean = False
For Each item As String In depth.Split(","c)
If (IsNumeric(item)) Then
If (objCategory.SortOrder = Convert.ToInt32(item)) Then
isOrder = True
End If
End If
Next
Dim endToken As String = "/" & templateArray(iPtr + 1)
If (isOrder = False) Then
While (iPtr < templateArray.Length - 1)
If (templateArray(iPtr + 1) = endToken) Then
Exit While
End If
iPtr = iPtr + 1
End While
End If
End If
If (templateArray(iPtr + 1).ToUpper().StartsWith("IFNOTORDER:")) Then
Dim depth As String = templateArray(iPtr + 1).Substring(11, templateArray(iPtr + 1).Length - 11)
Dim isOrder As Boolean = False
For Each item As String In depth.Split(","c)
If (IsNumeric(item)) Then
If (objCategory.SortOrder = Convert.ToInt32(item)) Then
isOrder = True
End If
End If
Next
Dim endToken As String = "/" & templateArray(iPtr + 1)
If (isOrder = True) Then
While (iPtr < templateArray.Length - 1)
If (templateArray(iPtr + 1) = endToken) Then
Exit While
End If
iPtr = iPtr + 1
End While
End If
End If
If (templateArray(iPtr + 1).ToUpper().StartsWith("IMAGETHUMB:")) Then
If (objCategory.Image <> "") Then
If (objCategory.Image.Split("="c).Length = 2) Then
If (IsNumeric(objCategory.Image.Split("="c)(1))) Then
Dim objFile As DotNetNuke.Services.FileSystem.FileInfo = FileManager.Instance.GetFile(Convert.ToInt32(objCategory.Image.Split("="c)(1)))
If (objFile IsNot Nothing) Then
Dim val As String = templateArray(iPtr + 1).Substring(11, templateArray(iPtr + 1).Length - 11)
If (val.IndexOf(":"c) = -1) Then
Dim length As Integer = Convert.ToInt32(val)
Dim objImage As New Image
If (ArticleSettings.ImageThumbnailType = ThumbnailType.Proportion) Then
objImage.ImageUrl = Page.ResolveUrl("~/DesktopModules/DnnForge - NewsArticles/ImageHandler.ashx?Width=" & length.ToString() & "&Height=" & length.ToString() & "&HomeDirectory=" & Server.UrlEncode(PortalSettings.HomeDirectory & objFile.Folder) & "&FileName=" & Server.UrlEncode(objFile.FileName) & "&PortalID=" & PortalId.ToString() & "&q=1")
Else
objImage.ImageUrl = Page.ResolveUrl("~/DesktopModules/DnnForge - NewsArticles/ImageHandler.ashx?Width=" & length.ToString() & "&Height=" & length.ToString() & "&HomeDirectory=" & Server.UrlEncode(PortalSettings.HomeDirectory & objFile.Folder) & "&FileName=" & Server.UrlEncode(objFile.FileName) & "&PortalID=" & PortalId.ToString() & "&q=1&s=1")
End If
objImage.EnableViewState = False
objPlaceHolder.Add(objImage)
Else
Dim arr() As String = val.Split(":"c)
Dim width As Integer = Convert.ToInt32(val.Split(":"c)(0))
Dim height As Integer = Convert.ToInt32(val.Split(":"c)(1))
Dim objImage As New Image
If (ArticleSettings.ImageThumbnailType = ThumbnailType.Proportion) Then
objImage.ImageUrl = Page.ResolveUrl("~/DesktopModules/DnnForge - NewsArticles/ImageHandler.ashx?Width=" & width.ToString() & "&Height=" & height.ToString() & "&HomeDirectory=" & Server.UrlEncode(PortalSettings.HomeDirectory & objFile.Folder) & "&FileName=" & Server.UrlEncode(objFile.FileName) & "&PortalID=" & PortalId.ToString() & "&q=1")
Else
objImage.ImageUrl = Page.ResolveUrl("~/DesktopModules/DnnForge - NewsArticles/ImageHandler.ashx?Width=" & width.ToString() & "&Height=" & height.ToString() & "&HomeDirectory=" & Server.UrlEncode(PortalSettings.HomeDirectory & objFile.Folder) & "&FileName=" & Server.UrlEncode(objFile.FileName) & "&PortalID=" & PortalId.ToString() & "&q=1&s=1")
End If
objImage.EnableViewState = False
objPlaceHolder.Add(objImage)
End If
End If
End If
End If
End If
End If
If (templateArray(iPtr + 1).ToUpper().StartsWith("ISDEPTHABS:")) Then
Dim depth As String = templateArray(iPtr + 1).Substring(11, templateArray(iPtr + 1).Length - 11)
Dim isDepth As Boolean = False
For Each item As String In depth.Split(","c)
If (IsNumeric(item)) Then
For Each objCategoryItem As CategoryInfo In _objCategoriesAll
If (objCategoryItem.CategoryID = objCategory.CategoryID) Then
If (objCategoryItem.Level = Convert.ToInt32(item)) Then
isDepth = True
End If
End If
Next
End If
Next
Dim endToken As String = "/" & templateArray(iPtr + 1)
If (isDepth = False) Then
While (iPtr < templateArray.Length - 1)
If (templateArray(iPtr + 1) = endToken) Then
Exit While
End If
iPtr = iPtr + 1
End While
End If
End If
If (templateArray(iPtr + 1).ToUpper().StartsWith("ISDEPTHREL:")) Then
Dim depth As String = templateArray(iPtr + 1).Substring(11, templateArray(iPtr + 1).Length - 11)
Dim isDepth As Boolean = False
For Each item As String In depth.Split(","c)
If (IsNumeric(item)) Then
For Each objCategoryItem As CategoryInfo In _objCategoriesAll
If (objCategoryItem.CategoryID = objCategory.CategoryID) Then
If ((objCategoryItem.Level - level) = Convert.ToInt32(item)) Then
isDepth = True
End If
End If
Next
End If
Next
Dim endToken As String = "/" & templateArray(iPtr + 1)
If (isDepth = False) Then
While (iPtr < templateArray.Length - 1)
If (templateArray(iPtr + 1) = endToken) Then
Exit While
End If
iPtr = iPtr + 1
End While
End If
End If
If (templateArray(iPtr + 1).ToUpper().StartsWith("ISNOTDEPTHABS:")) Then
Dim depth As String = templateArray(iPtr + 1).Substring(14, templateArray(iPtr + 1).Length - 14)
Dim isDepth As Boolean = False
For Each item As String In depth.Split(","c)
If (IsNumeric(item)) Then
For Each objCategoryItem As CategoryInfo In _objCategoriesAll
If (objCategoryItem.CategoryID = objCategory.CategoryID) Then
If (objCategoryItem.Level = Convert.ToInt32(item)) Then
isDepth = True
End If
End If
Next
End If
Next
Dim endToken As String = "/" & templateArray(iPtr + 1)
If (isDepth = True) Then
While (iPtr < templateArray.Length - 1)
If (templateArray(iPtr + 1) = endToken) Then
Exit While
End If
iPtr = iPtr + 1
End While
End If
End If
If (templateArray(iPtr + 1).ToUpper().StartsWith("ISNOTDEPTHREL:")) Then
Dim depth As String = templateArray(iPtr + 1).Substring(14, templateArray(iPtr + 1).Length - 14)
Dim isDepth As Boolean = False
For Each item As String In depth.Split(","c)
If (IsNumeric(item)) Then
For Each objCategoryItem As CategoryInfo In _objCategoriesAll
If (objCategoryItem.CategoryID = objCategory.CategoryID) Then
If ((objCategoryItem.Level - level) = Convert.ToInt32(item)) Then
isDepth = True
End If
End If
Next
End If
Next
Dim endToken As String = "/" & templateArray(iPtr + 1)
If (isDepth = True) Then
While (iPtr < templateArray.Length - 1)
If (templateArray(iPtr + 1) = endToken) Then
Exit While
End If
iPtr = iPtr + 1
End While
End If
End If
End Select
End If
Next
End Sub
Private Sub ProcessCategory(ByVal objCategory As CategoryInfo, ByRef objPlaceHolder As ControlCollection)
_layoutController = New LayoutController(Me)
Dim layoutCategory As LayoutInfo = LayoutController.GetLayout(Me, LayoutType.Category_Html)
Dim layoutCategoryChild As LayoutInfo = LayoutController.GetLayout(Me, LayoutType.Category_Child_Html)
Dim templateArray As String() = layoutCategory.Tokens
Dim objCategoryController As New CategoryController
Dim objParentCategory As CategoryInfo = Nothing
If (objCategory.ParentID <> Null.NullInteger) Then
objParentCategory = objCategoryController.GetCategory(objCategory.ParentID, ModuleId)
End If
Dim objCategoriesChildren As List(Of CategoryInfo) = objCategoryController.GetCategories(Me.ModuleId, objCategory.CategoryID)
For iPtr As Integer = 0 To templateArray.Length - 1 Step 2
objPlaceHolder.Add(New LiteralControl(_layoutController.ProcessImages(templateArray(iPtr).ToString())))
If iPtr < templateArray.Length - 1 Then
Select Case templateArray(iPtr + 1)
Case "ARTICLECOUNT"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID("Category-" & iPtr.ToString())
objLiteral.Text = objCategory.NumberOfArticles.ToString()
objPlaceHolder.Add(objLiteral)
Case "CATEGORYLABEL"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID("Category-" & iPtr.ToString())
Dim entriesFrom As String = Localization.GetString("CategoryEntries", LocalResourceFile)
If (entriesFrom.Contains("{0}")) Then
objLiteral.Text = String.Format(entriesFrom, objCategory.Name)
Else
objLiteral.Text = objCategory.Name
End If
objPlaceHolder.Add(objLiteral)
Case "CATEGORYID"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID("Category-" & iPtr.ToString())
objLiteral.Text = objCategory.CategoryID.ToString()
objPlaceHolder.Add(objLiteral)
Case "CHILDCATEGORIES"
If (objCategoriesChildren.Count > 0) Then
For Each objCategoryItem As CategoryInfo In _objCategoriesAll
If (objCategoryItem.CategoryID = objCategory.CategoryID) Then
Dim i As Integer = 0
For Each objCategoryChild As CategoryInfo In objCategoriesChildren
ProcessCategoryChild(objCategoryChild, objPlaceHolder, "ChildCategory-" & i.ToString() & "-" & iPtr.ToString(), layoutCategoryChild.Tokens, objCategoryItem.Level)
i = i + 1
Next
End If
Next
End If
Case "DESCRIPTION"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID("Category-" & iPtr.ToString())
objLiteral.Text = Server.HtmlDecode(objCategory.Description)
objPlaceHolder.Add(objLiteral)
Case "HASCHILDCATEGORIES"
If (objCategoriesChildren.Count = 0) Then
While (iPtr < templateArray.Length - 1)
If (templateArray(iPtr + 1) = "/HASCHILDCATEGORIES") Then
Exit While
End If
iPtr = iPtr + 1
End While
End If
Case "/HASCHILDCATEGORIES"
' Do Nothing
Case "HASNOCHILDCATEGORIES"
If (objCategoriesChildren.Count > 0) Then
While (iPtr < templateArray.Length - 1)
If (templateArray(iPtr + 1) = "/HASNOCHILDCATEGORIES") Then
Exit While
End If
iPtr = iPtr + 1
End While
End If
Case "/HASNOCHILDCATEGORIES"
' Do Nothing
Case "HASNOPARENT"
If (objParentCategory IsNot Nothing) Then
While (iPtr < templateArray.Length - 1)
If (templateArray(iPtr + 1) = "/HASNOPARENT") Then
Exit While
End If
iPtr = iPtr + 1
End While
End If
Case "/HASNOPARENT"
' Do Nothing
Case "HASPARENT"
If (objParentCategory Is Nothing) Then
While (iPtr < templateArray.Length - 1)
If (templateArray(iPtr + 1) = "/HASPARENT") Then
Exit While
End If
iPtr = iPtr + 1
End While
End If
Case "/HASPARENT"
' Do Nothing
Case "HASIMAGE"
If (objCategory.Image = "") Then
While (iPtr < templateArray.Length - 1)
If (templateArray(iPtr + 1) = "/HASIMAGE") Then
Exit While
End If
iPtr = iPtr + 1
End While
End If
Case "/HASIMAGE"
' Do Nothing
Case "HASNOIMAGE"
If (objCategory.Image <> "") Then
While (iPtr < templateArray.Length - 1)
If (templateArray(iPtr + 1) = "/HASNOIMAGE") Then
Exit While
End If
iPtr = iPtr + 1
End While
End If
Case "/HASNOIMAGE"
' Do Nothing
Case "IMAGE"
If (objCategory.Image <> "") Then
If (objCategory.Image.Split("="c).Length = 2) Then
If (IsNumeric(objCategory.Image.Split("="c)(1))) Then
Dim objFile As DotNetNuke.Services.FileSystem.FileInfo = FileManager.Instance.GetFile(Convert.ToInt32(objCategory.Image.Split("="c)(1)))
If (objFile IsNot Nothing) Then
Dim objImage As New Image
objImage.ID = Globals.CreateValidID("Category-" & iPtr.ToString())
objImage.ImageUrl = PortalSettings.HomeDirectory & objFile.Folder & objFile.FileName
objPlaceHolder.Add(objImage)
End If
End If
End If
End If
Case "IMAGELINK"
If (objCategory.Image <> "") Then
If (objCategory.Image.Split("="c).Length = 2) Then
If (IsNumeric(objCategory.Image.Split("="c)(1))) Then
Dim objFile As DotNetNuke.Services.FileSystem.FileInfo = FileManager.Instance.GetFile(Convert.ToInt32(objCategory.Image.Split("="c)(1)))
If (objFile IsNot Nothing) Then
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID("Category-" & iPtr.ToString())
objLiteral.Text = PortalSettings.HomeDirectory & objFile.Folder & objFile.FileName
objPlaceHolder.Add(objLiteral)
End If
End If
End If
End If
Case "LINK"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID("Category-" & iPtr.ToString())
objLiteral.Text = Common.GetCategoryLink(TabId, ModuleId, objCategory.CategoryID.ToString(), objCategory.Name, ArticleSettings.LaunchLinks, ArticleSettings)
objPlaceHolder.Add(objLiteral)
Case "METADESCRIPTION"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID("Category-" & iPtr.ToString())
objLiteral.Text = objCategory.MetaDescription.ToString()
objPlaceHolder.Add(objLiteral)
Case "NAME"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID("Category-" & iPtr.ToString())
objLiteral.Text = objCategory.Name
objPlaceHolder.Add(objLiteral)
Case "PARENTDESCRIPTION"
If (objParentCategory IsNot Nothing) Then
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID("Category-" & iPtr.ToString())
objLiteral.Text = Server.HtmlDecode(objParentCategory.Description)
objPlaceHolder.Add(objLiteral)
End If
Case "PARENTLINK"
If (objParentCategory IsNot Nothing) Then
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID("Category-" & iPtr.ToString())
objLiteral.Text = Common.GetCategoryLink(TabId, ModuleId, objParentCategory.CategoryID.ToString(), objParentCategory.Name, ArticleSettings.LaunchLinks, ArticleSettings)
objPlaceHolder.Add(objLiteral)
End If
Case "PARENTNAME"
If (objParentCategory IsNot Nothing) Then
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID("Category-" & iPtr.ToString())
objLiteral.Text = objParentCategory.Name
objPlaceHolder.Add(objLiteral)
End If
Case "RSSLINK"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID("Category-" & iPtr.ToString())
objLiteral.Text = Page.ResolveUrl("~/DesktopModules/DnnForge - NewsArticles/RSS.aspx?TabID=" & TabId.ToString() & "&ModuleID=" & ModuleId.ToString() & "&CategoryID=" & objCategory.CategoryID.ToString())
objPlaceHolder.Add(objLiteral)
Case "VIEWS"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID("Category-" & iPtr.ToString())
objLiteral.Text = objCategory.NumberOfViews.ToString()
objPlaceHolder.Add(objLiteral)
Case Else
If (templateArray(iPtr + 1).ToUpper().StartsWith("CHILDCATEGORIES:")) Then
Dim count As String = templateArray(iPtr + 1).Substring(16, templateArray(iPtr + 1).Length - 16)
If (IsNumeric(count)) Then
Dim relativeLevel As Integer = Null.NullInteger
For Each objCategoryItem As CategoryInfo In _objCategoriesAll
If (objCategoryItem.CategoryID = objCategory.CategoryID) Then
relativeLevel = objCategoryItem.Level
End If
Next
Dim level As Integer = Null.NullInteger
Dim i As Integer = 0
For Each objCategoryItem As CategoryInfo In _objCategoriesAll
If (level <> Null.NullInteger AndAlso objCategoryItem.Level <= level) Then
Exit For
End If
If (objCategoryItem.CategoryID = objCategory.CategoryID) Then
level = objCategoryItem.Level
Else
If (level <> Null.NullInteger) Then
If (objCategoryItem.Level > level And ((objCategoryItem.Level - relativeLevel) <= Convert.ToInt32(count))) Then
ProcessCategoryChild(objCategoryItem, objPlaceHolder, "ChildCategory" & i.ToString() & "-" & iPtr.ToString(), layoutCategoryChild.Tokens(), relativeLevel)
i = i + 1
End If
End If
End If
Next
End If
End If
If (templateArray(iPtr + 1).ToUpper().StartsWith("DESCRIPTION:")) Then
Dim description As String = Server.HtmlDecode(objCategory.Description)
If (IsNumeric(templateArray(iPtr + 1).Substring(12, templateArray(iPtr + 1).Length - 12))) Then
Dim length As Integer = Convert.ToInt32(templateArray(iPtr + 1).Substring(12, templateArray(iPtr + 1).Length - 12))
If (StripHtml(Server.HtmlDecode(objCategory.Description)).TrimStart().Length > length) Then
description = Left(StripHtml(Server.HtmlDecode(objCategory.Description)).TrimStart(), length) & "..."
Else
description = Left(StripHtml(Server.HtmlDecode(objCategory.Description)).TrimStart(), length)
End If
End If
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID("Category-" & iPtr.ToString())
objLiteral.Text = description
objPlaceHolder.Add(objLiteral)
Exit Select
End If
If (templateArray(iPtr + 1).ToUpper().StartsWith("ISDEPTHABS:")) Then
Dim depth As String = templateArray(iPtr + 1).Substring(11, templateArray(iPtr + 1).Length - 11)
Dim isDepth As Boolean = False
For Each item As String In depth.Split(","c)
If (IsNumeric(item)) Then
For Each objCategoryItem As CategoryInfo In _objCategoriesAll
If (objCategoryItem.CategoryID = objCategory.CategoryID) Then
If (objCategoryItem.Level = Convert.ToInt32(item)) Then
isDepth = True
End If
End If
Next
End If
Next
Dim endToken As String = "/" & templateArray(iPtr + 1)
If (isDepth = False) Then
While (iPtr < templateArray.Length - 1)
If (templateArray(iPtr + 1) = endToken) Then
Exit While
End If
iPtr = iPtr + 1
End While
End If
End If
If (templateArray(iPtr + 1).ToUpper().StartsWith("ISNOTDEPTHABS:")) Then
Dim depth As String = templateArray(iPtr + 1).Substring(14, templateArray(iPtr + 1).Length - 14)
Dim isDepth As Boolean = False
For Each item As String In depth.Split(","c)
If (IsNumeric(item)) Then
For Each objCategoryItem As CategoryInfo In _objCategoriesAll
If (objCategoryItem.CategoryID = objCategory.CategoryID) Then
If (objCategoryItem.Level = Convert.ToInt32(item)) Then
isDepth = True
End If
End If
Next
End If
Next
Dim endToken As String = "/" & templateArray(iPtr + 1)
If (isDepth = True) Then
While (iPtr < templateArray.Length - 1)
If (templateArray(iPtr + 1) = endToken) Then
Exit While
End If
iPtr = iPtr + 1
End While
End If
End If
If (templateArray(iPtr + 1).ToUpper().StartsWith("IMAGETHUMB:")) Then
If (objCategory.Image <> "") Then
If (objCategory.Image.Split("="c).Length = 2) Then
If (IsNumeric(objCategory.Image.Split("="c)(1))) Then
Dim objFile As DotNetNuke.Services.FileSystem.FileInfo = FileManager.Instance.GetFile(Convert.ToInt32(objCategory.Image.Split("="c)(1)))
If (objFile IsNot Nothing) Then
Dim val As String = templateArray(iPtr + 1).Substring(11, templateArray(iPtr + 1).Length - 11)
If (val.IndexOf(":"c) = -1) Then
Dim length As Integer = Convert.ToInt32(val)
Dim objImage As New Image
If (ArticleSettings.ImageThumbnailType = ThumbnailType.Proportion) Then
objImage.ImageUrl = Page.ResolveUrl("~/DesktopModules/DnnForge - NewsArticles/ImageHandler.ashx?Width=" & length.ToString() & "&Height=" & length.ToString() & "&HomeDirectory=" & Server.UrlEncode(PortalSettings.HomeDirectory & objFile.Folder) & "&FileName=" & Server.UrlEncode(objFile.FileName) & "&PortalID=" & PortalId.ToString() & "&q=1")
Else
objImage.ImageUrl = Page.ResolveUrl("~/DesktopModules/DnnForge - NewsArticles/ImageHandler.ashx?Width=" & length.ToString() & "&Height=" & length.ToString() & "&HomeDirectory=" & Server.UrlEncode(PortalSettings.HomeDirectory & objFile.Folder) & "&FileName=" & Server.UrlEncode(objFile.FileName) & "&PortalID=" & PortalId.ToString() & "&q=1&s=1")
End If
objImage.EnableViewState = False
objPlaceHolder.Add(objImage)
Else
Dim arr() As String = val.Split(":"c)
Dim width As Integer = Convert.ToInt32(val.Split(":"c)(0))
Dim height As Integer = Convert.ToInt32(val.Split(":"c)(1))
Dim objImage As New Image
If (ArticleSettings.ImageThumbnailType = ThumbnailType.Proportion) Then
objImage.ImageUrl = Page.ResolveUrl("~/DesktopModules/DnnForge - NewsArticles/ImageHandler.ashx?Width=" & width.ToString() & "&Height=" & height.ToString() & "&HomeDirectory=" & Server.UrlEncode(PortalSettings.HomeDirectory & objFile.Folder) & "&FileName=" & Server.UrlEncode(objFile.FileName) & "&PortalID=" & PortalId.ToString() & "&q=1")
Else
objImage.ImageUrl = Page.ResolveUrl("~/DesktopModules/DnnForge - NewsArticles/ImageHandler.ashx?Width=" & width.ToString() & "&Height=" & height.ToString() & "&HomeDirectory=" & Server.UrlEncode(PortalSettings.HomeDirectory & objFile.Folder) & "&FileName=" & Server.UrlEncode(objFile.FileName) & "&PortalID=" & PortalId.ToString() & "&q=1&s=1")
End If
objImage.EnableViewState = False
objPlaceHolder.Add(objImage)
End If
End If
End If
End If
End If
End If
If (templateArray(iPtr + 1).ToUpper().StartsWith("PARENTDESCRIPTION:")) Then
If (objParentCategory IsNot Nothing) Then
Dim description As String = Server.HtmlDecode(objParentCategory.Description)
If (IsNumeric(templateArray(iPtr + 1).Substring(18, templateArray(iPtr + 1).Length - 18))) Then
Dim length As Integer = Convert.ToInt32(templateArray(iPtr + 1).Substring(18, templateArray(iPtr + 1).Length - 18))
If (StripHtml(Server.HtmlDecode(objParentCategory.Description)).TrimStart().Length > length) Then
description = Left(StripHtml(Server.HtmlDecode(objParentCategory.Description)).TrimStart(), length) & "..."
Else
description = Left(StripHtml(Server.HtmlDecode(objParentCategory.Description)).TrimStart(), length)
End If
End If
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID("Category-" & iPtr.ToString())
objLiteral.Text = description
objPlaceHolder.Add(objLiteral)
Exit Select
End If
End If
End Select
End If
Next
End Sub
Private Sub ReadQueryString()
If (Request(PARAM_CATEGORY_ID) <> "" AndAlso IsNumeric(Request(PARAM_CATEGORY_ID))) Then
_categoryID = Convert.ToInt32(Request(PARAM_CATEGORY_ID))
Else
If (ArticleSettings.FilterSingleCategory <> Null.NullInteger) Then
_categoryID = ArticleSettings.FilterSingleCategory
End If
End If
End Sub
#End Region
#Region " Event Handlers "
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
Try
ReadQueryString()
Dim objCategoryController As New CategoryController
_objCategoriesAll = objCategoryController.GetCategoriesAll(Me.ModuleId, Null.NullInteger, ArticleSettings.CategorySortType)
If (Request("articleType") <> "" AndAlso Request("articleType").ToLower() = "categoryview") Then
For Each objCategory As CategoryInfo In _objCategoriesAll
If (objCategory.CategoryID = _categoryID) Then
If (ArticleSettings.FilterSingleCategory = objCategory.CategoryID) Then
Exit For
End If
Dim path As String = ""
If (ArticleSettings.CategoryBreadcrumb) Then
Dim objTab As New DotNetNuke.Entities.Tabs.TabInfo
objTab.TabName = objCategory.Name
objTab.Url = Common.GetCategoryLink(TabId, ModuleId, objCategory.CategoryID.ToString(), objCategory.Name, ArticleSettings.LaunchLinks, ArticleSettings)
PortalSettings.ActiveTab.BreadCrumbs.Add(objTab)
Dim parentID As Integer = objCategory.ParentID
Dim parentCount As Integer = 0
While parentID <> Null.NullInteger
For Each objParentCategory As CategoryInfo In _objCategoriesAll
If (objParentCategory.CategoryID = parentID) Then
If (ArticleSettings.FilterSingleCategory = objParentCategory.CategoryID) Then
parentID = Null.NullInteger
Exit For
End If
Dim objParentTab As New DotNetNuke.Entities.Tabs.TabInfo
objParentTab.TabID = 10000 + objParentCategory.CategoryID
objParentTab.TabName = objParentCategory.Name
objParentTab.Url = Common.GetCategoryLink(TabId, ModuleId, objParentCategory.CategoryID.ToString(), objParentCategory.Name, ArticleSettings.LaunchLinks, ArticleSettings)
PortalSettings.ActiveTab.BreadCrumbs.Insert(PortalSettings.ActiveTab.BreadCrumbs.Count - 1 - parentCount, objParentTab)
If (path.Length = 0) Then
path = " > " & objParentCategory.Name
Else
path = " > " & objParentCategory.Name & path
End If
parentCount = parentCount + 1
parentID = objParentCategory.ParentID
End If
Next
End While
End If
If (Request("articleType") <> "" AndAlso Request("articleType").ToLower() = "categoryview") Then
If (PortalSettings.ActiveTab.Title.Length = 0) Then
Me.BasePage.Title = Server.HtmlEncode(PortalSettings.PortalName & " > " & PortalSettings.ActiveTab.TabName & path & " > " & objCategory.Name)
Else
Me.BasePage.Title = Server.HtmlEncode(PortalSettings.ActiveTab.Title & path & " > " & objCategory.Name)
End If
If (objCategory.MetaTitle <> "") Then
Me.BasePage.Title = objCategory.MetaTitle
End If
If (objCategory.MetaDescription <> "") Then
Me.BasePage.Description = objCategory.MetaDescription
End If
If (objCategory.MetaKeywords <> "") Then
Me.BasePage.KeyWords = objCategory.MetaKeywords
End If
End If
If (ArticleSettings.IncludeInPageName) Then
HttpContext.Current.Items.Add("NA-CategoryName", objCategory.Name)
End If
Exit For
End If
Next
End If
BindCategory()
Dim categories() As Integer = {_categoryID}
Listing1.FilterCategories = categories
If (ArticleSettings.FilterSingleCategory <> Null.NullInteger) Then
Listing1.ShowExpired = False
Else
Listing1.ShowExpired = True
End If
Listing1.MaxArticles = Null.NullInteger
Listing1.ShowMessage = False
If (ArticleSettings.CategoryBreadcrumb AndAlso Request("CategoryID") <> "") Then
Listing1.IncludeCategory = True
End If
Listing1.BindListing()
Listing1.BindArticles = False
Listing1.IsIndexed = False
'Listing1.BindListing()
'ucHeader1.ProcessMenu()
'ucHeader2.ProcessMenu()
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Private Sub Page_PreRender(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.PreRender
Try
If (HttpContext.Current.Items.Contains("NA-CategoryName")) Then
PortalSettings.ActiveTab.TabName = HttpContext.Current.Items("NA-CategoryName").ToString()
End If
Catch ex As Exception
End Try
End Sub
#End Region
End Class
End Namespace