Example #1
0
        private void FillSelectedPage(List <Post> posts, BlogsEngine engine)
        {
            var currentUser = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);

            if (posts == null || posts.Count == 0)
            {
                var emptyScreenControl = new EmptyScreenControl
                {
                    ImgSrc   = WebImageSupplier.GetAbsoluteWebPath("blog_icon.png", ASC.Blogs.Core.Constants.ModuleId),
                    Header   = BlogsResource.EmptyScreenBlogCaption,
                    Describe = currentUser.IsVisitor() ? BlogsResource.EmptyScreenBlogTextVisitor : BlogsResource.EmptyScreenBlogText
                };

                if (CommunitySecurity.CheckPermissions(new PersonalBlogSecObject(currentUser), ASC.Blogs.Core.Constants.Action_AddPost) &&
                    string.IsNullOrEmpty(UserID) && string.IsNullOrEmpty(Search))
                {
                    emptyScreenControl.ButtonHTML = String.Format("<a class='link underline blue plus' href='addblog.aspx'>{0}</a>", BlogsResource.EmptyScreenBlogLink);
                }

                placeContent.Controls.Add(emptyScreenControl);
                return;
            }


            PostsAndCommentsCount = engine.GetPostsCommentsCount(posts);
        }
Example #2
0
        public void UpdatePost(Post post, BlogsEngine engine)
        {
            post.Title   = GetLimitedText(txtTitle.Text);
            post.Content = (Request["blog_text"] ?? "");

            post.TagList = new List <Tag>();

            foreach (var tagName in txtTags.Text.Split(','))
            {
                if (tagName == string.Empty || IsExistsTagName(post, tagName))
                {
                    continue;
                }

                var tag = new Tag(post)
                {
                    Content = GetLimitedText(tagName.Trim())
                };
                post.TagList.Add(tag);
            }

            engine.SavePost(post, false, false);

            CommonControlsConfigurer.FCKEditingComplete("blogs", post.ID.ToString(), post.Content, true);

            Response.Redirect("viewblog.aspx?blogid=" + post.ID.ToString());
        }
Example #3
0
        public void UpdatePost(Post post, BlogsEngine engine)
        {
            post.Title   = GetLimitedText(txtTitle.Text);
            post.Content = _mobileVer ? (Request["mobiletext"] ?? "") : FCKeditor.Value;

            post.TagList = new List <Tag>();

            foreach (string tagName in txtTags.Text.Split(','))
            {
                if (tagName != string.Empty && !IsExistsTagName(post, tagName))
                {
                    Tag tag = new Tag(post);
                    tag.Content = GetLimitedText(tagName.Trim());
                    post.TagList.Add(tag);
                }
            }


            engine.SavePost(post, false, false);

            CommonControlsConfigurer.FCKEditingComplete("blogs", post.ID.ToString(), post.Content, true);



            Response.Redirect("viewblog.aspx?blogid=" + post.ID.ToString());
        }
Example #4
0
        private List <BlogInfo> GetBlogsStatistic(BlogsEngine engine, int filedID, bool sortDirection)
        {
            var sort = new CMPSort(filedID, sortDirection ? SortDirection.Ascending : SortDirection.Descending);

            this.sortedFiledID = filedID;
            this.direction     = sortDirection ? SortDirection.Ascending : SortDirection.Descending;

            var stat = engine.GetAuthorsStatistic();

            var listBlogs = new List <BlogInfo>(stat.Count);

            foreach (var blog in stat)
            {
                listBlogs.Add(new BlogInfo()
                {
                    ID            = blog.Value1,
                    BlogsCount    = blog.Value2,
                    CommentsCount = blog.Value3,
                    ReviewCount   = blog.Value4,

                    Name = DisplayUserSettings.GetFullUserName(blog.Value1)
                });
            }

            listBlogs.Sort(sort);

            return(listBlogs);
        }
        private void FillPosts(PostsQuery query, BlogsEngine engine)
        {
            query
            .SetOffset((SelectedPage - 1) * BlogsPageSize)
            .SetCount(BlogsPageSize);

            SetTotalPostsCount(engine.GetPostsCount(query));
            var posts = engine.SelectPosts(query);

            FillSelectedPage(posts, engine);
        }
Example #6
0
        private void ShowPost(BlogsEngine engine)
        {
            //EditBlogPresenter presenter = new EditBlogPresenter(ctrlViewBlogView, DaoFactory.GetBlogDao());
            //ctrlViewBlogView.AttachPresenter(presenter);

            ctrlViewBlogView.UpdateCompleted += new EventHandler(HandleUpdateCompleted);
            ctrlViewBlogView.UpdateCancelled += new EventHandler(HandleUpdateCancelled);

            if (!IsPostBack)
            {

                Post post = null;

                try
                {
                    post = engine.GetPostById(new Guid(BlogId));

                    base.InitSubscribers(actions, post.UserID);
                }
                catch (Exception)
                {
                    post = null;
                }

                if (post != null)
                {
                    ctrlViewBlogView.post = post;

                    mainContainer.BreadCrumbs.Add(new BreadCrumb { Caption = ASC.Blogs.Core.Resources.BlogsResource.AddonName, NavigationUrl = VirtualPathUtility.ToAbsolute(ASC.Blogs.Core.Constants.BaseVirtualPath ) });
                    mainContainer.BreadCrumbs.Add(new BreadCrumb { Caption = DisplayUserSettings.GetFullUserName(post.UserID, false), NavigationUrl = VirtualPathUtility.ToAbsolute(ASC.Blogs.Core.Constants.BaseVirtualPath) + "?userid=" + post.UserID });
                    mainContainer.BreadCrumbs.Add(new BreadCrumb { Caption = post.Title });

                    var loadedComments = engine.GetPostComments(post.ID);

                    commentList.Items = BuildCommentsList(post, loadedComments);


                    ConfigureComments(commentList, loadedComments.Count, post);

                    if (!SecurityContext.DemoMode)
                        engine.SavePostReview(post,SecurityContext.CurrentAccount.ID);
                }
                else
                {
                    ctrlViewBlogView.Visible = false;
                    lblMessage.Visible = true;
                    mainContainer.BreadCrumbs.Add(new BreadCrumb { Caption = ASC.Blogs.Core.Resources.BlogsResource.AddonName, NavigationUrl = VirtualPathUtility.ToAbsolute(ASC.Blogs.Core.Constants.BaseVirtualPath) });
                    commentList.Visible = false;
                    ConfigureComments(commentList, 0, null);
                }
            }
        }
