-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharticledetail.aspx.cs
234 lines (201 loc) · 8.35 KB
/
articledetail.aspx.cs
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
#region XD World Recipe V 2.8
// FileName: articledetail.cs
// Author: Dexter Zafra
// Date Created: 2/28/2009
// Website: www.ex-designz.net
#endregion
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using XDRecipe.UI;
using XDRecipe.BL;
using XDRecipe.BL.Providers.Article;
using XDRecipe.Common;
using XDRecipe.Model;
using XDRecipe.BL.Providers.User;
using XDRecipe.Security;
using XDRecipe.BL.Providers.Comments;
using XDRecipe.Common.Utilities;
using XDRecipe.Security;
public partial class articledetail : BasePage
{
public int ArtCatId;
public string strCatName;
public string strArtTitle;
public string strBookmarkURL;
public int ArticleSection;
public int ArticleID;
public string strAuthor;
private Utility Util
{
get { return new Utility(); }
}
protected void Page_Load(object sender, EventArgs e)
{
ProviderArticleDetails Article = new ProviderArticleDetails();
ArticleID = (int)Util.Val(Request.QueryString["aid"]);
Article.Approved = constant.Approved;
Article.FillUp(ArticleID);
if (!string.IsNullOrEmpty(Article.Content))
lblwordcount.Text = Utility.WordCount(Article.Content).ToString();
CommentLink.Text = "Comments (" + Article.CountComments + ")";
CommentLink.Attributes.Add("onmouseover", "Tip('Read or write comments.', BGCOLOR, '#FFFBE1', BORDERCOLOR, '#acc6db')");
CommentLink.Attributes.Add("onmouseout", "UnTip()");
lbcountcomment.Text = Article.CountComments.ToString();
lbtitle.Text = Article.Title;
lbcontent.Text = Article.Content;
lbhits.Text = string.Format("{0:#,###}", Article.Hits);
lbauthor.Text = "<a class='content2' title='View author complete profile.' href=userprofile.aspx?uid=" + Article.UID + ">" + Article.Author + "</a>";
lblrating.Text = Article.Rating;
lblvotescount.Text = Article.NoRates;
starimage.ImageUrl = Utility.GetStarImage(Article.Rating);
lbldate.Text = Utility.FormatDate(Article.Date);
lbauthor.Attributes.Add("onmouseover", "Tip('View <b>" + Article.Author + "</b> profile.', BGCOLOR, '#FFFBE1', BORDERCOLOR, '#acc6db')");
lbauthor.Attributes.Add("onmouseout", "UnTip()");
strBookmarkURL = Bookmark.URL;
strAuthor = Article.Author;
strArtTitle = Article.Title;
strCatName = Article.Category;
ArtCatId = Article.CatID;
ArticleSection = constant.intArticle;
ShowEditLink(Article);
GetMetaTitleTagKeywords(Article);
GetUserCookingArticleRating(ArticleID);
GetRelatedArticle(Article);
GetOtherArticleByThisAuthor(Article);
GetComments(ArticleID);
ShowCommentFormIfLogin();
Article = null;
}
private void ShowEditLink(ProviderArticleDetails Article)
{
if (Authentication.IsUserAuthenticated && Article.UID == UserIdentity.UserID)
{
editarticlelink.Visible = true;
editarticlelink.Text = "<img src='images/icon_pencil.gif' alt='Edit' border='0'> Edit";
editarticlelink.NavigateUrl = "editarticle.aspx?aid=" + Article.ID;
editarticlelink.Attributes.Add("onmouseover", "Tip('Edit my submitted <b>" + Article.Title + "</b> article.', BGCOLOR, '#FFFBE1', BORDERCOLOR, '#acc6db')");
editarticlelink.Attributes.Add("onmouseout", "UnTip()");
}
}
private void ShowCommentFormIfLogin()
{
if (Authentication.IsUserAuthenticated)
{
Panel3.Visible = true;
lbllogintocomment.Visible = false;
AUTHOR.Value = UserIdentity.UserName;
EMAIL.Value = UserIdentity.UserEmail;
lblUsernameComment.Text = UserIdentity.UserName;
lbluserCommentEmail.Text = UserIdentity.UserEmail;
}
else
{
Panel3.Visible = false;
lbllogintocomment.Visible = true;
lbllogintocomment.Text = "To be able to leave a comment please login at the top right corner or " + "<a href='registration.aspx'>Register</a>.";
}
}
private void GetRelatedArticle(ProviderArticleDetails Article)
{
ProviderRalatedArticle GetRelatedArticle = ProviderRalatedArticle.GetInstance();
GetRelatedArticle.Param(Article.CatID, Article.ID);
if (GetRelatedArticle.RecordCount > 1)
{
PanelRelatedArticle.Visible = true;
RelatedArticle.DataSource = GetRelatedArticle.GetArticle();
RelatedArticle.DataBind();
}
}
private void GetOtherArticleByThisAuthor(ProviderArticleDetails Article)
{
ProviderOtherArticleByThisAuthor GetOtherArticle = ProviderOtherArticleByThisAuthor.GetInstance();
GetOtherArticle.Param(Article.UID, Article.ID);
if (GetOtherArticle.RecordCount > 1)
{
PanelOtherArticleByAuthor.Visible = true;
OtherArticleByThisAuthor.DataSource = GetOtherArticle.GetArticle();
OtherArticleByThisAuthor.DataBind();
}
}
private void GetUserCookingArticleRating(int AID)
{
CookieRating GetCookie = new CookieRating(constant.intArticle, AID, PlaceHolder2);
GetCookie.GetUserCookieRating();
GetCookie = null;
}
private void GetComments(int AID)
{
ArticleComments Comment = new ArticleComments(AID, RecComments, PlaceHolder2);
Comment.FillUp();
Comment = null;
}
private void GetMetaTitleTagKeywords(ProviderArticleDetails Article)
{
Page.Header.Title = Article.Title + "," + Article.Category + " article";
HtmlMeta metaTag = new HtmlMeta();
metaTag.Name = "Keywords";
metaTag.Content = Article.Title + "," + Article.Category + ", cooking article";
this.Header.Controls.Add(metaTag);
}
public void Add_Comment(Object s, EventArgs e)
{
if (Authentication.IsUserAuthenticated)
{
if (Page.IsValid && (txtsecfield.Text.ToString() == Session["randomStr"].ToString()))
{
ArticleCommentsRepository comment = new ArticleCommentsRepository();
comment.ID = (int)Util.Val(Request.QueryString["aid"]);
comment.UID = UserIdentity.UserID;
comment.Author = Util.FormatTextForInput(Request.Form[AUTHOR.UniqueID]);
comment.Email = Util.FormatTextForInput(Request.Form[EMAIL.UniqueID]);
comment.Comments = Util.FormatTextForInput(Request.Form[COMMENTS.UniqueID]);
if (comment.Comments.Length == 0)
{
lbvalenght.Text = "<br>Error: Comment is empty, please enter your comment.";
lbvalenght.Visible = true;
txtsecfield.Text = "";
return;
}
if (comment.Comments.Length > 350)
{
lbvalenght.Text = "<br>Error: Comments is too long. Max of 350 characters.";
lbvalenght.Visible = true;
txtsecfield.Text = "";
return;
}
if (comment.Add(comment) != 0)
{
lbvalenght.Text = "A database error occured while processing your comment.";
return;
}
EmailCommentNotificationToAdministrator(comment.ID, strArtTitle);
comment = null;
Response.Redirect("commentpostconfirmation.aspx?ReturnURL=" + this.Request.Url.PathAndQuery);
}
else
{
lbvalenght.Text = "<br>Invalid security code. Make sure you type it correctly.";
lbvalenght.Visible = true;
txtsecfield.Text = "";
lblinvalidsecode.Text = "Invalid security code. Make sure you type it correctly.";
lblinvalidsecode.Visible = true;
}
}
}
private void EmailCommentNotificationToAdministrator(int ID, string Title)
{
EmailTemplate SendEmail = new EmailTemplate();
SendEmail.ItemID = ID;
SendEmail.ItemName = Title;
SendEmail.SendEmailArticleCommentNotify();
SendEmail = null;
}
}