Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            long.TryParse(Request["id"], out id);

            if (id > 0)
            {
                posts = PostDA.SelectByID(id);

                if (posts == null)
                {
                    mess = "Bài viết này không có, bạn hãy liên hệ với Admin về sự cố này.";
                    return;
                }
                else
                {
                    listPost = PostDA.SelectPostRelation(posts.CateID.Value, posts.ObjectID.Value, id, 4);
                }

                content = (posts.Content);
                shortContent = LanguageConvert.StripHtml(posts.Content, false);
                matchString = Regex.Match(content, "(?<=<img.*?src=\")[^\"]*(?=\".*?((/>)|(>.*</img)))", RegexOptions.IgnoreCase).Value;
                shortContent = shortContent.Replace("\"", "'");
                shortContent = shortContent.Length > 150 ? shortContent.Substring(0, shortContent.IndexOf(" ", 140)) : shortContent;

                urlShare = LinkBuilder.getLinkPost(posts.ID, posts.ObjectID.Value, posts.Title);
                string domain = CommentTotal.getDomain();
                urlShare = domain + urlShare;
                is_owner = (Current_user.Username == posts.UserName) ? true : false;
                Page.Title = posts.Title + " | T2S";
                Page.MetaDescription = shortContent;
                Page.MetaKeywords = posts.Tags;
                if (!IsPostBack)
                {
                    posts.View += 1;

                    PostDA.Update(posts);
                }

                //listComment = CommentDA.SelectByObjectID(id,page,pagesize);
                #region comment
                commentajax1.objectID = id;
                commentajax1.objecttype = "comment";
                commentajax1.receiverID = posts.AccountID;
                commentajax1.receiverUsername = posts.UserName;
                string url = Request.RawUrl;
                commentajax1.target_link = url;
                commentajax1.target_object_name = posts.Title.Length > 100 ? posts.Title.Substring(0, posts.Title.IndexOf(" ", 80)) : posts.Title;
                #endregion comment
            }
            else
            {
                //string cateSlug = Request["page"];
                //listPost = PostDA.SelectByCateNameSlug(cateSlug,page,pagesize);
                //countPage = PostDA.countAll(cateSlug);
            }
        }
Ejemplo n.º 2
0
        protected void btnCompose_Click(object sender, EventArgs e)
        {
            string content = Editor.Text;

            int forumid;
            int.TryParse(RadioButtonListCate.SelectedValue, out forumid);
            if (!string.IsNullOrEmpty(content) && !string.IsNullOrEmpty(txttitle.Text.Trim()))
            {
                Forum f = ForumDA.SelectByID(forumid);
                if (f != null)
                {
                    Category cate = CategoryDA.SelectByID(f.CateID.Value);
                    if (cate != null && Current_user != null && Current_user.ID > 0 && !string.IsNullOrEmpty(Current_user.Username))
                    {
                        hoachdinhtuonglai.Data.Core.Post post = new hoachdinhtuonglai.Data.Core.Post();
                        post.AccountID = Current_user.ID;
                        post.UserName = Current_user.Username;
                        post.CateID = cate.ID;
                        post.CateNameSlug = LanguageConvert.GenerateDesc(cate.CateName);
                        post.ObjectID = f.ID;
                        post.ObjectNameSlug = f.ForumNameSlug;
                        post.Spam = false;
                        post.Title = txttitle.Text.Trim();
                        post.View = 1;
                        post.Vote = 0;
                        post.Active = true;
                        post.Content = content;
                        if (!string.IsNullOrEmpty(txtKeyword.Text.Trim()))
                            post.Tags = txtKeyword.Text.Trim();
                        else
                            post.Tags = txttitle.Text.Trim();
                        long id = PostDA.Insert(post);
                        mess = "Gửi bài viết thành công.";
                        Response.Redirect(LinkBuilder.getLinkPost(id, post.Title));
                    }
                }

            }
            else
            {
                mess = "Bạn xem lại dữ liệu nhập nhé!";
            }
        }