Example #7
0
        private void ShowPost(BlogsEngine engine)
        {
            //EditBlogPresenter presenter = new EditBlogPresenter(ctrlViewBlogView, DaoFactory.GetBlogDao());
            //ctrlViewBlogView.AttachPresenter(presenter);

            ctrlViewBlogView.UpdateCompleted += HandleUpdateCompleted;
            ctrlViewBlogView.UpdateCancelled += HandleUpdateCancelled;

            if (IsPostBack)
            {
                return;
            }

            Post post;

            try
            {
                post = engine.GetPostById(new Guid(BlogId));
            }
            catch (Exception)
            {
                post = null;
            }

            if (post != null)
            {
                ctrlViewBlogView.post = post;
                var subscriber         = new Subscriber();
                var postId             = String.IsNullOrEmpty(BlogId) ? new Guid() : new Guid(BlogId);
                var isBlogSubscribe    = subscriber.IsCommentsSubscribe(postId);
                var subscribeTopicLink = subscriber.RenderCommentsSubscriptionLink(!isBlogSubscribe, postId);

                SubscribeLinkBlock.Text = subscribeTopicLink;

                BlogTitle = post.Title;

                var loadedComments = engine.GetPostComments(post.ID);

                commentList.Items = BuildCommentsList(post, loadedComments);

                ConfigureComments(commentList, loadedComments.Count, post);
                engine.SavePostReview(post, SecurityContext.CurrentAccount.ID);
            }
            else
            {
                ctrlViewBlogView.Visible         = false;
                lblMessage.Visible               = true;
                mainContainer.CurrentPageCaption = BlogsResource.AddonName;
                commentList.Visible              = false;
                ConfigureComments(commentList, 0, null);
            }
        }
Example #8
0
        private void ShowForEdit(BlogsEngine engine)
        {
            if (!IsPostBack)
            {
                var post = engine.GetPostById(new Guid(BlogId));

                InitPreviewTemplate(post);

                if (post != null && CommunitySecurity.CheckPermissions(post, Constants.Action_EditRemovePost))
                {
                    hdnUserID.Value = post.UserID.ToString();

                    if (Request.QueryString["action"] == "delete")
                    {
                        foreach (var comment in engine.GetPostComments(post.ID))
                        {
                            CommonControlsConfigurer.FCKUploadsRemoveForItem("blogs_comments", comment.ID.ToString());
                        }

                        engine.DeletePost(post);
                        CommonControlsConfigurer.FCKUploadsRemoveForItem("blogs", post.ID.ToString());
                        Response.Redirect(Constants.DefaultPageUrl);
                        return;
                    }
                    else
                    {
                        txtTitle.Text = Server.HtmlDecode(post.Title);

                        if (_mobileVer)
                        {
                            _text = post.Content;
                        }
                        else
                        {
                            FCKeditor.Value = post.Content;
                        }

                        hidBlogID.Value = post.ID.ToString();

                        LoadTags(post.TagList);
                    }
                }
                else
                {
                    Response.Redirect(Constants.DefaultPageUrl);
                    return;
                }
            }
        }
        private void ShowPost(BlogsEngine engine)
        {
            //EditBlogPresenter presenter = new EditBlogPresenter(ctrlViewBlogView, DaoFactory.GetBlogDao());
            //ctrlViewBlogView.AttachPresenter(presenter);

            ctrlViewBlogView.UpdateCompleted += HandleUpdateCompleted;
            ctrlViewBlogView.UpdateCancelled += HandleUpdateCancelled;

            if (IsPostBack) return;

            Post post;
            try
            {
                post = engine.GetPostById(new Guid(BlogId));
            }
            catch (Exception)
            {
                post = null;
            }

            if (post != null)
            {
                ctrlViewBlogView.post = post;
                var subscriber = new Subscriber();
                var postId = String.IsNullOrEmpty(BlogId) ? new Guid() : new Guid(BlogId);
                var isBlogSubscribe = subscriber.IsCommentsSubscribe(postId);
                var subscribeTopicLink = subscriber.RenderCommentsSubscriptionLink(!isBlogSubscribe, postId);

                SubscribeLinkBlock.Text = subscribeTopicLink;

                BlogTitle = post.Title;

                var loadedComments = engine.GetPostComments(post.ID);

                commentList.Items = BuildCommentsList(post, loadedComments);

                ConfigureComments(commentList, loadedComments.Count, post);
                engine.SavePostReview(post, SecurityContext.CurrentAccount.ID);
            }
            else
            {
                ctrlViewBlogView.Visible = false;
                lblMessage.Visible = true;
                mainContainer.CurrentPageCaption = BlogsResource.AddonName;
                commentList.Visible = false;
                ConfigureComments(commentList, 0, null);
            }
        }
