/
Category.aspx.cs
604 lines (479 loc) · 27.4 KB
/
Category.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
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
// Owner: Vatsal Shah
// Product: getputs.com
// Copyright Notice: Copyright Protected. All Rights Reserved.
using System;
using System.Data;
using System.Configuration;
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 MySql.Data.MySqlClient;
using System.Collections.Generic;
using System.Text;
using System.Collections.Specialized;
using System.Net;
// The Table getputs.item has the following schema:
// getputs.item [IID, Title, Link, Text, Date, UID, NComments, Category, Clicks, UpVotes, DownVotes, Spam]
// The Table getputs.user has the following schema:
// getputs.item [UID, Password, Date, EMail, About, Admin, Points]
public partial class Category : System.Web.UI.Page
{
DBOperations dbOps;
Links links;
General general;
GUIVariables gui;
Categories categories;
ProcessingEngine engine;
ImageEngine imageEngine;
ItemDisplayer itemDisplayer;
string dateFormatString = ConfigurationManager.AppSettings["dateFormatString"];
string UID;
string seperator = " | ";
int startItem = 0; // Default Value;
ProcessingEngine.Sort sort = ProcessingEngine.Sort.Hot;
private static int itemClicks = 0;
string requestedCategory = string.Empty;
ItemDisplayer.ItemLayoutOptions itemLayoutOptions = ItemDisplayer.ItemLayoutOptions.Flow;
// ItemDisplayer.ItemLayoutOptions itemLayoutOptions = ItemDisplayer.ItemLayoutOptions.Columns;
// ItemDisplayer.ItemLayoutOptions itemLayoutOptions = ItemDisplayer.ItemLayoutOptions.Categorized;
protected void Page_Load(object sender, EventArgs e)
{
dbOps = DBOperations.Instance;
links = Links.Instance;
general = General.Instance;
gui = GUIVariables.Instance;
categories = Categories.Instance;
engine = ProcessingEngine.Instance;
imageEngine = ImageEngine.Instance;
itemDisplayer = ItemDisplayer.Instance;
seperator = gui.Seperator;
// requestedTag = Request.QueryString["category"].Trim();
requestedCategory = Request.QueryString.Get("category");
if (!string.IsNullOrEmpty(Request.QueryString["startItem"]))
{
bool isStartItemInt = int.TryParse(Request.QueryString["startItem"].Trim(), out startItem);
if (!isStartItemInt)
{
startItem = 0;
}
if (startItem < 0)
{
startItem = 0;
}
}
else
{
startItem = 0;
}
if (!string.IsNullOrEmpty(Request.QueryString["sort"]))
{
string sortStr = Convert.ToString(Request.QueryString["sort"]);
sort = engine.GetSortType(sortStr);
}
if (Request.Cookies["getputsLayoutCookie"] != null)
{
HttpCookie getputsLayoutCookie = Request.Cookies["getputsLayoutCookie"];
itemLayoutOptions = itemDisplayer.GetItemLayoutOptionsType(dbOps.Decrypt(getputsLayoutCookie["layout"].ToString().Trim()));
}
#region CookieAlreadyExists
// START: If a getputsCookie with the Username already exists, do not show the Login Page.
if (Request.Cookies["getputsCookie"] != null)
{
HttpCookie getputsCookie = Request.Cookies["getputsCookie"];
UID = dbOps.Decrypt(getputsCookie["UID"].ToString().Trim());
}
if (string.IsNullOrEmpty(UID))
{
}
else
{
}
// END: If a getputsCookie with the Username already exists, do not show the Login Page.
#endregion CookieAlreadyExists
if (string.IsNullOrEmpty(requestedCategory))
{
LoadGenericCategoryTable();
}
else if (!(categories.CategoriesList.Contains(requestedCategory) || categories.CategoriesList.Contains(requestedCategory.ToLower())))
{
MessageLabel.Text = gui.RedFontStart + "Invalid Category" + gui.RedFontEnd;
}
else
{
string currentCategory = requestedCategory;
if (imageEngine.IsIconsOn)
{
string iconLocation = imageEngine.LoadIconLocation(currentCategory);
if (!string.IsNullOrEmpty(iconLocation))
{
System.Web.UI.WebControls.Image icon = new System.Web.UI.WebControls.Image();
// icon.ImageUrl = links.DomainLink + iconLocation;
icon.ImageUrl = iconLocation;
icon.ToolTip = currentCategory;
CategoryDiv.Controls.Add(icon);
CategoryDiv.Controls.Add(new LiteralControl(" "));
}
}
MessageLabel.Text = gui.GreenFontStart + requestedCategory + gui.GreenFontEnd;
// MessageLabel.Text = gui.WhiteFontStart + requestedCategory + gui.WhiteFontEnd;
LoadCategoryTable(requestedCategory, sort);
}
}
private void LoadGenericCategoryTable()
{
MessageLabel.Text = "Categories";
// ItemDiv.Controls.Add(new LiteralControl(gui.LineBreak));
for (int i = 0; i < categories.CategoriesList.Count; i++)
{
string currentCategory = categories.CategoriesList[i];
if (imageEngine.IsIconsOn)
{
string iconLocation = imageEngine.LoadIconLocation(currentCategory);
if (!string.IsNullOrEmpty(iconLocation))
{
System.Web.UI.WebControls.Image icon = new System.Web.UI.WebControls.Image();
// icon.ImageUrl = links.DomainLink + iconLocation;
icon.ImageUrl = iconLocation;
// icon.ImageUrl = Request.ApplicationPath + iconLocation;
icon.ToolTip = currentCategory;
ItemDiv.Controls.Add(icon);
ItemDiv.Controls.Add(new LiteralControl(" "));
}
}
HyperLink categoryHL = new HyperLink();
categoryHL.NavigateUrl = links.CategoryPageLink + "?category=" + currentCategory;
categoryHL.Text = currentCategory;
categoryHL.CssClass = "CSS_NavigationTableLinkButtons";
ItemDiv.Controls.Add(categoryHL);
ItemDiv.Controls.Add(new LiteralControl(gui.LineBreak));
}
}
private void LoadCategoryTable(string requestedTag, ProcessingEngine.Sort sortType)
{
List<Item> itemList = new List<Item>();
// select * from item order by DATE_FORMAT(date, '%Y-%m-%d %k:%i:%S') desc;
// string queryString = "SELECT IID, Title, Link, Text, Date, UID, NComments, Category FROM getputs.item WHERE Spam = 0 ORDER BY Date DESC";
string queryString = "SELECT IID, Title, Link, Text, Date, UID, NComments, Clicks, NSaved, NEMailed, Tags, AvgRating, NRated FROM item WHERE Category = '" + requestedTag + "' AND Spam = 0 ORDER BY DATE_FORMAT(Date, '%Y-%m-%d %k:%i:%S') DESC LIMIT " + engine.MaxItems.ToString() + ";";
MySqlDataReader retList;
retList = dbOps.ExecuteReader(queryString);
if (retList != null && retList.HasRows)
{
while (retList.Read())
{
Item item = new Item();
item.IID = Convert.ToInt32(retList["IID"]);
item.Title = Convert.ToString(retList["Title"]);
item.Link = Convert.ToString(retList["Link"]);
item.Text = Convert.ToString(retList["Text"]);
item.Date = Convert.ToString(retList["Date"]);
item.UID = Convert.ToString(retList["UID"]);
item.NComments = Convert.ToInt32(retList["NComments"]);
item.Category = requestedTag;
item.Clicks = Convert.ToInt32(retList["Clicks"]);
item.NSaved = Convert.ToInt32(retList["NSaved"]);
item.NEMailed = Convert.ToInt32(retList["NEMailed"]);
item.TagString = Convert.ToString(retList["Tags"]);
item.TagList = general.ConvertCSVToList(item.TagString);
item.AvgRating = Convert.ToDouble(retList["AvgRating"]);
item.NRated = Convert.ToInt32(retList["NRated"]);
item.Age = item.GetAge(item.Date);
// item.Marks = item.GetMarks(item.Clicks, item.NComments, item.Age);
item.Marks = item.GetMarks(item);
if (!string.IsNullOrEmpty(item.Link))
{
item.Text = string.Empty;
}
itemList.Add(item);
}
retList.Close();
}
if (sortType == ProcessingEngine.Sort.Hot)
{
itemList = engine.SortItems(itemList, sortType);
}
// ItemDiv.InnerHtml = LoadItems(itemList);
// LoadItemTable(itemList);
ItemDisplayer.ShowItemsOptions itemOptions = ItemDisplayer.ShowItemsOptions.ShowUIDLink
| ItemDisplayer.ShowItemsOptions.ShowTime
| ItemDisplayer.ShowItemsOptions.ShowSaveLink
| ItemDisplayer.ShowItemsOptions.ShowEMailLink
| ItemDisplayer.ShowItemsOptions.ShowCommentsLink
| ItemDisplayer.ShowItemsOptions.ShowImage
| ItemDisplayer.ShowItemsOptions.ShowRatings
| ItemDisplayer.ShowItemsOptions.ShowTags
| ItemDisplayer.ShowItemsOptions.CountClicks
| ItemDisplayer.ShowItemsOptions.ShowPreviousNextLinks;
string itemTable = itemDisplayer.LoadItemTable(itemList, itemOptions, itemLayoutOptions, startItem, UID, sort, links.CategoryPageLink.Replace("~\\", "") + "?category=" + requestedCategory);
ItemDiv.InnerHtml = itemTable;
}
private void LoadItemTable(List<Item> itemList)
{
string commentString = "discuss";
if (itemList == null || itemList.Count == 0)
{
string submitLink = "<a href='Submit.aspx' class='CSS_LinkItem'>Submit Page</a>";
ItemDiv.Controls.Add(new LiteralControl(gui.LineBreak));
ItemDiv.Controls.Add(new LiteralControl("No items found in this category."));
ItemDiv.Controls.Add(new LiteralControl(gui.LineBreak));
ItemDiv.Controls.Add(new LiteralControl("To post items in the " + requestedCategory + " Category, visit the " + submitLink));
}
else
{
List<int> savedItems = null;
List<int> ratedItems = null;
if (!string.IsNullOrEmpty(UID))
{
// Get the list of items that have been saved by the User only if the User is logged in.
savedItems = general.GetSavedItemIID(UID);
ratedItems = general.GetRatedItemsIID(UID);
}
// for (int i = 0; i < itemList.Count; i++)
for (int i = startItem; i < itemList.Count && i < startItem + engine.ItemsPerPage; i++)
{
commentString = "discuss";
Item item = itemList[i];
if (!string.IsNullOrEmpty(item.Link))
{
//HyperLink linkItemHL = new HyperLink();
//linkItemHL.CssClass = "CSS_LinkItem";
//linkItemHL.Text = item.Title;
//// linkItemHL.NavigateUrl = links.RPageLink.Replace("~\\", "") + "?iid=" + item.IID.ToString() + "&url=" + item.Link;
//linkItemHL.NavigateUrl = item.Link;
//ItemDiv.Controls.Add(linkItemHL);
string linkItemHL = "<a class='CSS_LinkItem' onmouseover = \"this.style.textDecoration='underline'\" onmouseout = \"this.style.textDecoration='none'\" href='" + links.RPageLink.Replace("~\\", "") + "?iid=" + item.IID.ToString() + "&url=" + item.Link + "'>" + item.Title + "</a>";
ItemDiv.Controls.Add(new LiteralControl(linkItemHL));
Uri uri = new Uri(item.Link);
string website = uri.Host;
HyperLink websiteLink = new HyperLink();
websiteLink.Text = " " + "[" + website.Replace("www.", "") + "]";
websiteLink.CssClass = "CSS_ItemDomain";
websiteLink.Target = "_blank";
websiteLink.NavigateUrl = "http://" + website;
ItemDiv.Controls.Add(websiteLink);
}
else
{
//HyperLink textItemHL = new HyperLink();
//textItemHL.Text = item.Title;
//textItemHL.CssClass = "CSS_TextItem";
//// textItemHL.NavigateUrl = links.RPageLink.Replace("~\\", "") + "?iid=" + item.IID.ToString() + "&url=" + links.ItemDetailsPageLink + "?iid=" + item.IID.ToString();
//textItemHL.NavigateUrl = links.ItemDetailsPageLink + "?iid=" + item.IID.ToString();
//ItemDiv.Controls.Add(textItemHL);
string textItemHL = "<a class='CSS_LinkItem' onmouseover = \"this.style.textDecoration='underline'\" onmouseout = \"this.style.textDecoration='none'\" href='" + links.RPageLink.Replace("~\\", "") + "?iid=" + item.IID.ToString() + "&url=" + links.ItemDetailsPageLink + "?iid=" + item.IID.ToString() + "'>" + item.Title + "</a>";
ItemDiv.Controls.Add(new LiteralControl(textItemHL));
}
// Add an icon to open the link in a new window/tab.
if (imageEngine.IsIconsOn)
{
string iconLocation = imageEngine.LoadStaticIconLocation("NewWindow");
if (!string.IsNullOrEmpty(iconLocation))
{
ItemDiv.Controls.Add(new LiteralControl(" "));
iconLocation = iconLocation.Replace("~\\", "");
string newWindow = string.Empty;
if (!string.IsNullOrEmpty(item.Link)) // Link Submission
{
// Redirect via R.aspx
// newWindow = "<a title='Open Link in a New Tab' style='vertical-align: middle' target='_blank' text-decoration='none' href='R.aspx?iid=" + item.IID.ToString() + "&url=" + item.Link + "'><img border= '0' src='" + iconLocation + "' alt='New Window'/></a> ";
// Redirect Directly, Bypass R.aspx
newWindow = "<a title='Open Link in a New Tab' style='vertical-align: middle' target='_blank' text-decoration='none' href='" + item.Link + "'><img border= '0' src='" + iconLocation + "' alt='New Window'/></a> ";
}
else // Text Submission
{
// Redirect via R.aspx
// newWindow = "<a title='Open Link in a New Tab' style='vertical-align: middle' target='_blank' text-decoration='none' href='R.aspx?iid=" + item.IID.ToString() + "&url=" + links.ItemDetailsPageLink + "?iid=" + item.IID.ToString() + "'><img border= '0' src='" + iconLocation + "' alt='New Window'/></a> ";
// Redirect Directly, Bypass R.aspx
newWindow = "<a title='Open Link in a New Tab' style='vertical-align: middle' target='_blank' text-decoration='none' href='" + links.ItemDetailsPageLink.Replace("~\\","") + "?iid=" + item.IID.ToString() + "'><img border= '0' src='" + iconLocation + "' alt='New Window'/></a> ";
}
LiteralControl NewWindowLiteral = new LiteralControl(newWindow);
ItemDiv.Controls.Add(NewWindowLiteral);
}
}
ItemDiv.Controls.Add(new LiteralControl(gui.LineBreak));
//HyperLink userHL = new HyperLink();
//userHL.Text = item.UID;
//userHL.Font.Underline = false;
//userHL.CssClass = "CSS_Submitter";
//userHL.NavigateUrl = links.UserDetailsPageLink + "?UID=" + item.UID;
//ItemDiv.Controls.Add(userHL);
//ItemDiv.Controls.Add(new LiteralControl(seperator));
string userHL = "<a class='CSS_Submitter' onmouseover = \"this.style.textDecoration='underline'\" onmouseout = \"this.style.textDecoration='none'\" href='" + links.UserDetailsPageLink.Replace("~\\", "") + "?UID=" + item.UID + "' >" + item.UID + "</a>";
ItemDiv.Controls.Add(new LiteralControl(userHL + seperator));
string dateFormatString = gui.SmallFontStart + gui.GrayFontStart + general.GetFormattedDate(item.Date) + gui.GrayFontEnd + gui.SmallFontEnd;
Label dateLabel = new Label();
dateLabel.Text = dateFormatString;
dateLabel.CssClass = "CSS_SubmissionFreshness";
ItemDiv.Controls.Add(dateLabel);
ItemDiv.Controls.Add(new LiteralControl(seperator));
// //No need to show a category for this page.
//if (!string.IsNullOrEmpty(item.Category))
//{
// LinkButton categoryLB = new LinkButton();
// categoryLB.Click += new EventHandler(categoryLB_Click);
// categoryLB.Text = item.Category;
// categoryLB.CssClass = "CSS_Category";
// // categoryLB.Font.Underline = false;
// // categoryLB.Font.Size = FontUnit.Small;
// // categoryLB.ForeColor = System.Drawing.Color.Silver;
// categoryLB.Attributes.Add("category", item.Category);
// ItemDiv.Controls.Add(categoryLB);
// ItemDiv.Controls.Add(new LiteralControl(seperator));
//}
if (!string.IsNullOrEmpty(UID)) // Show the Saved link only if the User is logged in.
{
// List<int> savedItems = general.GetSavedItemIID(UID);
LinkButton saveLB = new LinkButton();
saveLB.Click += new EventHandler(saveLB_Click);
saveLB.Text = "save";
saveLB.CssClass = "CSS_Save";
saveLB.Attributes.Add("IID", item.IID.ToString());
if (savedItems != null && savedItems.Count > 0)
{
if (savedItems.Contains(item.IID))
{
// Do not show the Save Link.
}
else
{
// Show the Save Link.
ItemDiv.Controls.Add(saveLB);
ItemDiv.Controls.Add(new LiteralControl(seperator));
}
}
else
{
// Show the Save Link.
ItemDiv.Controls.Add(saveLB);
ItemDiv.Controls.Add(new LiteralControl(seperator));
}
}
if (engine.IsEMailOn)
{
//string emailIconLocation = imageEngine.LoadStaticIconLocation("EMail");
//if (!string.IsNullOrEmpty(emailIconLocation))
//{
// System.Web.UI.WebControls.ImageButton emailIB = new ImageButton();
// emailIB.ImageUrl = emailIconLocation;
// emailIB.ToolTip = "EMail/Share this Item";
// emailIB.Click += new ImageClickEventHandler(emailIB_Click);
// emailIB.ImageAlign = ImageAlign.AbsMiddle;
// emailIB.Attributes.Add("IID", item.IID.ToString());
// ItemDiv.Controls.Add(emailIB);
// ItemDiv.Controls.Add(new LiteralControl(seperator));
//}
string emailIconLocation = imageEngine.LoadStaticIconLocation("EMail");
if (!string.IsNullOrEmpty(emailIconLocation))
{
string eMailHL = "<img title='E-Mail/Share this Item' border= '0' style='vertical-align:middle;' src='" + emailIconLocation.Replace("~\\", "") + "' alt='E-Mail'/>"
+ " "
+ "<a class='CSS_EMailLink' onmouseover = \"this.style.textDecoration='underline'\" onmouseout = \"this.style.textDecoration='none'\" href='" + links.SendItemMailPageLink.Replace("~\\", "") + "?IID=" + item.IID + "'>E-Mail</a>";
ItemDiv.Controls.Add(new LiteralControl(eMailHL + seperator));
}
}
//if (item.NComments > 0)
//{
// commentString = item.NComments == 1 ? (item.NComments.ToString() + " comment") : (item.NComments.ToString() + " comments");
//}
//HyperLink commentsHL = new HyperLink();
//commentsHL.CssClass = "CSS_Comments";
//commentsHL.Text = commentString;
//// commentsHL.NavigateUrl = links.RPageLink.Replace("~\\", "") + "?iid=" + item.IID.ToString() + "&url=" + links.ItemDetailsPageLink + "?iid=" + item.IID.ToString();
//commentsHL.NavigateUrl = links.ItemDetailsPageLink + "?iid=" + item.IID.ToString();
//ItemDiv.Controls.Add(commentsHL);
if (item.NComments > 0)
{
commentString = item.NComments == 1 ? (item.NComments.ToString() + " comment") : (item.NComments.ToString() + " comments");
}
string commentsHL = "<a class='CSS_Comments' onmouseover = \"this.style.textDecoration='underline'\" onmouseout = \"this.style.textDecoration='none'\" href='" + links.RPageLink.Replace("~\\", "") + "?iid=" + item.IID.ToString() + "&url=" + links.ItemDetailsPageLink + "?iid=" + item.IID.ToString() + "'>" + commentString + "</a>";
ItemDiv.Controls.Add(new LiteralControl(commentsHL));
if (engine.IsDebug)
{
string debugMessage = string.Empty;
ItemDiv.Controls.Add(new LiteralControl(gui.LineBreak));
if (engine.ClickCount.ContainsKey(item.IID))
{
debugMessage += "Dictionary Clicks: " + Convert.ToString(engine.ClickCount[item.IID]) + seperator;
}
string queryString = "SELECT Clicks, NSaved, NEMailed FROM item WHERE IID=" + item.IID.ToString() + ";";
MySqlDataReader retList = dbOps.ExecuteReader(queryString);
if (retList != null && retList.HasRows)
{
while (retList.Read())
{
debugMessage += "DB Clicks: " + Convert.ToString(retList["Clicks"]) + seperator
+ "NSaved: " + Convert.ToString(retList["NSaved"]) + seperator
+ "NEMailed: " + Convert.ToString(retList["NEMailed"]) + seperator;
}
retList.Close();
}
debugMessage += "Age: " + item.Age.ToString() + seperator;
debugMessage += "Marks: " + item.Marks.ToString();
Label debugLabel = new Label();
debugLabel.Text = debugMessage;
debugLabel.Font.Size = FontUnit.Small;
debugLabel.ForeColor = System.Drawing.Color.Gray;
ItemDiv.Controls.Add(debugLabel);
}
ItemDiv.Controls.Add(new LiteralControl(gui.LineBreak + gui.LineBreak));
ItemDiv.Controls.Add(new LiteralControl(gui.GrayFontStart + gui.ItemSeperator + gui.GrayFontEnd));
ItemDiv.Controls.Add(new LiteralControl(gui.LineBreak));
} // ItemList Loop Ends.
string sortStr = sort == ProcessingEngine.Sort.New ? "n" : "h";
// Add the "Previous" Link if required.
if (startItem - engine.ItemsPerPage >= 0)
{
int previousItem = startItem - engine.ItemsPerPage;
HyperLink previousPageHL = new HyperLink();
previousPageHL.Text = "Previous";
previousPageHL.CssClass = "CSS_Next";
previousPageHL.NavigateUrl = links.CategoryPageLink + "?category=" + requestedCategory + "&sort=" + sortStr + "&startItem=" + previousItem.ToString();
ItemDiv.Controls.Add(previousPageHL);
}
// Add the "Next" Link if required.
if (startItem + engine.ItemsPerPage < itemList.Count)
{
if (startItem - engine.ItemsPerPage >= 0)
{
ItemDiv.Controls.Add(new LiteralControl(seperator));
}
int nextItem = startItem + engine.ItemsPerPage;
HyperLink nextPageHL = new HyperLink();
nextPageHL.Text = "Next";
nextPageHL.CssClass = "CSS_Next";
nextPageHL.NavigateUrl = links.CategoryPageLink + "?category=" + requestedCategory + "&sort=" + sortStr + "&startItem=" + nextItem.ToString();
ItemDiv.Controls.Add(nextPageHL);
}
}
}
void saveLB_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(UID)) // Show the Saved link only if the User is logged in.
{
LinkButton saveLB = (LinkButton)sender;
saveLB.Text = "saved";
saveLB.Enabled = false;
saveLB.CssClass = "CSS_AfterSave";
//saveLB.Font.Underline = false;
//saveLB.Font.Size = FontUnit.Small;
//saveLB.ForeColor = System.Drawing.Color.Gray;
string IID = saveLB.Attributes["IID"];
string date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
string queryString = "INSERT INTO saveditems VALUES ('" + UID + "' , " + IID + " , '" + date + "');";
int retInt = dbOps.ExecuteNonQuery(queryString);
// Also update the getputs.item NSaved Field.
queryString = "UPDATE item SET NSaved=NSaved+1 WHERE IID=" + IID + ";";
retInt = dbOps.ExecuteNonQuery(queryString);
Response.Redirect(Context.Request.Url.ToString());
}
}
void emailIB_Click(object sender, EventArgs e)
{
ImageButton emailIB = (ImageButton)sender;
string iidStr = Convert.ToString(emailIB.Attributes["IID"]);
int iid = int.Parse(iidStr);
Response.Redirect(links.SendItemMailPageLink + "?IID=" + iid.ToString(), false);
}
}