// Fetch Recent Video comments public static List <Comment_Struct> Fetch_Comments(long id, int type, int total_records) { SqlConnection con = new SqlConnection(Config.ConnectionString); con.Open(); System.Collections.Generic.List <Comment_Struct> items = new System.Collections.Generic.List <Comment_Struct>(); Comment_Struct str_ct = default(Comment_Struct); //// generate query string Query = "SELECT TOP " + total_records + " commentid,username,_comment,videoid,added_date,points,replyid from comments WHERE videoid=" + id + " AND type=" + type + " AND isenabled=1 AND isApproved=1 ORDER BY commentid DESC"; SqlCommand cmd = new SqlCommand(Query, con); SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (reader.Read()) { str_ct = new Comment_Struct(); str_ct.CommentID = (long)reader["CommentID"]; str_ct.UserName = reader["username"].ToString(); str_ct.Added_Date = (DateTime)reader["added_date"]; str_ct.Comment = reader["_comment"].ToString(); str_ct.VideoID = Convert.ToInt64(reader["videoid"]); str_ct.Points = (int)reader["points"]; str_ct.ReplyID = Convert.ToInt64(reader["replyid"]); items.Add(str_ct); } reader.Close(); con.Close(); return(items); }
// Get UserName, Comment, isEnable for Abuse Reporting Purpose // Added 12th Oct 2010 public static List <Comment_Struct> Get_SM_Info(long ID, int type) { SqlConnection con = new SqlConnection(Config.ConnectionString); con.Open(); List <Comment_Struct> _items = new List <Comment_Struct>(); Comment_Struct _item; // generate sql query StringBuilder str = new StringBuilder(); str.Append("SELECT username,_comment,isenabled FROM comments WHERE videoid=" + ID + " AND type=" + type + ""); // execute sql query SqlCommand video_cmd = new SqlCommand(str.ToString(), con); SqlDataReader reader = video_cmd.ExecuteReader(CommandBehavior.CloseConnection); while (reader.Read()) { _item = new Comment_Struct(); _item.Comment = reader["_comment"].ToString(); _item.UserName = reader["username"].ToString(); _item.isEnabled = Convert.ToInt32(reader["isenabled"]); _items.Add(_item); } reader.Close(); con.Close(); return(_items); }
public string Process(Comment_Struct grp) { this.AuthorUrl = UrlConfig.Prepare_User_Profile_Url(grp.UserName, this.isAdmin); StringBuilder str = new StringBuilder(); string reply_pad = ""; string container_size = "100%"; if (grp.ReplyID > 0) { reply_pad = "padding-left:3%;"; container_size = "97%"; } // don't remove class name "vskcmtcnt" its internal use only str.Append("<div id=\"citem_" + grp.CommentID + "\" class=\"vskcmtcnt\" style=\"width:" + container_size + ";" + reply_pad + ";\">\n"); str.Append("<div id=\"cmsg_" + grp.CommentID + "\"></div>\n"); // to display runtime messages str.Append("<div class=\"" + this.BoxCssClass + "\">\n"); string container = "class=\"item_pad_2\""; if (this.isHoverEffect) { container = "class=\"" + this.HoverCssClass + "\""; } if (this.isAltColor) { container = "class=\"" + this.AltCssClass + "\""; } str.Append("<div " + container + ">\n"); switch (this.TemplateID) { case 0: // youtube style comment style str.Append(YoutubeStyleTemplate(grp)); break; case 1: // Facebook style comment str.Append(FBStyleTemplate(grp)); break; case 2: // Blog style comment str.Append(BlogStyleTemplate(grp)); break; case 3: // Simple Style str.Append(ProcessContent_Simple(grp)); break; } str.Append("</div>\n"); //close hover box str.Append("</div>\n"); // close box css class str.Append("</div>\n"); // close main box // reset urls for next itemgroup this.AuthorUrl = ""; return(str.ToString()); }
// Post Comment public static long Add(Comment_Struct cmt, int Comments) { // *********************************************************// // SCREENING Data Script: Updated in VSK 5.2 // *********************************************************// if (Config.Get_ScreeningOption() == 1) { // screening, matching and replacing enabled // the following script will screen content with matching words e.g "apple" -> "a***e" cmt.Comment = DictionaryBLL.Process_Screening(cmt.Comment); } //// Stored Procedure Version //SqlParameter CommentID = new SqlParameter("@CommentID", MySqlDbType.Int64); //CommentID.Direction = ParameterDirection.Output; //SqlHelper.ExecuteNonQuery(Config.ConnectionString, CommandType.StoredProcedure, "VSK_Comments_Post", CommentID, new SqlParameter("@VideoID", cmt.VideoID), new SqlParameter("@username", cmt.UserName), new SqlParameter("@comments", cmt.Comment), new SqlParameter("@date_added", DateTime.Now), new SqlParameter("@type", cmt.Type), new SqlParameter("@replyid", cmt.ReplyID), new SqlParameter("@profileid", cmt.ProfileID)); SqlConnection con = new SqlConnection(Config.ConnectionString); // generate sql query StringBuilder str = new StringBuilder(); str.Append("Insert Into comments(VideoID,username,_comment,added_date,type,replyid,profileid)values(@VideoID,@UserName,@Comments,@Date_Added,@Type,@ReplyID,@ProfileID);Select SCOPE_IDENTITY();"); // execute sql query SqlCommand cmd = new SqlCommand(str.ToString(), con); cmd.CommandType = CommandType.Text; cmd.Parameters.Add(new SqlParameter("@VideoID", cmt.VideoID)); cmd.Parameters.Add(new SqlParameter("@UserName", cmt.UserName)); cmd.Parameters.Add(new SqlParameter("@Comments", cmt.Comment)); cmd.Parameters.Add(new SqlParameter("@Type", cmt.Type)); cmd.Parameters.Add(new SqlParameter("@ReplyID", cmt.ReplyID)); cmd.Parameters.Add(new SqlParameter("@ProfileID", cmt.ProfileID)); cmd.Parameters.Add(new SqlParameter("@Date_Added", DateTime.Now)); if (con.State != ConnectionState.Open) { con.Open(); } long id = Convert.ToInt64(cmd.ExecuteScalar()); string level = id.ToString(); if (cmt.ReplyID > 0) { long c = cmt.ReplyID - 1; // in order to order replies based on comment id / replies level = c + "." + id.ToString(); } // Update Level //SqlHelper.ExecuteNonQuery(Config.ConnectionString, CommandType.StoredProcedure, "VSK_Comments_UpdateLevel", CommentID, new SqlParameter("@_CommentID", CommentID.Value), new SqlParameter("@_Level", level)); SqlHelper.ExecuteNonQuery(Config.ConnectionString, CommandType.Text, "Update comments set level=@Level WHERE CommentID=@CommentID;", new SqlParameter("@CommentID", id), new SqlParameter("@Level", level)); Comments++; if (cmt.ProfileID != "") { members.Update_Value(cmt.ProfileID, "comments", Comments.ToString()); } else { Update_Comment_Statistics(cmt.VideoID, cmt.Type, Comments); } return(id); }
// Post Comment public static long Add(Comment_Struct cmt, int Comments) { // *********************************************************// // SCREENING Data Script: Updated in VSK 5.2 // *********************************************************// if (Config.Get_ScreeningOption() == 1) { // screening, matching and replacing enabled // the following script will screen content with matching words e.g "apple" -> "a***e" cmt.Comment = DictionaryBLL.Process_Screening(cmt.Comment); } //// Stored Procedure Version //SqlParameter CommentID = new SqlParameter("@CommentID", MySqlDbType.Int64); //CommentID.Direction = ParameterDirection.Output; //SqlHelper.ExecuteNonQuery(Config.ConnectionString, CommandType.StoredProcedure, "VSK_Comments_Post", CommentID, new SqlParameter("@VideoID", cmt.VideoID), new SqlParameter("@username", cmt.UserName), new SqlParameter("@comments", cmt.Comment), new SqlParameter("@date_added", DateTime.Now), new SqlParameter("@type", cmt.Type), new SqlParameter("@replyid", cmt.ReplyID), new SqlParameter("@profileid", cmt.ProfileID)); SqlConnection con = new SqlConnection(Config.ConnectionString); // generate sql query StringBuilder str = new StringBuilder(); str.Append("Insert Into comments(VideoID,username,_comment,added_date,type,replyid,profileid)values(@VideoID,@UserName,@Comments,@Date_Added,@Type,@ReplyID,@ProfileID);Select SCOPE_IDENTITY();"); // execute sql query SqlCommand cmd = new SqlCommand(str.ToString(), con); cmd.CommandType = CommandType.Text; cmd.Parameters.Add(new SqlParameter("@VideoID", cmt.VideoID)); cmd.Parameters.Add(new SqlParameter("@UserName", cmt.UserName)); cmd.Parameters.Add(new SqlParameter("@Comments", cmt.Comment)); cmd.Parameters.Add(new SqlParameter("@Type", cmt.Type)); cmd.Parameters.Add(new SqlParameter("@ReplyID", cmt.ReplyID)); cmd.Parameters.Add(new SqlParameter("@ProfileID", cmt.ProfileID)); cmd.Parameters.Add(new SqlParameter("@Date_Added", DateTime.Now)); if (con.State != ConnectionState.Open) con.Open(); long id = Convert.ToInt64(cmd.ExecuteScalar()); string level = id.ToString(); if(cmt.ReplyID>0) { long c = cmt.ReplyID - 1; // in order to order replies based on comment id / replies level = c + "." + id.ToString(); } // Update Level //SqlHelper.ExecuteNonQuery(Config.ConnectionString, CommandType.StoredProcedure, "VSK_Comments_UpdateLevel", CommentID, new SqlParameter("@_CommentID", CommentID.Value), new SqlParameter("@_Level", level)); SqlHelper.ExecuteNonQuery(Config.ConnectionString, CommandType.Text, "Update comments set level=@Level WHERE CommentID=@CommentID;", new SqlParameter("@CommentID", id), new SqlParameter("@Level", level)); Comments++; if (cmt.ProfileID != "") { members.Update_Value(cmt.ProfileID, "comments", Comments.ToString()); } else { Update_Comment_Statistics(cmt.VideoID, cmt.Type, Comments); } return id; }
// Fetch Comments With User Profile Picture public static List <Comment_Struct> Fetch_Comments_V2(long id, string profileid, int type, int total_records, string Order, bool ShowAuthoImage) { SqlConnection con = new SqlConnection(Config.ConnectionString); con.Open(); System.Collections.Generic.List <Comment_Struct> items = new System.Collections.Generic.List <Comment_Struct>(); Comment_Struct str_ct = default(Comment_Struct); //// generate query string _filter = ""; if (profileid != "") { _filter = "c.profileid=" + profileid; } else { _filter = "c.videoid=" + id; } string Query = ""; if (!ShowAuthoImage) { Query = "SELECT TOP " + total_records + " c.commentid,c.username,c._comment,c.videoid,c.added_date,c.points,c.replyid from comments as c WHERE " + _filter + " AND c.type=" + type + " AND c.isenabled=1 AND c.isApproved=1 ORDER BY " + Order + " DESC"; } else { Query = "SELECT TOP " + total_records + " c.commentid,c.username,c._comment,c.videoid,c.added_date,c.points,u.picturename,c.replyid from comments as c inner join users as u on u.username=c.username WHERe " + _filter + " AND c.type=" + type + " AND c.isenabled=1 AND c.isApproved=1 ORDER BY " + Order + ""; } SqlCommand cmd = new SqlCommand(Query, con); SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (reader.Read()) { str_ct = new Comment_Struct(); str_ct.CommentID = (long)reader["CommentID"]; str_ct.UserName = reader["username"].ToString(); str_ct.Added_Date = (DateTime)reader["added_date"]; str_ct.Comment = reader["_comment"].ToString(); str_ct.VideoID = Convert.ToInt64(reader["videoid"]); str_ct.Points = (int)reader["points"]; str_ct.ReplyID = Convert.ToInt64(reader["replyid"]); if (profileid != "") { str_ct.PictureName = reader["picturename"].ToString(); } items.Add(str_ct); } reader.Close(); con.Close(); return(items); }
private string BlogStyleTemplate(Comment_Struct grp) { StringBuilder str = new StringBuilder(); if (this.ShowAuthorImage) { this.LeftWidth = 12; this.RightWidth = 87; // show author thumb on right side of comment str.Append("<div class=\"item_pad_4\">\n"); str.Append("<div style=\"float:left; width:" + this.LeftWidth + "%;\">\n"); str.Append(ProcessThumb(grp)); str.Append("</div>\n"); str.Append("<div style=\"float:right; width:" + this.RightWidth + "%;\">\n"); // show author if (Config.isFeature_UserName() && this.ShowAuthor) { // if username enabled string _usr = grp.UserName; if (_usr.Length > 18) { _usr = _usr.Substring(0, 18) + ".."; } string _usr_link = "<a id=\"cmtusr_" + grp.CommentID + "\" class=\"" + this.BoldLinkCssClass + "\" href=\"" + this.AuthorUrl + "\" title=\"" + grp.UserName + "\">" + _usr + "</a>"; str.Append(_usr_link); } str.Append("</div>\n"); str.Append("<div class=\"clear\"></div>\n"); str.Append("</div>\n"); } else { str.Append("<div class=\"item_pad_4\">\n"); // show author if (Config.isFeature_UserName() && this.ShowAuthor) { // if username enabled string _usr = grp.UserName; if (_usr.Length > 18) { _usr = _usr.Substring(0, 18) + ".."; } string _usr_link = "<a id=\"cmtusr_" + grp.CommentID + "\" class=\"" + this.BoldLinkCssClass + "\" href=\"" + this.AuthorUrl + "\" title=\"" + grp.UserName + "\">" + _usr + "</a>"; str.Append(_usr_link); } str.Append("</div>\n"); } str.Append("<div class=\"item_pad_4\">\n"); str.Append(ProcessContent_Blog(grp)); str.Append("</div>\n"); return(str.ToString()); }
// Fetch all video comments public static List <Comment_Struct> Fetch_Comments(long id, int type, int PageNumber, int PageSize) { SqlConnection con = new SqlConnection(Config.ConnectionString); con.Open(); System.Collections.Generic.List <Comment_Struct> items = new System.Collections.Generic.List <Comment_Struct>(); Comment_Struct str_ct = default(Comment_Struct); //// generate query StringBuilder str = new StringBuilder(); StringBuilder query = new StringBuilder(); query.Append("commentid,username,_comment,videoid,added_date,points from comments WHERE VideoID=" + id + " AND type=" + type + " AND isenabled=1 AND isApproved=1"); // implement paging script for differnt data sources. switch (Site_Settings.Pagination_Type) { case 0: // SQL SERVER 2005 or Later Supported Query str.Append(Pagination_Process.Prepare_SQLSERVER2005_Pagination(query.ToString(), "commentid DESC", PageNumber, PageSize)); break; case 1: // MySQL Supported Query string mysql_query = "SELECT " + query.ToString() + " ORDER BY commentid DESC"; str.Append(Pagination_Process.Prepare_MySQL_Pagination(mysql_query, PageNumber, PageSize)); break; case 2: // SQL SERVER 2000 Supported Query string normal_query = "SELECT " + query.ToString() + " ORDER BY commentid DESC"; str.Append(normal_query); break; } SqlCommand cmd = new SqlCommand(str.ToString(), con); SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (reader.Read()) { str_ct = new Comment_Struct(); str_ct.CommentID = (long)reader["CommentID"]; str_ct.UserName = reader["username"].ToString(); str_ct.Added_Date = (DateTime)reader["added_date"]; str_ct.Comment = reader["_comment"].ToString(); str_ct.VideoID = Convert.ToInt64(reader["videoid"]); str_ct.Points = (int)reader["points"]; items.Add(str_ct); } reader.Close(); con.Close(); return(items); }
private string ProcessThumb(Comment_Struct grp) { StringBuilder str = new StringBuilder(); // photo thumb string image_src = UrlConfig.Return_Photo_Url(grp.UserName, grp.PictureName, 0, 0); str.Append("<a href=\"" + this.AuthorUrl + "\" title=\"" + grp.UserName + "\">"); // thumb link setup string border_class = this.ThumbRoundCssClass; if (!this.isRoundCorners) { border_class = this.ThumbCssClass; } str.Append("<img class=\"" + border_class + "\" src=\"" + image_src + "\" height=\"" + this.Height + "\" width=\"" + this.Width + "\">"); str.Append("</a>"); return(str.ToString()); }
private string FBStyleTemplate(Comment_Struct grp) { StringBuilder str = new StringBuilder(); if (this.ShowAuthorImage) { // show author thumb on right side of comment str.Append("<div style=\"float:left; width:" + this.LeftWidth + "%;\">\n"); str.Append(ProcessThumb(grp)); str.Append("</div>\n"); str.Append("<div style=\"float:right; width:" + this.RightWidth + "%;\">\n"); str.Append(ProcessContent_Fb(grp)); str.Append("</div>\n"); str.Append("<div class=\"clear\"></div>\n"); } else { str.Append("<div class=\"item\">\n"); str.Append(ProcessContent_Fb(grp)); str.Append("</div>\n"); } return(str.ToString()); }
private string ProcessContent_Simple(Comment_Struct grp) { StringBuilder str = new StringBuilder(); int _content_left_width = 78; // % int _content_right_width = 118; // px; if (grp.ReplyID > 0 || !this.ShowReplyLink) { _content_left_width = _content_left_width + 4; _content_right_width = _content_right_width - 28; } if (!this.ShowVotes) { _content_left_width = _content_left_width + 8; _content_right_width = _content_right_width - 58; } str.Append("<span id=\"cmtpts_" + grp.CommentID + "\" style=\"display:none;\">" + grp.Points + "</span>\n"); // Comment Section str.Append("<div style=\"float:left; width:" + _content_left_width + "%;\">\n"); // show votes if (this.ShowVotes) { //// comment like action to be store in span// 0: Like, 1: Unlike cmt_lk int likes = grp.Points; if (likes < 0) str.Append("<span id=\"cmtpl_" + grp.CommentID + "\" class=\"badge badge-important mini-text\">" + likes + "</span> "); else if (likes > 0) str.Append("<span id=\"cmtpl_" + grp.CommentID + "\" class=\"badge badge-warning mini-text\">" + likes + "</span> "); else str.Append("<span id=\"cmtpl_" + grp.CommentID + "\"></span> "); // keep it empty in case of no votes } // Show Comment //str.Append("<div class=\"item\"><p>\n"); str.Append("<span class=\"normal-text\">" + grp.Comment + "</span>"); //str.Append("</p></div>\n"); // show author if (Config.isFeature_UserName() && this.ShowAuthor) { // if username enabled string _usr = grp.UserName; if (_usr.Length > 18) _usr = _usr.Substring(0, 18) + ".."; string _usr_link = " <a id=\"cmtusr_" + grp.CommentID + "\" class=\"" + this.BoldLinkCssClass + "\" href=\"" + this.AuthorUrl + "\" title=\"" + grp.UserName + "\">" + _usr + "</a> "; str.Append(_usr_link); } // Added Date if (Config.isFeature_Date() && this.ShowDate) { str.Append(" <span class=\"mini-text light\">" + UtilityBLL.Generate_Date(grp.Added_Date, this.DateFormat) + "</span>"); } // approved, disabled if (this.ShowApproved && this.ShowDisabled) { str.Append("<div class=\"item_pad_2\">\n"); string _approve = "<span class=\"" + this.GoodCssClass + "\">" + Resources.vsk.approved + "</span>\n"; if (grp.isApproved == 0) _approve = "<span class=\"" + this.BadCssClass + "\">Not approved</span>\n"; string _disabled = "<span class=\"" + this.GoodCssClass + "\">" + Resources.vsk.enabled + "</span>\n"; if (grp.isEnabled == 0) _disabled = "<span class=\"" + this.BadCssClass + "\">Disabled</span>\n"; str.Append(_approve + " | " + _disabled); str.Append("</div>\n"); } else if (this.ShowApproved) { str.Append("<div class=\"item_pad_2\">\n"); string _approve = "<span class=\"" + this.GoodCssClass + "\">" + Resources.vsk.approved + "</span>\n"; if (grp.isApproved == 0) _approve = "<span class=\"" + this.BadCssClass + "\">Not approved</span>\n"; str.Append(_approve); str.Append("</div>\n"); } else if (this.ShowDisabled) { str.Append("<div class=\"item_pad_2\">\n"); string _disabled = "<span class=\"" + this.GoodCssClass + "\">" + Resources.vsk.enabled + "</span>\n"; if (grp.isEnabled == 0) _disabled = "<span class=\"" + this.BadCssClass + "\">Disabled</span>\n"; str.Append(_disabled); str.Append("</div>\n"); } str.Append("</div>\n"); // close float left div //str.Append("<div id=\"cmt_action_" + grp.CommentID + "\" class=\"itm_cross\" style=\"float:right; width:" + _content_right_width + "px; display:none;\">\n"); //if (this.PosterUserName != "") //{ // // if currently logged in user is author of post or author of comment, then shown remove comment link instead of flag link // if (this.PosterUserName == grp.UserName || this.PosterUserName == this.AuthorUserName) // { // // remove link // str.Append("<a href=\"#\" class=\"cmt_remove\" title=\"Remove Comment\">X</a>"); // } //} //str.Append("</div>\n"); // close float right div if (!this.isAdmin) { str.Append("<div id=\"cmt_action_" + grp.CommentID + "\" class=\"itm_cross btn-group\" style=\"float:right; width:" + _content_right_width + "px; display:none;\">\n"); if (this.ShowVotes) { // vote up link str.Append("<a href=\"#\" class=\"btn btn-warning btn-mini cmt_vu\" rel=\"tooltip\" title=\"Vote Up\"><i class=\"icon-thumbs-up icon-white\"></i></a>"); // vote down link str.Append("<a href=\"#\" class=\"btn btn-warning btn-mini cmt_vd\" title=\"Vote Down\"><i class=\"icon-thumbs-down icon-white\"></i></a>"); } if (grp.ReplyID == 0 && this.ShowReplyLink) { // reply link str.Append("<a href=\"#\" class=\"btn btn-warning btn-mini cmt_rep\" title=\"Reply to this comment\"><i class=\"icon-repeat icon-white\"></i></a>"); } if (this.PosterUserName != "") { // if currently logged in user is author of post or author of comment, then shown remove comment link instead of flag link if (this.PosterUserName == grp.UserName || this.PosterUserName == this.AuthorUserName) { // remove link str.Append("<a href=\"#\" class=\"btn btn-warning btn-mini cmt_remove\" title=\"Remove Comment\"><i class=\"icon-trash icon-white\"></i></a>"); } else { // spam link str.Append("<a href=\"#\" class=\"btn btn-warning btn-mini cmt_flag\" title=\"Flag for Spam\"><i class=\"icon-flag icon-white\"></i></a>"); } } else { // spam link str.Append("<a href=\"#\" class=\"btn btn-warning btn-mini cmt_flag\" title=\"Flag for Spam\"><i class=\"icon-flag icon-white\"></i></a>"); } str.Append("</div>\n"); // close float right div } //********************* str.Append("<div class=\"clear\"></div>\n"); str.Append("<div id=\"cmtrepmsg_" + grp.CommentID + "\"></div>\n"); // reply comment box str.Append("<div id=\"cmtrep_" + grp.CommentID + "\"></div>\n"); // for showing comment box // Action Secction return str.ToString(); }
private string ProcessContent_Blog(Comment_Struct grp) { StringBuilder str = new StringBuilder(); int _content_left_width = 97; // % int _content_right_width = 12; // px; str.Append("<span id=\"cmtpts_" + grp.CommentID + "\" style=\"display:none;\">" + grp.Points + "</span>\n"); // Comment Section str.Append("<div style=\"float:left; width:" + _content_left_width + "%;\">\n"); // Show Comment str.Append("<div class=\"item\"><p>\n"); str.Append(grp.Comment); str.Append("</p></div>\n"); str.Append("<div class=\"action\">\n"); str.Append("<div style=\"float:left;width:50%;\">\n"); // Added Date if (Config.isFeature_Date() && this.ShowDate) { str.Append("<span class=\"light\">" + UtilityBLL.Generate_Date(grp.Added_Date, this.DateFormat) + "</span>"); } str.Append("</div>\n"); str.Append("<div id=\"cmt_action_fb_" + grp.CommentID + "\" class=\"item_r\" style=\"float:right;width:49%;\">\n"); if (grp.ReplyID == 0 && this.ShowReplyLink) { // reply link str.Append("<a href=\"#\" class=\"cmt_rep\" title=\"Reply to this comment\">Reply</a> . \n"); } if (this.ShowVotes) { //// comment like action to be store in span// 0: Like, 1: Unlike cmt_lk int likes = grp.Points; if (likes < 0) { likes = 0; } if (likes > 0) { str.Append("<span id=\"cmtpl_" + grp.Points + "\" class=\"normal-text reverse\">" + likes + "</span> . "); } str.Append("<a id=\"cmt_lk_" + grp.CommentID + "\" class=\"cmt_vu\" href=\"#\">Like</a> . \n"); } if (this.PosterUserName != "") { // if currently logged in user is author of post or author of comment, then shown remove comment link instead of flag link if (this.PosterUserName == grp.UserName || this.PosterUserName == this.AuthorUserName) { // remove link } else { // spam link str.Append("<a href=\"#\" class=\"cmt_flag\" title=\"Flag for Spam\">" + Resources.vsk.flag + "</a>"); } } else { // spam link str.Append("<a href=\"#\" class=\"cmt_flag\" title=\"Flag for Spam\">" + Resources.vsk.flag + "</a>"); } str.Append("</div>\n"); str.Append("<div class=\"clear\"></div>\n"); str.Append("</div>\n"); // approved, disabled if (this.ShowApproved && this.ShowDisabled) { str.Append("<div class=\"item_pad_2\">\n"); string _approve = "<span class=\"" + this.GoodCssClass + "\">" + Resources.vsk.approved + "</span>\n"; if (grp.isApproved == 0) { _approve = "<span class=\"" + this.BadCssClass + "\">Not approved</span>\n"; } string _disabled = "<span class=\"" + this.GoodCssClass + "\">" + Resources.vsk.enabled + "</span>\n"; if (grp.isEnabled == 0) { _disabled = "<span class=\"" + this.BadCssClass + "\">Disabled</span>\n"; } str.Append(_approve + " | " + _disabled); str.Append("</div>\n"); } else if (this.ShowApproved) { str.Append("<div class=\"item_pad_2\">\n"); string _approve = "<span class=\"" + this.GoodCssClass + "\">" + Resources.vsk.approved + "</span>\n"; if (grp.isApproved == 0) { _approve = "<span class=\"" + this.BadCssClass + "\">Not approved</span>\n"; } str.Append(_approve); str.Append("</div>\n"); } else if (this.ShowDisabled) { str.Append("<div class=\"item_pad_2\">\n"); string _disabled = "<span class=\"" + this.GoodCssClass + "\">" + Resources.vsk.enabled + "</span>\n"; if (grp.isEnabled == 0) { _disabled = "<span class=\"" + this.BadCssClass + "\">Disabled</span>\n"; } str.Append(_disabled); str.Append("</div>\n"); } str.Append("</div>\n"); // close float left div str.Append("<div id=\"cmt_action_" + grp.CommentID + "\" class=\"itm_cross\" style=\"float:right; width:" + _content_right_width + "px; display:none;\">\n"); if (this.PosterUserName != "") { // if currently logged in user is author of post or author of comment, then shown remove comment link instead of flag link if (this.PosterUserName == grp.UserName || this.PosterUserName == this.AuthorUserName) { // remove link str.Append("<a href=\"#\" class=\"cmt_remove\" title=\"Remove Comment\">X</a>"); } } str.Append("</div>\n"); // close float right div str.Append("<div class=\"clear\"></div>\n"); str.Append("<div id=\"cmtrepmsg_" + grp.CommentID + "\"></div>\n"); // reply comment box str.Append("<div id=\"cmtrep_" + grp.CommentID + "\"></div>\n"); // for showing comment box // Action Secction return(str.ToString()); }
// Load photos in admin section public static List<Comment_Struct> Load_Comments(string search, string username, string type, int isEnabled, int isApproved, int filteroption, string order, int PageNumber, int PageSize) { SqlConnection con = new SqlConnection(Config.ConnectionString); if (con.State != ConnectionState.Open) con.Open(); List<Comment_Struct> _items = new List<Comment_Struct>(); Comment_Struct _item; // Query Building StringBuilder str = new StringBuilder(); StringBuilder query = new StringBuilder(); string logic = CommentsBLL.Return_Comment_Admin_Logic(search, username, type, isEnabled, isApproved, filteroption); query.Append("commentid,videoid,username,_comment,added_date,isenabled,type,points,isapproved,replyid,profileid FROM comments" + logic); // implement paging script for differnt data sources. switch (Site_Settings.Pagination_Type) { case 0: // SQL SERVER 2005 or Later Supported Query str.Append(Pagination_Process.Prepare_SQLSERVER2005_Pagination(query.ToString(), order, PageNumber, PageSize)); break; case 1: // MySQL Supported Query string mysql_query = "SELECT " + query.ToString() + " ORDER BY " + order; str.Append(Pagination_Process.Prepare_MySQL_Pagination(mysql_query, PageNumber, PageSize)); break; case 2: // SQL SERVER 2000 Supported Query string normal_query = "SELECT " + query.ToString() + " ORDER BY " + order; str.Append(normal_query); break; } // execute sql query SqlCommand video_cmd = new SqlCommand(str.ToString(), con); video_cmd.Parameters.Add(new SqlParameter("@search",search)); video_cmd.Parameters.Add(new SqlParameter("@username", username)); video_cmd.Parameters.Add(new SqlParameter("@type", type)); video_cmd.Parameters.Add(new SqlParameter("@isenabled", isEnabled)); video_cmd.Parameters.Add(new SqlParameter("@isapproved", isApproved)); SqlDataReader reader = video_cmd.ExecuteReader(CommandBehavior.CloseConnection); while (reader.Read()) { _item = new Comment_Struct(); _item.CommentID = (long)reader["commentid"]; _item.Comment = reader["_comment"].ToString(); _item.UserName = reader["username"].ToString(); _item.VideoID = (long)reader["videoid"]; _item.isEnabled = Convert.ToInt32(reader["isenabled"]); _item.isApproved = Convert.ToInt32(reader["isapproved"]); _item.Type = Convert.ToInt32(reader["type"]); _item.ReplyID = (long)reader["replyid"]; _item.Points = Convert.ToInt32(reader["points"]); _item.Added_Date = (DateTime)reader["added_date"]; _item.ProfileID = reader["profileid"].ToString(); _items.Add(_item); } reader.Close(); con.Close(); con.Dispose(); return _items; }
// Get UserName, Comment, isEnable for Abuse Reporting Purpose // Added 12th Oct 2010 public static List<Comment_Struct> Get_SM_Info(long ID, int type) { SqlConnection con = new SqlConnection(Config.ConnectionString); con.Open(); List<Comment_Struct> _items = new List<Comment_Struct>(); Comment_Struct _item; // generate sql query StringBuilder str = new StringBuilder(); str.Append("SELECT username,_comment,isenabled FROM comments WHERE videoid=" + ID + " AND type=" + type + ""); // execute sql query SqlCommand video_cmd = new SqlCommand(str.ToString(), con); SqlDataReader reader = video_cmd.ExecuteReader(CommandBehavior.CloseConnection); while (reader.Read()) { _item = new Comment_Struct(); _item.Comment = reader["_comment"].ToString(); _item.UserName = reader["username"].ToString(); _item.isEnabled = Convert.ToInt32(reader["isenabled"]); _items.Add(_item); } reader.Close(); con.Close(); return _items; }
private string ProcessContent_Simple(Comment_Struct grp) { StringBuilder str = new StringBuilder(); int _content_left_width = 78; // % int _content_right_width = 118; // px; if (grp.ReplyID > 0 || !this.ShowReplyLink) { _content_left_width = _content_left_width + 4; _content_right_width = _content_right_width - 28; } if (!this.ShowVotes) { _content_left_width = _content_left_width + 8; _content_right_width = _content_right_width - 58; } str.Append("<span id=\"cmtpts_" + grp.CommentID + "\" style=\"display:none;\">" + grp.Points + "</span>\n"); // Comment Section str.Append("<div style=\"float:left; width:" + _content_left_width + "%;\">\n"); // show votes if (this.ShowVotes) { //// comment like action to be store in span// 0: Like, 1: Unlike cmt_lk int likes = grp.Points; if (likes < 0) { str.Append("<span id=\"cmtpl_" + grp.CommentID + "\" class=\"badge badge-important mini-text\">" + likes + "</span> "); } else if (likes > 0) { str.Append("<span id=\"cmtpl_" + grp.CommentID + "\" class=\"badge badge-warning mini-text\">" + likes + "</span> "); } else { str.Append("<span id=\"cmtpl_" + grp.CommentID + "\"></span> "); // keep it empty in case of no votes } } // Show Comment //str.Append("<div class=\"item\"><p>\n"); str.Append("<span class=\"normal-text\">" + grp.Comment + "</span>"); //str.Append("</p></div>\n"); // show author if (Config.isFeature_UserName() && this.ShowAuthor) { // if username enabled string _usr = grp.UserName; if (_usr.Length > 18) { _usr = _usr.Substring(0, 18) + ".."; } string _usr_link = " <a id=\"cmtusr_" + grp.CommentID + "\" class=\"" + this.BoldLinkCssClass + "\" href=\"" + this.AuthorUrl + "\" title=\"" + grp.UserName + "\">" + _usr + "</a> "; str.Append(_usr_link); } // Added Date if (Config.isFeature_Date() && this.ShowDate) { str.Append(" <span class=\"mini-text light\">" + UtilityBLL.Generate_Date(grp.Added_Date, this.DateFormat) + "</span>"); } // approved, disabled if (this.ShowApproved && this.ShowDisabled) { str.Append("<div class=\"item_pad_2\">\n"); string _approve = "<span class=\"" + this.GoodCssClass + "\">" + Resources.vsk.approved + "</span>\n"; if (grp.isApproved == 0) { _approve = "<span class=\"" + this.BadCssClass + "\">Not approved</span>\n"; } string _disabled = "<span class=\"" + this.GoodCssClass + "\">" + Resources.vsk.enabled + "</span>\n"; if (grp.isEnabled == 0) { _disabled = "<span class=\"" + this.BadCssClass + "\">Disabled</span>\n"; } str.Append(_approve + " | " + _disabled); str.Append("</div>\n"); } else if (this.ShowApproved) { str.Append("<div class=\"item_pad_2\">\n"); string _approve = "<span class=\"" + this.GoodCssClass + "\">" + Resources.vsk.approved + "</span>\n"; if (grp.isApproved == 0) { _approve = "<span class=\"" + this.BadCssClass + "\">Not approved</span>\n"; } str.Append(_approve); str.Append("</div>\n"); } else if (this.ShowDisabled) { str.Append("<div class=\"item_pad_2\">\n"); string _disabled = "<span class=\"" + this.GoodCssClass + "\">" + Resources.vsk.enabled + "</span>\n"; if (grp.isEnabled == 0) { _disabled = "<span class=\"" + this.BadCssClass + "\">Disabled</span>\n"; } str.Append(_disabled); str.Append("</div>\n"); } str.Append("</div>\n"); // close float left div //str.Append("<div id=\"cmt_action_" + grp.CommentID + "\" class=\"itm_cross\" style=\"float:right; width:" + _content_right_width + "px; display:none;\">\n"); //if (this.PosterUserName != "") //{ // // if currently logged in user is author of post or author of comment, then shown remove comment link instead of flag link // if (this.PosterUserName == grp.UserName || this.PosterUserName == this.AuthorUserName) // { // // remove link // str.Append("<a href=\"#\" class=\"cmt_remove\" title=\"Remove Comment\">X</a>"); // } //} //str.Append("</div>\n"); // close float right div if (!this.isAdmin) { str.Append("<div id=\"cmt_action_" + grp.CommentID + "\" class=\"itm_cross btn-group\" style=\"float:right; width:" + _content_right_width + "px; display:none;\">\n"); if (this.ShowVotes) { // vote up link str.Append("<a href=\"#\" class=\"btn btn-warning btn-mini cmt_vu\" rel=\"tooltip\" title=\"Vote Up\"><i class=\"icon-thumbs-up icon-white\"></i></a>"); // vote down link str.Append("<a href=\"#\" class=\"btn btn-warning btn-mini cmt_vd\" title=\"Vote Down\"><i class=\"icon-thumbs-down icon-white\"></i></a>"); } if (grp.ReplyID == 0 && this.ShowReplyLink) { // reply link str.Append("<a href=\"#\" class=\"btn btn-warning btn-mini cmt_rep\" title=\"Reply to this comment\"><i class=\"icon-repeat icon-white\"></i></a>"); } if (this.PosterUserName != "") { // if currently logged in user is author of post or author of comment, then shown remove comment link instead of flag link if (this.PosterUserName == grp.UserName || this.PosterUserName == this.AuthorUserName) { // remove link str.Append("<a href=\"#\" class=\"btn btn-warning btn-mini cmt_remove\" title=\"Remove Comment\"><i class=\"icon-trash icon-white\"></i></a>"); } else { // spam link str.Append("<a href=\"#\" class=\"btn btn-warning btn-mini cmt_flag\" title=\"Flag for Spam\"><i class=\"icon-flag icon-white\"></i></a>"); } } else { // spam link str.Append("<a href=\"#\" class=\"btn btn-warning btn-mini cmt_flag\" title=\"Flag for Spam\"><i class=\"icon-flag icon-white\"></i></a>"); } str.Append("</div>\n"); // close float right div } //********************* str.Append("<div class=\"clear\"></div>\n"); str.Append("<div id=\"cmtrepmsg_" + grp.CommentID + "\"></div>\n"); // reply comment box str.Append("<div id=\"cmtrep_" + grp.CommentID + "\"></div>\n"); // for showing comment box // Action Secction return(str.ToString()); }
// Fetch Comments With User Profile Picture public static List<Comment_Struct> Fetch_Comments_V2(long id, string profileid, int type, int PageNumber, int PageSize, string Order, bool ShowAuthoImage) { SqlConnection con = new SqlConnection(Config.ConnectionString); con.Open(); System.Collections.Generic.List<Comment_Struct> items = new System.Collections.Generic.List<Comment_Struct>(); Comment_Struct str_ct = default(Comment_Struct); //// generate query StringBuilder str = new StringBuilder(); StringBuilder query = new StringBuilder(); //// generate query string _filter = ""; if (profileid != "") _filter = "c.profileid=@profileid"; //_filter = "c.profileid=" + profileid.Replace("'",""); else _filter = "c.videoid=@id"; // _filter = "c.videoid=" + id; query.Append("c.commentid,c.username,c._comment,c.videoid,c.added_date,c.points,c.replyid"); // remove , if(ShowAuthoImage) query.Append(",u.picturename"); // remove, query.Append(" FROM comments c "); // WHERE p.videoid=555 ORDER BY level; if (ShowAuthoImage) query.Append("inner join users as u on u.username=c.username "); query.Append(" WHERE " + _filter + " AND c.type=@type AND c.isenabled=1 AND c.isApproved=1"); // implement paging script for differnt data sources. switch (Site_Settings.Pagination_Type) { case 0: // SQL SERVER 2005 or Later Supported Query str.Append(Pagination_Process.Prepare_SQLSERVER2005_Pagination(query.ToString(), Order, PageNumber, PageSize)); break; case 1: // MySQL Supported Query string mysql_query = "SELECT " + query.ToString() + " ORDER BY " + Order; str.Append(Pagination_Process.Prepare_MySQL_Pagination(mysql_query, PageNumber, PageSize)); break; case 2: // SQL SERVER 2000 Supported Query string normal_query = "SELECT " + query.ToString() + " ORDER BY " + Order; str.Append(normal_query); break; } SqlParameter profileparam = new SqlParameter("@profileid", profileid); SqlParameter contentidparam = new SqlParameter("@id", id); SqlParameter typeparam = new SqlParameter("@type", type); SqlCommand cmd = new SqlCommand(str.ToString(), con); cmd.Parameters.Add(profileparam); cmd.Parameters.Add(contentidparam); cmd.Parameters.Add(typeparam); SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (reader.Read()) { str_ct = new Comment_Struct(); str_ct.CommentID = (long)reader["CommentID"]; str_ct.UserName = reader["username"].ToString(); str_ct.Added_Date = (DateTime)reader["added_date"]; str_ct.Comment = reader["_comment"].ToString(); str_ct.VideoID = Convert.ToInt64(reader["videoid"]); str_ct.Points = (int)reader["points"]; str_ct.ReplyID = Convert.ToInt64(reader["replyid"]); if (ShowAuthoImage) str_ct.PictureName = reader["picturename"].ToString(); items.Add(str_ct); } reader.Close(); con.Close(); return items; }
// Fetch all video comments public static List<Comment_Struct> Fetch_Comments(long id,int type,int PageNumber,int PageSize) { SqlConnection con = new SqlConnection(Config.ConnectionString); con.Open(); System.Collections.Generic.List<Comment_Struct> items = new System.Collections.Generic.List<Comment_Struct>(); Comment_Struct str_ct = default(Comment_Struct); //// generate query StringBuilder str = new StringBuilder(); StringBuilder query = new StringBuilder(); query.Append("commentid,username,_comment,videoid,added_date,points from comments WHERE VideoID=" + id + " AND type=" + type + " AND isenabled=1 AND isApproved=1"); // implement paging script for differnt data sources. switch (Site_Settings.Pagination_Type) { case 0: // SQL SERVER 2005 or Later Supported Query str.Append(Pagination_Process.Prepare_SQLSERVER2005_Pagination(query.ToString(), "commentid DESC", PageNumber, PageSize)); break; case 1: // MySQL Supported Query string mysql_query = "SELECT " + query.ToString() + " ORDER BY commentid DESC"; str.Append(Pagination_Process.Prepare_MySQL_Pagination(mysql_query, PageNumber, PageSize)); break; case 2: // SQL SERVER 2000 Supported Query string normal_query = "SELECT " + query.ToString() + " ORDER BY commentid DESC"; str.Append(normal_query); break; } SqlCommand cmd = new SqlCommand(str.ToString(), con); SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (reader.Read()) { str_ct = new Comment_Struct(); str_ct.CommentID = (long)reader["CommentID"]; str_ct.UserName = reader["username"].ToString(); str_ct.Added_Date = (DateTime)reader["added_date"]; str_ct.Comment = reader["_comment"].ToString(); str_ct.VideoID = Convert.ToInt64(reader["videoid"]); str_ct.Points = (int)reader["points"]; items.Add(str_ct); } reader.Close(); con.Close(); return items; }
public string Process(Comment_Struct grp) { this.AuthorUrl = UrlConfig.Prepare_User_Profile_Url(grp.UserName, this.isAdmin); StringBuilder str = new StringBuilder(); string reply_pad = ""; string container_size = "100%"; if (grp.ReplyID > 0) { reply_pad = "padding-left:3%;"; container_size = "97%"; } // don't remove class name "vskcmtcnt" its internal use only str.Append("<div id=\"citem_" + grp.CommentID + "\" class=\"vskcmtcnt\" style=\"width:" + container_size + ";" + reply_pad + ";\">\n"); str.Append("<div id=\"cmsg_" + grp.CommentID + "\"></div>\n"); // to display runtime messages str.Append("<div class=\"" + this.BoxCssClass + "\">\n"); string container = "class=\"item_pad_2\""; if (this.isHoverEffect) container = "class=\"" + this.HoverCssClass + "\""; if (this.isAltColor) container = "class=\"" + this.AltCssClass + "\""; str.Append("<div " + container + ">\n"); switch (this.TemplateID) { case 0: // youtube style comment style str.Append(YoutubeStyleTemplate(grp)); break; case 1: // Facebook style comment str.Append(FBStyleTemplate(grp)); break; case 2: // Blog style comment str.Append(BlogStyleTemplate(grp)); break; case 3: // Simple Style str.Append(ProcessContent_Simple(grp)); break; } str.Append("</div>\n"); //close hover box str.Append("</div>\n"); // close box css class str.Append("</div>\n"); // close main box // reset urls for next itemgroup this.AuthorUrl = ""; return str.ToString(); }
private string FBStyleTemplate(Comment_Struct grp) { StringBuilder str = new StringBuilder(); if (this.ShowAuthorImage) { // show author thumb on right side of comment str.Append("<div style=\"float:left; width:" + this.LeftWidth + "%;\">\n"); str.Append(ProcessThumb(grp)); str.Append("</div>\n"); str.Append("<div style=\"float:right; width:" + this.RightWidth + "%;\">\n"); str.Append(ProcessContent_Fb(grp)); str.Append("</div>\n"); str.Append("<div class=\"clear\"></div>\n"); } else { str.Append("<div class=\"item\">\n"); str.Append(ProcessContent_Fb(grp)); str.Append("</div>\n"); } return str.ToString(); }
private string ProcessThumb(Comment_Struct grp) { StringBuilder str = new StringBuilder(); // photo thumb string image_src = UrlConfig.Return_Photo_Url(grp.UserName, grp.PictureName, 0, 0); str.Append("<a href=\"" + this.AuthorUrl + "\" title=\"" + grp.UserName + "\">"); // thumb link setup string border_class = this.ThumbRoundCssClass; if (!this.isRoundCorners) border_class = this.ThumbCssClass; str.Append("<img class=\"" + border_class + "\" src=\"" + image_src + "\" height=\"" + this.Height + "\" width=\"" + this.Width + "\">"); str.Append("</a>"); return str.ToString(); }
private string ProcessContent_Blog(Comment_Struct grp) { StringBuilder str = new StringBuilder(); int _content_left_width = 97; // % int _content_right_width = 12; // px; str.Append("<span id=\"cmtpts_" + grp.CommentID + "\" style=\"display:none;\">" + grp.Points + "</span>\n"); // Comment Section str.Append("<div style=\"float:left; width:" + _content_left_width + "%;\">\n"); // Show Comment str.Append("<div class=\"item\"><p>\n"); str.Append(grp.Comment); str.Append("</p></div>\n"); str.Append("<div class=\"action\">\n"); str.Append("<div style=\"float:left;width:50%;\">\n"); // Added Date if (Config.isFeature_Date() && this.ShowDate) { str.Append("<span class=\"light\">" + UtilityBLL.Generate_Date(grp.Added_Date, this.DateFormat) + "</span>"); } str.Append("</div>\n"); str.Append("<div id=\"cmt_action_fb_" + grp.CommentID + "\" class=\"item_r\" style=\"float:right;width:49%;\">\n"); if (grp.ReplyID == 0 && this.ShowReplyLink) { // reply link str.Append("<a href=\"#\" class=\"cmt_rep\" title=\"Reply to this comment\">Reply</a> . \n"); } if (this.ShowVotes) { //// comment like action to be store in span// 0: Like, 1: Unlike cmt_lk int likes = grp.Points; if (likes < 0) likes = 0; if (likes > 0) str.Append("<span id=\"cmtpl_" + grp.Points + "\" class=\"normal-text reverse\">" + likes + "</span> . "); str.Append("<a id=\"cmt_lk_" + grp.CommentID + "\" class=\"cmt_vu\" href=\"#\">Like</a> . \n"); } if (this.PosterUserName != "") { // if currently logged in user is author of post or author of comment, then shown remove comment link instead of flag link if (this.PosterUserName == grp.UserName || this.PosterUserName == this.AuthorUserName) { // remove link } else { // spam link str.Append("<a href=\"#\" class=\"cmt_flag\" title=\"Flag for Spam\">" + Resources.vsk.flag + "</a>"); } } else { // spam link str.Append("<a href=\"#\" class=\"cmt_flag\" title=\"Flag for Spam\">" + Resources.vsk.flag + "</a>"); } str.Append("</div>\n"); str.Append("<div class=\"clear\"></div>\n"); str.Append("</div>\n"); // approved, disabled if (this.ShowApproved && this.ShowDisabled) { str.Append("<div class=\"item_pad_2\">\n"); string _approve = "<span class=\"" + this.GoodCssClass + "\">" + Resources.vsk.approved + "</span>\n"; if (grp.isApproved == 0) _approve = "<span class=\"" + this.BadCssClass + "\">Not approved</span>\n"; string _disabled = "<span class=\"" + this.GoodCssClass + "\">" + Resources.vsk.enabled + "</span>\n"; if (grp.isEnabled == 0) _disabled = "<span class=\"" + this.BadCssClass + "\">Disabled</span>\n"; str.Append(_approve + " | " + _disabled); str.Append("</div>\n"); } else if (this.ShowApproved) { str.Append("<div class=\"item_pad_2\">\n"); string _approve = "<span class=\"" + this.GoodCssClass + "\">" + Resources.vsk.approved + "</span>\n"; if (grp.isApproved == 0) _approve = "<span class=\"" + this.BadCssClass + "\">Not approved</span>\n"; str.Append(_approve); str.Append("</div>\n"); } else if (this.ShowDisabled) { str.Append("<div class=\"item_pad_2\">\n"); string _disabled = "<span class=\"" + this.GoodCssClass + "\">" + Resources.vsk.enabled + "</span>\n"; if (grp.isEnabled == 0) _disabled = "<span class=\"" + this.BadCssClass + "\">Disabled</span>\n"; str.Append(_disabled); str.Append("</div>\n"); } str.Append("</div>\n"); // close float left div str.Append("<div id=\"cmt_action_" + grp.CommentID + "\" class=\"itm_cross\" style=\"float:right; width:" + _content_right_width + "px; display:none;\">\n"); if (this.PosterUserName != "") { // if currently logged in user is author of post or author of comment, then shown remove comment link instead of flag link if (this.PosterUserName == grp.UserName || this.PosterUserName == this.AuthorUserName) { // remove link str.Append("<a href=\"#\" class=\"cmt_remove\" title=\"Remove Comment\">X</a>"); } } str.Append("</div>\n"); // close float right div str.Append("<div class=\"clear\"></div>\n"); str.Append("<div id=\"cmtrepmsg_" + grp.CommentID + "\"></div>\n"); // reply comment box str.Append("<div id=\"cmtrep_" + grp.CommentID + "\"></div>\n"); // for showing comment box // Action Secction return str.ToString(); }
private string BlogStyleTemplate(Comment_Struct grp) { StringBuilder str = new StringBuilder(); if (this.ShowAuthorImage) { this.LeftWidth = 12; this.RightWidth = 87; // show author thumb on right side of comment str.Append("<div class=\"item_pad_4\">\n"); str.Append("<div style=\"float:left; width:" + this.LeftWidth + "%;\">\n"); str.Append(ProcessThumb(grp)); str.Append("</div>\n"); str.Append("<div style=\"float:right; width:" + this.RightWidth + "%;\">\n"); // show author if (Config.isFeature_UserName() && this.ShowAuthor) { // if username enabled string _usr = grp.UserName; if (_usr.Length > 18) _usr = _usr.Substring(0, 18) + ".."; string _usr_link = "<a id=\"cmtusr_" + grp.CommentID + "\" class=\"" + this.BoldLinkCssClass + "\" href=\"" + this.AuthorUrl + "\" title=\"" + grp.UserName + "\">" + _usr + "</a>"; str.Append(_usr_link); } str.Append("</div>\n"); str.Append("<div class=\"clear\"></div>\n"); str.Append("</div>\n"); } else { str.Append("<div class=\"item_pad_4\">\n"); // show author if (Config.isFeature_UserName() && this.ShowAuthor) { // if username enabled string _usr = grp.UserName; if (_usr.Length > 18) _usr = _usr.Substring(0, 18) + ".."; string _usr_link = "<a id=\"cmtusr_" + grp.CommentID + "\" class=\"" + this.BoldLinkCssClass + "\" href=\"" + this.AuthorUrl + "\" title=\"" + grp.UserName + "\">" + _usr + "</a>"; str.Append(_usr_link); } str.Append("</div>\n"); } str.Append("<div class=\"item_pad_4\">\n"); str.Append(ProcessContent_Blog(grp)); str.Append("</div>\n"); return str.ToString(); }
// Fetch Comments With User Profile Picture public static List <Comment_Struct> Fetch_Comments_V2(long id, string profileid, int type, int PageNumber, int PageSize, string Order, bool ShowAuthoImage) { SqlConnection con = new SqlConnection(Config.ConnectionString); con.Open(); System.Collections.Generic.List <Comment_Struct> items = new System.Collections.Generic.List <Comment_Struct>(); Comment_Struct str_ct = default(Comment_Struct); //// generate query StringBuilder str = new StringBuilder(); StringBuilder query = new StringBuilder(); //// generate query string _filter = ""; if (profileid != "") { _filter = "c.profileid=@profileid"; //_filter = "c.profileid=" + profileid.Replace("'",""); } else { _filter = "c.videoid=@id"; // _filter = "c.videoid=" + id; } query.Append("c.commentid,c.username,c._comment,c.videoid,c.added_date,c.points,c.replyid"); // remove , if (ShowAuthoImage) { query.Append(",u.picturename"); // remove, } query.Append(" FROM comments c "); // WHERE p.videoid=555 ORDER BY level; if (ShowAuthoImage) { query.Append("inner join users as u on u.username=c.username "); } query.Append(" WHERE " + _filter + " AND c.type=@type AND c.isenabled=1 AND c.isApproved=1"); // implement paging script for differnt data sources. switch (Site_Settings.Pagination_Type) { case 0: // SQL SERVER 2005 or Later Supported Query str.Append(Pagination_Process.Prepare_SQLSERVER2005_Pagination(query.ToString(), Order, PageNumber, PageSize)); break; case 1: // MySQL Supported Query string mysql_query = "SELECT " + query.ToString() + " ORDER BY " + Order; str.Append(Pagination_Process.Prepare_MySQL_Pagination(mysql_query, PageNumber, PageSize)); break; case 2: // SQL SERVER 2000 Supported Query string normal_query = "SELECT " + query.ToString() + " ORDER BY " + Order; str.Append(normal_query); break; } SqlParameter profileparam = new SqlParameter("@profileid", profileid); SqlParameter contentidparam = new SqlParameter("@id", id); SqlParameter typeparam = new SqlParameter("@type", type); SqlCommand cmd = new SqlCommand(str.ToString(), con); cmd.Parameters.Add(profileparam); cmd.Parameters.Add(contentidparam); cmd.Parameters.Add(typeparam); SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (reader.Read()) { str_ct = new Comment_Struct(); str_ct.CommentID = (long)reader["CommentID"]; str_ct.UserName = reader["username"].ToString(); str_ct.Added_Date = (DateTime)reader["added_date"]; str_ct.Comment = reader["_comment"].ToString(); str_ct.VideoID = Convert.ToInt64(reader["videoid"]); str_ct.Points = (int)reader["points"]; str_ct.ReplyID = Convert.ToInt64(reader["replyid"]); if (ShowAuthoImage) { str_ct.PictureName = reader["picturename"].ToString(); } items.Add(str_ct); } reader.Close(); con.Close(); return(items); }
// Fetch Recent Video comments public static List<Comment_Struct> Fetch_Comments(long id, int type,int total_records) { SqlConnection con = new SqlConnection(Config.ConnectionString); con.Open(); System.Collections.Generic.List<Comment_Struct> items = new System.Collections.Generic.List<Comment_Struct>(); Comment_Struct str_ct = default(Comment_Struct); //// generate query string Query = "SELECT TOP " + total_records + " commentid,username,_comment,videoid,added_date,points,replyid from comments WHERE videoid=" + id + " AND type=" + type + " AND isenabled=1 AND isApproved=1 ORDER BY commentid DESC"; SqlCommand cmd = new SqlCommand(Query, con); SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (reader.Read()) { str_ct = new Comment_Struct(); str_ct.CommentID = (long)reader["CommentID"]; str_ct.UserName = reader["username"].ToString(); str_ct.Added_Date = (DateTime)reader["added_date"]; str_ct.Comment = reader["_comment"].ToString(); str_ct.VideoID = Convert.ToInt64(reader["videoid"]); str_ct.Points = (int)reader["points"]; str_ct.ReplyID = Convert.ToInt64(reader["replyid"]); items.Add(str_ct); } reader.Close(); con.Close(); return items; }
// Load photos in admin section public static List <Comment_Struct> Load_Comments(string search, string username, string type, int isEnabled, int isApproved, int filteroption, string order, int PageNumber, int PageSize) { SqlConnection con = new SqlConnection(Config.ConnectionString); if (con.State != ConnectionState.Open) { con.Open(); } List <Comment_Struct> _items = new List <Comment_Struct>(); Comment_Struct _item; // Query Building StringBuilder str = new StringBuilder(); StringBuilder query = new StringBuilder(); string logic = CommentsBLL.Return_Comment_Admin_Logic(search, username, type, isEnabled, isApproved, filteroption); query.Append("commentid,videoid,username,_comment,added_date,isenabled,type,points,isapproved,replyid,profileid FROM comments" + logic); // implement paging script for differnt data sources. switch (Site_Settings.Pagination_Type) { case 0: // SQL SERVER 2005 or Later Supported Query str.Append(Pagination_Process.Prepare_SQLSERVER2005_Pagination(query.ToString(), order, PageNumber, PageSize)); break; case 1: // MySQL Supported Query string mysql_query = "SELECT " + query.ToString() + " ORDER BY " + order; str.Append(Pagination_Process.Prepare_MySQL_Pagination(mysql_query, PageNumber, PageSize)); break; case 2: // SQL SERVER 2000 Supported Query string normal_query = "SELECT " + query.ToString() + " ORDER BY " + order; str.Append(normal_query); break; } // execute sql query SqlCommand video_cmd = new SqlCommand(str.ToString(), con); video_cmd.Parameters.Add(new SqlParameter("@search", search)); video_cmd.Parameters.Add(new SqlParameter("@username", username)); video_cmd.Parameters.Add(new SqlParameter("@type", type)); video_cmd.Parameters.Add(new SqlParameter("@isenabled", isEnabled)); video_cmd.Parameters.Add(new SqlParameter("@isapproved", isApproved)); SqlDataReader reader = video_cmd.ExecuteReader(CommandBehavior.CloseConnection); while (reader.Read()) { _item = new Comment_Struct(); _item.CommentID = (long)reader["commentid"]; _item.Comment = reader["_comment"].ToString(); _item.UserName = reader["username"].ToString(); _item.VideoID = (long)reader["videoid"]; _item.isEnabled = Convert.ToInt32(reader["isenabled"]); _item.isApproved = Convert.ToInt32(reader["isapproved"]); _item.Type = Convert.ToInt32(reader["type"]); _item.ReplyID = (long)reader["replyid"]; _item.Points = Convert.ToInt32(reader["points"]); _item.Added_Date = (DateTime)reader["added_date"]; _item.ProfileID = reader["profileid"].ToString(); _items.Add(_item); } reader.Close(); con.Close(); con.Dispose(); return(_items); }
// Fetch Comments With User Profile Picture public static List<Comment_Struct> Fetch_Comments_V2(long id, string profileid, int type, int total_records, string Order, bool ShowAuthoImage) { SqlConnection con = new SqlConnection(Config.ConnectionString); con.Open(); System.Collections.Generic.List<Comment_Struct> items = new System.Collections.Generic.List<Comment_Struct>(); Comment_Struct str_ct = default(Comment_Struct); //// generate query string _filter = ""; if (profileid != "") _filter = "c.profileid=" + profileid; else _filter = "c.videoid=" + id; string Query = ""; if(!ShowAuthoImage) Query = "SELECT TOP " + total_records + " c.commentid,c.username,c._comment,c.videoid,c.added_date,c.points,c.replyid from comments as c WHERE " + _filter + " AND c.type=" + type + " AND c.isenabled=1 AND c.isApproved=1 ORDER BY " + Order + " DESC"; else Query = "SELECT TOP " + total_records + " c.commentid,c.username,c._comment,c.videoid,c.added_date,c.points,u.picturename,c.replyid from comments as c inner join users as u on u.username=c.username WHERe " + _filter + " AND c.type=" + type + " AND c.isenabled=1 AND c.isApproved=1 ORDER BY " + Order + ""; SqlCommand cmd = new SqlCommand(Query, con); SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (reader.Read()) { str_ct = new Comment_Struct(); str_ct.CommentID = (long)reader["CommentID"]; str_ct.UserName = reader["username"].ToString(); str_ct.Added_Date = (DateTime)reader["added_date"]; str_ct.Comment = reader["_comment"].ToString(); str_ct.VideoID = Convert.ToInt64(reader["videoid"]); str_ct.Points = (int)reader["points"]; str_ct.ReplyID = Convert.ToInt64(reader["replyid"]); if(profileid !="") str_ct.PictureName = reader["picturename"].ToString(); items.Add(str_ct); } reader.Close(); con.Close(); return items; }