Example #10
0
        private Post AddNewBlog(BlogsEngine engine)
        {
            var authorId = SecurityContext.CurrentAccount.ID;

            if (CommunitySecurity.CheckPermissions(
                    new PersonalBlogSecObject(CoreContext.UserManager.GetUsers(authorId)),
                    Constants.Action_AddPost))
            {
                var newPost = new Post
                {
                    Content = (Request["blog_text"] ?? "")
                };

                var dateNow = ASC.Core.Tenants.TenantUtil.DateTimeNow();

                newPost.Datetime = dateNow;
                newPost.Title    = GetLimitedText(txtTitle.Text);
                newPost.UserID   = authorId;

                newPost.TagList = new List <Tag>();
                foreach (var tagName in txtTags.Text.Split(','))
                {
                    if (tagName == string.Empty || IsExistsTagName(newPost, tagName))
                    {
                        continue;
                    }

                    var tag = new Tag
                    {
                        Content = GetLimitedText(tagName.Trim())
                    };
                    newPost.TagList.Add(tag);
                }
                engine.SavePost(newPost, true, Request.Form["notify_comments"] == "on");

                CommonControlsConfigurer.FCKEditingComplete("blogs", newPost.ID.ToString(), newPost.Content, false);

                return(newPost);
            }

            Response.Redirect("AddBlog.aspx");
            return(null);
        }
Example #11
0
        private Post AddNewBlog(BlogsEngine engine)
        {
            Guid authorId = SecurityContext.CurrentAccount.ID;

            if (CommunitySecurity.CheckPermissions(
                    new PersonalBlogSecObject(CoreContext.UserManager.GetUsers(authorId)),
                    ASC.Blogs.Core.Constants.Action_AddPost))
            {
                Post newPost = new Post();
                newPost.Content = _mobileVer? (Request["mobiletext"] ?? "") : FCKeditor.Value;

                DateTime dateNow = ASC.Core.Tenants.TenantUtil.DateTimeNow();

                newPost.Datetime = dateNow;
                newPost.Title    = GetLimitedText(txtTitle.Text);
                newPost.UserID   = authorId;

                newPost.TagList = new List <ASC.Blogs.Core.Domain.Tag>();
                foreach (string tagName in txtTags.Text.Split(','))
                {
                    if (tagName != string.Empty && !IsExistsTagName(newPost, tagName))
                    {
                        ASC.Blogs.Core.Domain.Tag tag = new ASC.Blogs.Core.Domain.Tag();
                        tag.Content = GetLimitedText(tagName.Trim());
                        newPost.TagList.Add(tag);
                    }
                }


                var blog = engine.EnsurePersonalBlog(authorId);
                engine.SavePost(newPost, true, Request.Form["notify_comments"] == "on");

                CommonControlsConfigurer.FCKEditingComplete("blogs", newPost.ID.ToString(), newPost.Content, false);

                return(newPost);
            }
            else
            {
                Response.Redirect("addblog.aspx");
                return(null);
            }
        }
Example #12
0
        public AjaxResponse UpdateComment(string commentID, string text, string pid)
        {
            AjaxResponse resp = new AjaxResponse();

            resp.rs1 = commentID;

            Guid?id = null;

            try
            {
                if (!String.IsNullOrEmpty(commentID))
                {
                    id = new Guid(commentID);
                }
            }
            catch
            {
                return(new AjaxResponse());
            }

            BlogsEngine engine = BasePage.GetEngine();

            var comment = engine.GetCommentById(id.Value);

            if (comment == null)
            {
                throw new ApplicationException("Comment not found");
            }

            CommunitySecurity.DemandPermissions(comment, ASC.Blogs.Core.Constants.Action_EditRemoveComment);

            comment.Content = text;

            var post = engine.GetPostById(comment.PostId);

            engine.UpdateComment(comment, post);

            resp.rs2 = text + Web.Controls.CodeHighlighter.GetJavaScriptLiveHighlight(true);

            return(resp);
        }
Example #13
0
        private void TryPostBlog(BlogsEngine engine)
        {
            if (CheckTitle(txtTitle.Text))
            {
                var post = AddNewBlog(engine);

                if (post != null)
                {
                    Response.Redirect("ViewBlog.aspx?blogid=" + post.ID.ToString());
                }
                else
                {
                    Response.Redirect(Constants.DefaultPageUrl);
                }
            }
            else
            {
                mainContainer.Options.InfoMessageText = BlogsResource.BlogTitleEmptyMessage;
                mainContainer.Options.InfoType        = InfoType.Alert;
            }
        }
Example #14
0
        public string RemoveComment(string commentID, string pid)
        {
            AjaxResponse resp = new AjaxResponse();

            resp.rs1 = commentID;

            Guid?id = null;

            try
            {
                if (!String.IsNullOrEmpty(commentID))
                {
                    id = new Guid(commentID);
                }
            }
            catch
            {
                return(commentID);
            }

            BlogsEngine engine = BasePage.GetEngine();

            var comment = engine.GetCommentById(id.Value);

            if (comment == null)
            {
                throw new ApplicationException("Comment not found");
            }

            CommunitySecurity.DemandPermissions(comment, ASC.Blogs.Core.Constants.Action_EditRemoveComment);

            comment.Inactive = true;

            var post = engine.GetPostById(comment.PostId);

            engine.RemoveComment(comment, post);

            return(commentID);
        }
