-
Notifications
You must be signed in to change notification settings - Fork 24
/
RssComments.aspx.vb
executable file
·232 lines (156 loc) · 9.82 KB
/
RssComments.aspx.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
'
' News Articles for DotNetNuke - http://www.dotnetnuke.com
' Copyright (c) 2002-2007
' by Ventrian ( [email protected] ) ( http://www.ventrian.com )
'
Imports System.Text
Imports System.Web
Imports DotNetNuke.Common
Imports DotNetNuke.Common.Utilities
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Entities.Portals
Namespace Ventrian.NewsArticles
Partial Public Class RssComments
Inherits Page
#Region " Private Members "
Private m_articleID As Integer = Null.NullInteger
Private m_tabID As Integer = Null.NullInteger
Private m_TabInfo As DotNetNuke.Entities.Tabs.TabInfo
Private m_moduleID As Integer = Null.NullInteger
#End Region
#Region " Private Methods "
Private Sub ProcessHeaderFooter(ByRef objPlaceHolder As ControlCollection, ByVal templateArray As String())
For iPtr As Integer = 0 To templateArray.Length - 1 Step 2
objPlaceHolder.Add(New LiteralControl(templateArray(iPtr).ToString()))
If iPtr < templateArray.Length - 1 Then
Select Case templateArray(iPtr + 1)
Case "PORTALEMAIL"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID("Rss-" & iPtr.ToString())
objLiteral.Text = PortalController.Instance.GetCurrentPortalSettings().Email
objPlaceHolder.Add(objLiteral)
Case "PORTALNAME"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID("Rss-" & iPtr.ToString())
objLiteral.Text = Server.HtmlEncode(PortalController.Instance.GetCurrentPortalSettings().PortalName)
objPlaceHolder.Add(objLiteral)
Case "PORTALURL"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID("Rss-" & iPtr.ToString())
objLiteral.Text = Server.HtmlEncode(AddHTTP(PortalController.Instance.GetCurrentPortalSettings().PortalAlias.HTTPAlias))
objPlaceHolder.Add(objLiteral)
End Select
End If
Next
End Sub
Private Sub ProcessItem(ByRef objPlaceHolder As ControlCollection, ByVal templateArray As String(), ByVal objArticle As ArticleInfo, ByVal objComment As CommentInfo, ByVal articleSettings As ArticleSettings)
Dim portalSettings As PortalSettings = PortalController.Instance.GetCurrentPortalSettings()
For iPtr As Integer = 0 To templateArray.Length - 1 Step 2
objPlaceHolder.Add(New LiteralControl(templateArray(iPtr).ToString()))
If iPtr < templateArray.Length - 1 Then
Select Case templateArray(iPtr + 1)
Case "CREATEDATE"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID("RssComment-" & objComment.CommentID.ToString() & iPtr.ToString())
objLiteral.Text = objComment.CreatedDate.ToUniversalTime().ToString("r")
objPlaceHolder.Add(objLiteral)
Case "DESCRIPTION"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID("RssComment-" & objComment.CommentID.ToString() & iPtr.ToString())
objLiteral.Text = Server.HtmlEncode(objComment.Comment)
objPlaceHolder.Add(objLiteral)
Case "GUID"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID("RssComment-" & objComment.CommentID.ToString() & iPtr.ToString())
objLiteral.Text = "f1397696-738c-4295-afcd-943feb885714:" & objComment.CommentID.ToString()
objPlaceHolder.Add(objLiteral)
Case "TITLE"
Dim objLiteral As New Literal
objLiteral.ID = Globals.CreateValidID("RssComment-" & objComment.CommentID.ToString() & iPtr.ToString())
objLiteral.Text = Server.HtmlEncode(objArticle.Title)
objPlaceHolder.Add(objLiteral)
Case Else
Dim objLiteralOther As New Literal
objLiteralOther.ID = Globals.CreateValidID("RssComment-" & objComment.CommentID.ToString() & iPtr.ToString())
objLiteralOther.Text = "[" & templateArray(iPtr + 1) & "]"
objLiteralOther.EnableViewState = False
objPlaceHolder.Add(objLiteralOther)
End Select
End If
Next
End Sub
Private Sub ReadQueryString()
If (Request("ArticleID") <> "") Then
If (IsNumeric(Request("ArticleID"))) Then
m_articleID = Convert.ToInt32(Request("ArticleID"))
End If
End If
If (Request("TabID") <> "") Then
If (IsNumeric(Request("TabID"))) Then
m_tabID = Convert.ToInt32(Request("TabID"))
Dim objTabController As New DotNetNuke.Entities.Tabs.TabController
m_TabInfo = objTabController.GetTab(m_tabID, Globals.GetPortalSettings().PortalId, False)
End If
End If
If (Request("ModuleID") <> "") Then
If (IsNumeric(Request("ModuleID"))) Then
m_moduleID = Convert.ToInt32(Request("ModuleID"))
End If
End If
End Sub
Private Function RenderControlToString(ByVal ctrl As Control) As String
Dim sb As New StringBuilder()
Dim tw As New IO.StringWriter(sb)
Dim hw As New HtmlTextWriter(tw)
ctrl.RenderControl(hw)
Return sb.ToString()
End Function
#End Region
#Region " Event Handlers "
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ReadQueryString()
Dim launchLinks As Boolean = False
Dim enableSyndicationHtml As Boolean = False
Dim _portalSettings As PortalSettings = CType(HttpContext.Current.Items("PortalSettings"), PortalSettings)
Dim objModuleController As New ModuleController
Dim objModule As ModuleInfo = objModuleController.GetModule(m_moduleID, m_tabID)
Dim articleSettings As ArticleSettings
If Not (objModule Is Nothing) Then
Dim settings As Hashtable = objModule.TabModuleSettings
articleSettings = New ArticleSettings(settings, _portalSettings, objModule)
If (settings.Contains(ArticleConstants.LAUNCH_LINKS)) Then
launchLinks = Convert.ToBoolean(settings(ArticleConstants.LAUNCH_LINKS).ToString())
End If
If (settings.Contains(ArticleConstants.ENABLE_SYNDICATION_HTML_SETTING)) Then
enableSyndicationHtml = Convert.ToBoolean(settings(ArticleConstants.ENABLE_SYNDICATION_HTML_SETTING).ToString())
End If
If (settings.Contains(ArticleConstants.DISPLAY_MODE)) Then
End If
Response.ContentType = "text/xml"
Response.ContentEncoding = Encoding.UTF8
Dim objArticleController As New ArticleController()
Dim objArticle As ArticleInfo = objArticleController.GetArticle(m_articleID)
Dim objLayoutController As New LayoutController(_portalSettings, articleSettings, objModule, Page)
' Dim objLayoutController As New LayoutController(_portalSettings, articleSettings, Me, False, m_tabID, m_moduleID, objModule.TabModuleID, _portalSettings.PortalId, Null.NullInteger, Null.NullInteger, "RssComment-" & m_tabID.ToString())
Dim layoutHeader As LayoutInfo = LayoutController.GetLayout(articleSettings, objModule, Page, LayoutType.Rss_Comment_Header_Html)
Dim layoutItem As LayoutInfo = LayoutController.GetLayout(articleSettings, objModule, Page, LayoutType.Rss_Comment_Item_Html)
Dim layoutFooter As LayoutInfo = LayoutController.GetLayout(articleSettings, objModule, Page, (LayoutType.Rss_Comment_Footer_Html))
Dim phRSS As New PlaceHolder
ProcessHeaderFooter(phRSS.Controls, layoutHeader.Tokens)
Dim objCommentController As CommentController = New CommentController
Dim commentList As List(Of CommentInfo) = objCommentController.GetCommentList(m_moduleID, m_articleID, True, SortDirection.Ascending, Null.NullInteger)
For Each objComment As CommentInfo In commentList
Dim delimStr As String = "[]"
Dim delimiter As Char() = delimStr.ToCharArray()
Dim phItem As New PlaceHolder
ProcessItem(phItem.Controls, layoutItem.Tokens, objArticle, objComment, articleSettings)
objLayoutController.ProcessComment(phRSS.Controls, objArticle, objComment, RenderControlToString(phItem).Split(delimiter))
Next
ProcessHeaderFooter(phRSS.Controls, layoutFooter.Tokens)
Response.Write(RenderControlToString(phRSS))
End If
Response.End()
End Sub
#End Region
End Class
End Namespace