/
lyricdetail.aspx.cs
338 lines (292 loc) · 28.7 KB
/
lyricdetail.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
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
#region XD World Lyric V 2.8
// FileName: Recipedetail.cs
// Author: Dexter Zafra
// Date Created: 5/23/2008
// 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 VGuitar.UI;
using VGuitar.BL;
using VGuitar.BL.Providers.Lyrics;
using VGuitar.BL.Providers.Comments;
using VGuitar.BL.Providers.User;
using VGuitar.Common;
using VGuitar.Model;
using VGuitar.BL.Providers.CookBooks;
using VGuitar.Common.Utilities;
using VGuitar.Security;
using System.Text;
public partial class lyricdetail : BasePage
{
public string strRName;
public string strCName;
public string strCreateBy;
public int iUserID;
public int RecCatId;
public string strBookmarkURL;
public string strLyricImage;
public int LyricSection;
public string strAddCookBookURL;
public string strAddCookbookLinkTooltip;
public string strAddCookBookURLWithJavaScriptCall;
public DateTime dateposted;
private Utility Util
{
get { return new Utility(); }
}
protected void Page_Load(object sender, EventArgs e)
{
LyricDetails lyric = new LyricDetails();
int LyricID = (int)Util.Val(Request.QueryString["id"]);
lyric.Approved = constant.ApprovedLyric;
lyric.FillUp(LyricID);
RecCatId = lyric.CatID;
strRName = lyric.LyricName;
strCName = lyric.Category;
LyricSection = constant.intLyric;
dateposted = lyric.Date;
strCreateBy = lyric.CreateBy;
iUserID = lyric.UID;
CommentLink.Text = "Lời bình (" + lyric.CountComments + ")";
CommentLink.Attributes.Add("onmouseover", "Tip('Đọc và viết lời bình cho bài hát này.', BGCOLOR, '#FFFBE1', BORDERCOLOR, '#acc6db')");
CommentLink.Attributes.Add("onmouseout", "UnTip()");
lbcountcomment.Text = lyric.CountComments.ToString();
lblname.Text = lyric.LyricName;
//lblauthor.Text = "<a href=" + "userprofile.aspx?uid=" + lyric.UID + ">" + lyric.Author + "</a>";
lblhits.Text = string.Format("{0:#,###}", lyric.Hits);
lblrating.Text = lyric.Rating;
lblvotescount.Text = lyric.NoRates;
lblcategorytop.Text = lyric.Category;
lbldate.Text = Utility.FormatDate(lyric.Date);
lblIngredients.Text = lyric.Ingredients;
lblInstructions.Text = lyric.Instructions;
starimage.ImageUrl = Utility.GetStarImage(lyric.Rating);
lblMediaPlayer.Text = GetAllMediaPlayer(lyric.UrlMusic,lyric.UrlChacha,lyric.UrlZing,lyric.UrlYoutube);
//lblauthor.Attributes.Add("onmouseover", "Tip('Xem tất cả bài hát đăng bởi <b>" + lyric.Author + "</b>.', BGCOLOR, '#FFFBE1', BORDERCOLOR, '#acc6db')");
//lblauthor.Attributes.Add("onmouseout", "UnTip()");
//lblauthor.Attributes.Add("onclick", "Popup('AjaxRequest/popUpAjax.aspx?uid=" + lyric.UID + "&author=" + lyric.Author + "',this);return false");
strBookmarkURL = Bookmark.URL;
GetMetaKeywords(DynamicKeywords.Keywords(constant.intLyricDynamicKeywordDetails, "Bài hát " + lyric.LyricName.ToString() + " thể loại " + lyric.Category.ToString()));
ShowLyricImage(LyricID);
AddToCookBookLinkButton(lyric.LyricName);
ShowEditLink(lyric);
ShowNewPopularImage(LyricID);
GetRelatedLyrics(lyric.CatID);
GetUserLyricCookieRating(LyricID);
GetComments(LyricID);
ShowCommentFormIfLogin();
lyric = null;
}
private string GetMediaPlayer(string url)
{
string result = "";
result = "<object classid=\"clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" width=\"340\" height=\"64\">";
result = result + "<param value=\" " + url + "\" name=\"FILENAME\">";
result = result + "<param value=\"true\" name=\"ShowStatusBar\">";
result = result + "<param value=\"false\" name=\"AutoStart\">";
result = result + "<embed type=\"application/x-mplayer2\" src=\"" + url + "\" showstatusbar=\"1\" autostart=\"0\" width=\"380\" height=\"64\">";
result = result + "</object>";
return result;
}
private string GetWebPlayer(string url)
{
string result = "";
result = result + "<object id=\"myPlayer\" data=\"webplayer.swf\" type=\"application/x-shockwave-flash\" width=\"280\" height=\"32\">";
result = result + "<param name=\"movie\" value=\"webplayer.swf\">";
result = result + "<param name=\"menu\" value=\"false\">";
result = result + "<param name=\"scale\" value=\"noscale\">";
result = result + "<param name=\"wmode\" value=\"transparent\">";
//result = result + "<param name=\"bgcolor\" value=\"#C0C0C0\">";
result = result + "<param name=\"flashvars\" value=\"src=" + url + "&autostart=no&loop=no&random=no&remote=no&debug=no\">";
result = result + "</object>";
return result;
}
private string GetAllMediaPlayer(string url,string chacha,string zing , string youtube)
{
StringBuilder result = new StringBuilder();
result.Append("<div onClick=\"javascript:Player('" + url + "');\" href=\"javascript:void(0);\" style=\"cursor: pointer; height: 28px; text-align: center; float: left ;padding-right:10px\">Mặc định</div>");
result.Append(System.Environment.NewLine);
result.Append("<div onClick=\"javascript:zing('" + zing + "');\" href=\"javascript:void(0);\" style=\"cursor: pointer; height: 28px;text-align: center; float: left;padding-right:10px\">Zing</div>");
result.Append(System.Environment.NewLine);
result.Append("<div onClick=\"javascript:chacha('" + chacha + "');\" href=\"javascript:void(0);\" style=\"cursor: pointer; height: 28px; text-align: center; float: left; padding-right:10px\">Chacha</div>");
result.Append(System.Environment.NewLine);
result.Append("<div onClick=\"javascript:youtube('" + youtube + "');\" href=\"javascript:void(0);\" style=\"cursor: pointer; height: 28px; text-align: center; float: left;\">Youtube</div>");
result.Append(System.Environment.NewLine);
result.Append("<div style=\"clear: both; display: block;\" id=\"chacha_audio\"><a class=\"media\" href=\"" + url + "\"></a></div>");
result.Append(System.Environment.NewLine);
return result.ToString();
}
private void AddToCookBookLinkButton(string LyricName)
{
if (Authentication.IsUserAuthenticated)
{
UsersCookBookMain UserCookBook = new UsersCookBookMain(UserIdentity.UserID);
int NumRecordsCookBookAllowed = SiteConfiguration.GetConfiguration.NumberOfLyricInFavorite;
addtoCookBook.Visible = false;
LinkButtonAddtoCookBookLogin.Visible = true;
if (UserCookBook.TotalCount > NumRecordsCookBookAllowed)
{
LinkButtonAddtoCookBookLogin.Text = "Ghi nhớ";
LinkButtonAddtoCookBookLogin.Attributes.Add("onclick", "csscody.alert('<b>Không được phép nhớ bài hát</b><br>Bạn không thể nhớ bất cứ bài hát nào. Bạn đã đạt đến số lượng tối đa của các khoá được cho phép để lưu vào mục yêu thích.');return false;");
LinkButtonAddtoCookBookLogin.Attributes.Add("onmouseover", "Tip('Không thể lưu tiếp các công thức. Bạn đã đạt đến mức tối đa được phép.', BGCOLOR, '#FFFBE1', BORDERCOLOR, '#acc6db')");
LinkButtonAddtoCookBookLogin.Attributes.Add("onmouseout", "UnTip()");
}
else
{
LinkButtonAddtoCookBookLogin.Text = "Ghi nhớ";
LinkButtonAddtoCookBookLogin.Attributes.Add("onmouseover", "Tip('Thêm bài hát(<b>" + LyricName + "</b>) Vào mục yêu thích.', BGCOLOR, '#FFFBE1', BORDERCOLOR, '#acc6db')");
LinkButtonAddtoCookBookLogin.Attributes.Add("onmouseout", "UnTip()");
}
UserCookBook = null;
}
else
{
addtoCookBook.Visible = true;
saveicon.AlternateText = "Ghi nhớ";
addtoCookBook.Text = "<a href='javascript:void(0)'>Ghi nhớ</a>";
addtoCookBook.Attributes.Add("onclick", "csscody.alert('<b>Không cho phép bài hát đó</b><br>Đăng nhập để thêm bài hát (<b>" + LyricName + "</b>) vào mục yêu thích.');return false;");
addtoCookBook.Attributes.Add("onmouseover", "Tip('Đăng nhập để thêm bài hát đó vào mục yêu thích.', BGCOLOR, '#FFFBE1', BORDERCOLOR, '#acc6db')");
addtoCookBook.Attributes.Add("onmouseout", "UnTip()");
}
}
private void ShowLyricImage(int LyricID)
{
Lyricimage.Visible = false;
string strLyricImage = GetLyricImage.GetImageForLyricDetails(LyricID);
if (!string.IsNullOrEmpty(strLyricImage))
{
Lyricimage.Visible = true;
Lyricimage.ImageUrl = strLyricImage.ToString();
}
}
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 = "Hãy đăng nhập để có thể thêm lời bình, nếu bạn chưa có tài khoản, hãy nhấn vào đây để " + "<a href='registration.aspx'>Đăng ký</a> một tài khoản trên hệ thống.";
}
}
private void ShowEditLink(LyricDetails lyric)
{
if (Authentication.IsUserAuthenticated && lyric.UID == UserIdentity.UserID)
{
editLyriclink.Visible = true;
editLyriclink.Text = "<img src='images/icon_pencil.gif' alt='Sửa' border='0'> Sửa";
editLyriclink.NavigateUrl = "editlyric.aspx?id=" + lyric.ID;
editLyriclink.Attributes.Add("onmouseover", "Tip('Sửa thông tin của bài hát <b>" + lyric.LyricName + "</b>.', BGCOLOR, '#FFFBE1', BORDERCOLOR, '#acc6db')");
editLyriclink.Attributes.Add("onmouseout", "UnTip()");
}
}
public void Add_CookBook(Object s, EventArgs e)
{
if (Authentication.IsUserAuthenticated)
{
int LyricID = (int)Util.Val(Request.QueryString["id"]);
Caching.PurgeCacheItems("MyCookBook_SideMenu_" + UserIdentity.UserID);
Blogic.InsertLyricToFavorite(UserIdentity.UserID, LyricID);
Response.Redirect("myfavorite.aspx");
}
}
private void GetUserLyricCookieRating(int LyricID)
{
CookieRating GetCookie = new CookieRating(constant.intLyric, LyricID, PlaceHolder1);
GetCookie.GetUserCookieRating();
GetCookie = null;
}
private void ShowNewPopularImage(int LyricID)
{
Utility.GetIdentifyItemNewPopular(dateposted, PlaceHolder1, LyricID);
}
private void GetRelatedLyrics(int CatID)
{
RelatedLyrics.DataSource = RelatedLyricProvider.GetRelatedLyrics(CatID);
RelatedLyrics.DataBind();
}
private void GetComments(int LyricID)
{
LyricComments Comment = new LyricComments(LyricID, RecComments, PlaceHolder1);
Comment.FillUp();
Comment = null;
}
private void GetMetaKeywords(string strPageTitleAndKeywords)
{
Page.Header.Title = strPageTitleAndKeywords;
HtmlMeta metaTag = new HtmlMeta();
metaTag.Name = "Từ khóa";
metaTag.Content = strPageTitleAndKeywords;
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()))
{
LyricCommentsRepository comment = new LyricCommentsRepository();
comment.ID = (int)Util.Val(Request.QueryString["id"]);
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>Lỗi: Lời bình chưa có, hãy đưa vào lời bình của bạn.";
lbvalenght.Visible = true;
txtsecfield.Text = "";
return;
}
if (comment.Comments.Length > 350)
{
lbvalenght.Text = "<br>Lỗi: Lời bình quá dài. Lớn nhất là 350 ký tự.";
lbvalenght.Visible = true;
txtsecfield.Text = "";
return;
}
if (comment.Add(comment) != 0)
{
lbvalenght.Text = "Một lỗi cơ sở dữ liệu trong quá trình sử lý lời bình của bạn.";
return;
}
EmailCommentNotificationToAdministrator(comment.ID, strRName);
comment = null;
Response.Redirect("commentpostconfirmation.aspx?ReturnURL=" + this.Request.Url.PathAndQuery);
}
else
{
lbvalenght.Text = "<br>Mã bảo mật không đúng. Chắc chắn những gì bạn đưa vào là đúng.";
lbvalenght.Visible = true;
txtsecfield.Text = "";
lblinvalidsecode.Text = "Mã bảo mật không đúng. Chắc chắn những gì bạn đưa vào là đúng.";
lblinvalidsecode.Visible = true;
}
}
}
private void EmailCommentNotificationToAdministrator(int ID, string LyricName)
{
EmailTemplate SendEmail = new EmailTemplate();
SendEmail.ItemID = ID;
SendEmail.ItemName = LyricName;
SendEmail.SendEmailLyricCommentNotify();
SendEmail = null;
}
}