Example #15
0
        private void FillPosts(PostsQuery query, BlogsEngine engine)
        {
            query
                .SetOffset((SelectedPage - 1)*BlogsPageSize)
                .SetCount(BlogsPageSize);

            SetTotalPostsCount(engine.GetPostsCount(query));
            var posts = engine.SelectPosts(query);
            FillSelectedPage(posts, engine);
        }
Example #16
0
        private void ShowForEdit(BlogsEngine engine)
        {
            if (!IsPostBack)
            {
                var post = engine.GetPostById(new Guid(BlogId));

                InitPreviewTemplate(post);

                if (post != null && CommunitySecurity.CheckPermissions(post, Constants.Action_EditRemovePost))
                {
                    hdnUserID.Value = post.UserID.ToString();

                    if (Request.QueryString["action"] == "delete")
                    {
                        foreach (var comment in engine.GetPostComments(post.ID))
                        {
                            CommonControlsConfigurer.FCKUploadsRemoveForItem("blogs_comments", comment.ID.ToString());
                        }

                        engine.DeletePost(post);
                        CommonControlsConfigurer.FCKUploadsRemoveForItem("blogs", post.ID.ToString());
                        Response.Redirect(Constants.DefaultPageUrl);
                        return;
                    }
                    else
                    {
                        txtTitle.Text = Server.HtmlDecode(post.Title);
                        _text = post.Content;
                        hidBlogID.Value = post.ID.ToString();

                        LoadTags(post.TagList);
                    }
                }
                else
                {
                    Response.Redirect(Constants.DefaultPageUrl);
                    return;
                }
            }
        }
Example #17
0
        public void UpdatePost(Post post, BlogsEngine engine)
        {
            post.Title = GetLimitedText(txtTitle.Text);
            post.Content = (Request["blog_text"] ?? "");

            post.TagList = new List<Tag>();

            foreach (var tagName in txtTags.Text.Split(','))
            {
                if (tagName == string.Empty || IsExistsTagName(post, tagName))
                    continue;

                var tag = new Tag(post)
                    {
                        Content = GetLimitedText(tagName.Trim())
                    };
                post.TagList.Add(tag);
            }

            engine.SavePost(post, false, false);

            CommonControlsConfigurer.FCKEditingComplete("blogs", post.ID.ToString(), post.Content, true);

            Response.Redirect("viewblog.aspx?blogid=" + post.ID.ToString());
        }
Example #18
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="blogApi"></param>
 public BlogActivityProvider(BlogApi blogApi)
 {
     _engine = blogApi.BlogEngine;
 }
Example #19
0
 public static BlogsEngine GetEngine()
 {
     return(BlogsEngine.GetEngine(TenantProvider.CurrentTenantID));
 }
Example #20
0
        private void FillSelectedPage(List <Post> posts, BlogsEngine engine)
        {
            var currentUser = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);

            if (posts == null || posts.Count == 0)
            {
                var emptyScreenControl = new EmptyScreenControl
                {
                    ImgSrc   = WebImageSupplier.GetAbsoluteWebPath("blog_icon.png", ASC.Blogs.Core.Constants.ModuleId),
                    Header   = BlogsResource.EmptyScreenBlogCaption,
                    Describe = BlogsResource.EmptyScreenBlogText
                };

                if (CommunitySecurity.CheckPermissions(new PersonalBlogSecObject(currentUser), ASC.Blogs.Core.Constants.Action_AddPost) &&
                    string.IsNullOrEmpty(UserID) && string.IsNullOrEmpty(Search))
                {
                    emptyScreenControl.ButtonHTML = String.Format("<a class='link underline blue plus' href='addblog.aspx'>{0}</a>", BlogsResource.EmptyScreenBlogLink);
                }

                placeContent.Controls.Add(emptyScreenControl);
                return;
            }

            placeContent.Controls.Add(new Literal {
                Text = "<div>"
            });

            var post_with_comments = engine.GetPostsCommentsCount(posts);

            if (!String.IsNullOrEmpty(UserID))
            {
                var post = post_with_comments[0].Item1;
                var st   = new StringBuilder();

                st.Append("<div class=\"BlogsHeaderBlock header-with-menu\" style=\"margin-bottom:16px;\">");
                st.Append("<span class=\"header\">" + CoreContext.UserManager.GetUsers(post.UserID).DisplayUserName() + "</span>");
                st.Append("</div>");

                placeContent.Controls.Add(new Literal {
                    Text = st.ToString()
                });
            }

            for (var i = 0; i < post_with_comments.Count; i++)
            {
                var post         = post_with_comments[i].Item1;
                var commentCount = post_with_comments[i].Item2;
                var sb           = new StringBuilder();
                var user         = CoreContext.UserManager.GetUsers(post.UserID);

                sb.Append("<div class=\"container-list\">");
                sb.Append("<div class=\"header-list\">");

                sb.Append("<div class=\"avatar-list\">");
                sb.Append("<a href=\"viewblog.aspx?blogid=" + post.ID.ToString() + "\">" + ImageHTMLHelper.GetHTMLUserAvatar(user.ID) + "</a>");
                sb.Append("</div><div class=\"describe-list\">");
                sb.Append("<div class=\"title-list\">");
                sb.Append("<a href=\"viewblog.aspx?blogid=" + post.ID.ToString() + "\">" + HttpUtility.HtmlEncode(post.Title) + "</a>");
                sb.Append("</div>");

                sb.Append("<div class=\"info-list\">");
                sb.Append("<span class=\"caption-list\">" + BlogsResource.PostedTitle + ":</span>");
                sb.Append(user.RenderCustomProfileLink("name-list", "link"));
                sb.Append("</div>");

                if (String.IsNullOrEmpty(UserID))
                {
                    sb.Append("<div class=\"info-list\">");
                    sb.Append("<a class=\"link gray-text\" href=\"" + VirtualPathUtility.ToAbsolute(ASC.Blogs.Core.Constants.BaseVirtualPath) + "?userid=" + post.UserID + "\">" + BlogsResource.AllRecordsOfTheAutor + "</a>");
                    sb.Append("</div>");
                }

                sb.Append("<div class=\"date-list\">");
                sb.AppendFormat("{0}<span class=\"time-list\">{1}</span>", post.Datetime.ToString("d"), post.Datetime.ToString("t"));
                sb.Append("</div></div></div>");

                sb.Append("<div class=\"content-list\">");

                sb.Append(HtmlUtility.GetFull(post.Content, false));
                sb.Append("<div id=\"postIndividualLink\" class=\"display-none\">viewblog.aspx?blogid=" + post.ID.ToString() + "</div>");
                sb.Append("<div class=\"comment-list\">");
                sb.Append("<a href=\"viewblog.aspx?blogid=" + post.ID + "#comments\">" + BlogsResource.CommentsTitle + ": " + commentCount.ToString() + "</a>");
                if (!currentUser.IsOutsider())
                {
                    sb.Append("<a href=\"viewblog.aspx?blogid=" + post.ID + "#addcomment\">" + BlogsResource.CommentsAddButtonTitle + "</a>");
                }
                sb.Append("</div></div></div>");

                placeContent.Controls.Add(new Literal {
                    Text = sb.ToString()
                });
            }

            placeContent.Controls.Add(new Literal {
                Text = "</div>"
            });
        }
Example #21
0
        private void FillSelectedPage(List <Post> posts, BlogsEngine engine)
        {
            if (posts == null || posts.Count == 0)
            {
                var emptyScreenControl = new EmptyScreenControl
                {
                    ImgSrc   = WebImageSupplier.GetAbsoluteWebPath("blog_icon.png", ASC.Blogs.Core.Constants.ModuleId),
                    Header   = BlogsResource.EmptyScreenBlogCaption,
                    Describe = BlogsResource.EmptyScreenBlogText
                };

                if (CommunitySecurity.CheckPermissions(new PersonalBlogSecObject(CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID)), ASC.Blogs.Core.Constants.Action_AddPost) &&
                    string.IsNullOrEmpty(UserID) && string.IsNullOrEmpty(Search))
                {
                    emptyScreenControl.ButtonHTML = String.Format("<a class='linkAddMediumText' href='addblog.aspx'>{0}</a>", BlogsResource.EmptyScreenBlogLink);
                }

                placeContent.Controls.Add(emptyScreenControl);
                return;
            }

            placeContent.Controls.Add(new Literal {
                Text = "<div>"
            });

            var post_with_comments = engine.GetPostsCommentsCount(posts);

            for (var i = 0; i < post_with_comments.Count; i++)
            {
                var post         = post_with_comments[i].Value1;
                var commentCount = post_with_comments[i].Value2;

                var sb = new StringBuilder();

                sb.Append("<div class=\"" + (i % 2 == 1 ? "tintLight" : "tintMedium") + " borderBase\" style=\"border-width: " + (i == 0 ? "1px" : "0") + " 0 1px 0;padding: 10px 14px;\">");

                sb.Append("<table class='BlogsTable' cellspacing='0' cellpadding='0' border='0'><tr><td valign='top'>");
                sb.Append("<div style='padding-top:4px;'>" + ImageHTMLHelper.GetLinkUserAvatar(post.UserID) + "</div>");
                sb.Append("</td><td><div class='longWordsBreak MainInfoBlock'>");

                sb.Append("<a href=\"viewblog.aspx?blogid=" + post.ID.ToString() + "\" class=\"linkHeaderLight\">" + HttpUtility.HtmlEncode(post.Title) + "</a>");

                sb.Append("<div class='BlockCreater'>");

                sb.Append("<a class='linkHeaderSmall' href='" + VirtualPathUtility.ToAbsolute(ASC.Blogs.Core.Constants.BaseVirtualPath) + "?userid=" + post.UserID + "'><span style='font-weight:normal;'>" + BlogsResource.BlogOfTitle + ":&nbsp;&nbsp;</span>" + DisplayUserSettings.GetFullUserName(post.UserID) + "</a>");

                sb.Append("</div>");
                sb.Append("<div >");
                sb.Append("<span class='textMediumDescribe' style='margin-right:5px;'>" + BlogsResource.PostedTitle + ":</span> " + CoreContext.UserManager.GetUsers(post.UserID).RenderProfileLink(Product.CommunityProduct.ID));
                sb.Append("<span class='textMediumDescribe'>&nbsp;&nbsp;" + post.Datetime.Ago() + "</span>");
                sb.Append("</div>");

                sb.Append("</div>");
                placeContent.Controls.Add(new Literal {
                    Text = sb.ToString()
                });


                sb = new StringBuilder();

                sb.Append("<div class='longWordsBreak ContentBlock'>");

                sb.Append(HtmlUtility.GetPreview(post.Content, "<div style='margin-top:15px;'><a style='text-decoration:none;' href=\"viewblog.aspx?blogid=" + post.ID.ToString() + "\"><font style='text-decoration:underline;'>" + ASC.Blogs.Core.Resources.BlogsResource.ReadMoreLink + "</font><font style='font-size:14px;text-decoration:none;'>&nbsp;&#8594</font></a></div>", Product.CommunityProduct.ID));

                sb.Append("</div>");


                sb.Append("<div class='clearFix CommentsBlock'>");
                if (post.TagList.Count > 0)
                {
                    sb.Append("<div class=\"textMediumDescribe TagsBlock\">");
                    sb.Append("<img class=\"TagsImgBlock\" src=\"" + WebImageSupplier.GetAbsoluteWebPath("tags.png", BlogsSettings.ModuleID) + "\">");

                    var j = 0;
                    foreach (var tag in post.TagList)
                    {
                        if (j != 0)
                        {
                            sb.Append(", ");
                        }
                        j++;
                        sb.Append("<a style='margin-left:5px;' class=\"linkDescribe\" href=\"./?tagname=" + HttpUtility.UrlEncode(tag.Content) + "\">" + HttpUtility.HtmlEncode(tag.Content) + "</a>");
                    }

                    sb.Append("</div>");
                }

                sb.Append("<div class='CommentsLinkBlock'>");
                sb.Append("<a href='viewblog.aspx?blogid=" + post.ID + "#comments'>" + BlogsResource.CommentsTitle + ": " + commentCount.ToString() + "</a>");
                sb.Append("</div>");

                sb.Append("</div></td></tr></table>");

                sb.Append("</div>");


                placeContent.Controls.Add(new Literal {
                    Text = sb.ToString()
                });
            }

            placeContent.Controls.Add(new Literal {
                Text = "</div>"
            });
        }
Example #22
0
        public void UpdatePost(Post post, BlogsEngine engine)
        {
            post.Title = GetLimitedText(txtTitle.Text);
            post.Content = _mobileVer ? (Request["mobiletext"]??"") : FCKeditor.Value;

            post.TagList = new List<Tag>();

            foreach (string tagName in txtTags.Text.Split(','))
            {
                if (tagName != string.Empty && !IsExistsTagName(post, tagName))
                {
                    Tag tag = new Tag(post);
                    tag.Content = GetLimitedText(tagName.Trim());
                    post.TagList.Add(tag);
                }
            }


            engine.SavePost(post,false,false);

            CommonControlsConfigurer.FCKEditingComplete("blogs", post.ID.ToString(), post.Content, true);



            Response.Redirect("viewblog.aspx?blogid=" + post.ID.ToString());

        }
Example #23
0
        private void FillSelectedPage(List<Post> posts, BlogsEngine engine)
        {
            if (posts == null || posts.Count == 0)
            {
                var emptyScreenControl = new EmptyScreenControl
                                             {
                                                 ImgSrc = WebImageSupplier.GetAbsoluteWebPath("blog_icon.png", ASC.Blogs.Core.Constants.ModuleId),
                                                 Header = BlogsResource.EmptyScreenBlogCaption,
                                                 Describe = BlogsResource.EmptyScreenBlogText
                                             };

                if (CommunitySecurity.CheckPermissions(new PersonalBlogSecObject(CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID)), ASC.Blogs.Core.Constants.Action_AddPost)
                    && string.IsNullOrEmpty(UserID) && string.IsNullOrEmpty(Search))
                {
                    emptyScreenControl.ButtonHTML = String.Format("<a class='linkAddMediumText' href='addblog.aspx'>{0}</a>", BlogsResource.EmptyScreenBlogLink);
                }

                placeContent.Controls.Add(emptyScreenControl);
                return;
            }

            placeContent.Controls.Add(new Literal {Text = "<div>"});

            var post_with_comments = engine.GetPostsCommentsCount(posts);

            for (var i = 0; i < post_with_comments.Count; i++)
            {

                var post = post_with_comments[i].Value1;
                var commentCount = post_with_comments[i].Value2;

                var sb = new StringBuilder();

                sb.Append("<div class=\"" + (i%2 == 1 ? "tintLight" : "tintMedium") + " borderBase\" style=\"border-width: " + (i == 0 ? "1px" : "0") + " 0 1px 0;padding: 10px 14px;\">");

                sb.Append("<table class='BlogsTable' cellspacing='0' cellpadding='0' border='0'><tr><td valign='top'>");
                sb.Append("<div style='padding-top:4px;'>" + ImageHTMLHelper.GetLinkUserAvatar(post.UserID) + "</div>");
                sb.Append("</td><td><div class='longWordsBreak MainInfoBlock'>");

                sb.Append("<a href=\"viewblog.aspx?blogid=" + post.ID.ToString() + "\" class=\"linkHeaderLight\">" + HttpUtility.HtmlEncode(post.Title) + "</a>");

                sb.Append("<div class='BlockCreater'>");

                sb.Append("<a class='linkHeaderSmall' href='" + VirtualPathUtility.ToAbsolute(ASC.Blogs.Core.Constants.BaseVirtualPath) + "?userid=" + post.UserID + "'><span style='font-weight:normal;'>" + BlogsResource.BlogOfTitle + ":&nbsp;&nbsp;</span>" + DisplayUserSettings.GetFullUserName(post.UserID) + "</a>");

                sb.Append("</div>");
                sb.Append("<div >");
                sb.Append("<span class='textMediumDescribe' style='margin-right:5px;'>" + BlogsResource.PostedTitle + ":</span> " + CoreContext.UserManager.GetUsers(post.UserID).RenderProfileLink(Product.CommunityProduct.ID));
                sb.Append("<span class='textMediumDescribe'>&nbsp;&nbsp;" + post.Datetime.Ago() + "</span>");
                sb.Append("</div>");

                sb.Append("</div>");
                placeContent.Controls.Add(new Literal {Text = sb.ToString()});


                sb = new StringBuilder();

                sb.Append("<div class='longWordsBreak ContentBlock'>");

                sb.Append(HtmlUtility.GetPreview(post.Content, "<div style='margin-top:15px;'><a style='text-decoration:none;' href=\"viewblog.aspx?blogid=" + post.ID.ToString() + "\"><font style='text-decoration:underline;'>" + ASC.Blogs.Core.Resources.BlogsResource.ReadMoreLink + "</font><font style='font-size:14px;text-decoration:none;'>&nbsp;&#8594</font></a></div>", Product.CommunityProduct.ID));

                sb.Append("</div>");


                sb.Append("<div class='clearFix CommentsBlock'>");
                if (post.TagList.Count > 0)
                {
                    sb.Append("<div class=\"textMediumDescribe TagsBlock\">");
                    sb.Append("<img class=\"TagsImgBlock\" src=\"" + WebImageSupplier.GetAbsoluteWebPath("tags.png", BlogsSettings.ModuleID) + "\">");

                    var j = 0;
                    foreach (var tag in post.TagList)
                    {
                        if (j != 0)
                            sb.Append(", ");
                        j++;
                        sb.Append("<a style='margin-left:5px;' class=\"linkDescribe\" href=\"./?tagname=" + HttpUtility.UrlEncode(tag.Content) + "\">" + HttpUtility.HtmlEncode(tag.Content) + "</a>");
                    }

                    sb.Append("</div>");
                }

                sb.Append("<div class='CommentsLinkBlock'>");
                sb.Append("<a href='viewblog.aspx?blogid=" + post.ID + "#comments'>" + BlogsResource.CommentsTitle + ": " + commentCount.ToString() + "</a>");
                sb.Append("</div>");

                sb.Append("</div></td></tr></table>");

                sb.Append("</div>");


                placeContent.Controls.Add(new Literal {Text = sb.ToString()});
            }

            placeContent.Controls.Add(new Literal {Text = "</div>"});

        }
Example #24
0
        private void FillSelectedPage(List<Post> posts, BlogsEngine engine)
        {
            if (posts == null || posts.Count == 0)
            {
                var emptyScreenControl = new EmptyScreenControl
                    {
                        ImgSrc = WebImageSupplier.GetAbsoluteWebPath("blog_icon.png", ASC.Blogs.Core.Constants.ModuleId),
                        Header = BlogsResource.EmptyScreenBlogCaption,
                        Describe = BlogsResource.EmptyScreenBlogText
                    };

                if (CommunitySecurity.CheckPermissions(new PersonalBlogSecObject(CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID)), ASC.Blogs.Core.Constants.Action_AddPost)
                    && string.IsNullOrEmpty(UserID) && string.IsNullOrEmpty(Search))
                {
                    emptyScreenControl.ButtonHTML = String.Format("<a class='link underline blue plus' href='addblog.aspx'>{0}</a>", BlogsResource.EmptyScreenBlogLink);
                }

                placeContent.Controls.Add(emptyScreenControl);
                return;
            }

            placeContent.Controls.Add(new Literal {Text = "<div>"});

            var post_with_comments = engine.GetPostsCommentsCount(posts);

            if (!String.IsNullOrEmpty(UserID))
            {

                var post = post_with_comments[0].Item1;
                var user = CoreContext.UserManager.GetUsers(post.UserID);

                var st = new StringBuilder();
                st.Append("<div class=\"BlogsHeaderBlock\" style=\"margin-bottom:16px;\">");
                st.Append("<span class=\"header-with-menu\">" + CoreContext.UserManager.GetUsers(user.ID).DisplayUserName() + "</span>");
                st.Append("</div>");

                placeContent.Controls.Add(new Literal {Text = st.ToString()});
            }

            for (var i = 0; i < post_with_comments.Count; i++)
            {
                var post = post_with_comments[i].Item1;
                var commentCount = post_with_comments[i].Item2;

                var sb = new StringBuilder();
                var user = CoreContext.UserManager.GetUsers(post.UserID);

                sb.Append("<div class=\"container-list\">");
                sb.Append("<div class=\"header-list\">");

                sb.Append("<div class=\"avatar-list\">");
                sb.Append("<a href=\"viewblog.aspx?blogid=" + post.ID.ToString() + "\">" + ImageHTMLHelper.GetHTMLUserAvatar(post.UserID) + "</a>");
                sb.Append("</div><div class=\"describe-list\">");
                sb.Append("<div class=\"title-list\">");
                sb.Append("<a href=\"viewblog.aspx?blogid=" + post.ID.ToString() + "\">" + HttpUtility.HtmlEncode(post.Title) + "</a>");
                sb.Append("</div>");

                sb.Append("<div class=\"info-list\">");
                sb.Append("<span class=\"caption-list\">" + BlogsResource.PostedTitle + ":</span>");
                sb.Append(CoreContext.UserManager.GetUsers(user.ID).RenderCustomProfileLink(CommunityProduct.ID, "name-list", "link"));
                sb.Append("</div>");
                if (String.IsNullOrEmpty(UserID))
                {
                    sb.Append("<div class=\"info-list\">");
                    sb.Append("<a class=\"link gray-text\" href=\"" + VirtualPathUtility.ToAbsolute(ASC.Blogs.Core.Constants.BaseVirtualPath) + "?userid=" + post.UserID + "\">" + BlogsResource.AllRecordsOfTheAutor + "</a>");
                    sb.Append("</div>");
                }

                sb.Append("<div class=\"date-list\">");
                sb.AppendFormat("{0}<span class=\"time-list\">{1}</span>", post.Datetime.ToString("d"), post.Datetime.ToString("t"));
                sb.Append("</div></div></div>");

                sb.Append("<div class=\"content-list\">");
               
                sb.Append(post.Content);
                sb.Append("<div id=\"postIndividualLink\" class=\"display-none\">viewblog.aspx?blogid=" + post.ID.ToString() + "</div>");               
                sb.Append("<div class=\"comment-list\">");
                sb.Append("<a href=\"viewblog.aspx?blogid=" + post.ID + "#comments\">" + BlogsResource.CommentsTitle + ": " + commentCount.ToString() + "</a>");
                sb.Append("<a href=\"viewblog.aspx?blogid=" + post.ID + "#addcomment\">" + BlogsResource.CommentsAddButtonTitle + "</a>");
                sb.Append("</div></div></div>");

                placeContent.Controls.Add(new Literal {Text = sb.ToString()});
            }

            placeContent.Controls.Add(new Literal {Text = "</div>"});
        }
        private Post AddNewBlog(BlogsEngine engine)
        {
            var authorId = SecurityContext.CurrentAccount.ID;

            if (CommunitySecurity.CheckPermissions(
                new PersonalBlogSecObject(CoreContext.UserManager.GetUsers(authorId)),
                Constants.Action_AddPost))
            {
                var newPost = new Post
                    {
                        Content = (Request["mobiletext"] ?? "")
                    };

                var dateNow = ASC.Core.Tenants.TenantUtil.DateTimeNow();

                newPost.Datetime = dateNow;
                newPost.Title = GetLimitedText(txtTitle.Text);
                newPost.UserID = authorId;

                newPost.TagList = new List<Tag>();
                foreach (var tagName in txtTags.Text.Split(','))
                {
                    if (tagName == string.Empty || IsExistsTagName(newPost, tagName))
                        continue;

                    var tag = new Tag
                        {
                            Content = GetLimitedText(tagName.Trim())
                        };
                    newPost.TagList.Add(tag);
                }
                engine.SavePost(newPost, true, Request.Form["notify_comments"] == "on");

                CommonControlsConfigurer.FCKEditingComplete("blogs", newPost.ID.ToString(), newPost.Content, false);

                return newPost;
            }

            Response.Redirect("addblog.aspx");
            return null;
        }
Example #26
0
 public void InitSidePanel(BlogsEngine engine, TagCloud tagCloud)
 {
     tagCloud.SetTags(engine.GetTopTagsList(40));
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="blogApi"></param>
 public BlogActivityProvider(BlogApi blogApi)
 {
     _engine = blogApi.BlogEngine;
 }
Example #28
0
        private void ShowPost(BlogsEngine engine)
        {
            //EditBlogPresenter presenter = new EditBlogPresenter(ctrlViewBlogView, DaoFactory.GetBlogDao());
            //ctrlViewBlogView.AttachPresenter(presenter);

            ctrlViewBlogView.UpdateCompleted += new EventHandler(HandleUpdateCompleted);
            ctrlViewBlogView.UpdateCancelled += new EventHandler(HandleUpdateCancelled);

            if (!IsPostBack)
            {
                Post post = null;

                try
                {
                    post = engine.GetPostById(new Guid(BlogId));

                    base.InitSubscribers(actions, post.UserID);
                }
                catch (Exception)
                {
                    post = null;
                }

                if (post != null)
                {
                    ctrlViewBlogView.post = post;

                    mainContainer.BreadCrumbs.Add(new BreadCrumb {
                        Caption = ASC.Blogs.Core.Resources.BlogsResource.AddonName, NavigationUrl = VirtualPathUtility.ToAbsolute(ASC.Blogs.Core.Constants.BaseVirtualPath)
                    });
                    mainContainer.BreadCrumbs.Add(new BreadCrumb {
                        Caption = DisplayUserSettings.GetFullUserName(post.UserID, false), NavigationUrl = VirtualPathUtility.ToAbsolute(ASC.Blogs.Core.Constants.BaseVirtualPath) + "?userid=" + post.UserID
                    });
                    mainContainer.BreadCrumbs.Add(new BreadCrumb {
                        Caption = post.Title
                    });

                    var loadedComments = engine.GetPostComments(post.ID);

                    commentList.Items = BuildCommentsList(post, loadedComments);


                    ConfigureComments(commentList, loadedComments.Count, post);

                    if (!SecurityContext.DemoMode)
                    {
                        engine.SavePostReview(post, SecurityContext.CurrentAccount.ID);
                    }
                }
                else
                {
                    ctrlViewBlogView.Visible = false;
                    lblMessage.Visible       = true;
                    mainContainer.BreadCrumbs.Add(new BreadCrumb {
                        Caption = ASC.Blogs.Core.Resources.BlogsResource.AddonName, NavigationUrl = VirtualPathUtility.ToAbsolute(ASC.Blogs.Core.Constants.BaseVirtualPath)
                    });
                    commentList.Visible = false;
                    ConfigureComments(commentList, 0, null);
                }
            }
        }
Example #29
0
 public void InitSidePanel(BlogsEngine engine, TagCloud tagCloud)
 {
     tagCloud.SetTags(engine.GetTopTagsList(40));
 }
        private void TryPostBlog(BlogsEngine engine)
        {
            if (CheckTitle(txtTitle.Text))
            {
                var post = AddNewBlog(engine);

                if (post != null)
                    Response.Redirect("viewblog.aspx?blogid=" + post.ID.ToString());
                else
                    Response.Redirect(Constants.DefaultPageUrl);
            }
            else
            {
                mainContainer.Options.InfoMessageText = BlogsResource.BlogTitleEmptyMessage;
                mainContainer.Options.InfoType = InfoType.Alert;
            }
        }