コード例 #1
0
        public virtual void AddForumPostTokens(IList <Token> tokens, ForumPost forumPost)
        {
            tokens.Add(new Token("Forums.PostAuthor", forumPost.Customer.FormatUserName()));
            tokens.Add(new Token("Forums.PostBody", forumPost.FormatPostText(), true));

            //event notification
            _eventPublisher.EntityTokensAdded(forumPost, tokens);
        }
コード例 #2
0
        protected virtual object CreateModelPart(ForumPost part, MessageContext messageContext)
        {
            Guard.NotNull(messageContext, nameof(messageContext));
            Guard.NotNull(part, nameof(part));

            var m = new Dictionary <string, object>
            {
                { "Author", part.Customer.FormatUserName().NullEmpty() },
                { "Body", part.FormatPostText().NullEmpty() }
            };

            PublishModelPartCreatedEvent <ForumPost>(part, m);

            return(m);
        }
コード例 #3
0
        protected void gvLP_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                ForumPost forumPost = (ForumPost)e.Row.DataItem;

                //topic info
                HyperLink hlTopic = e.Row.FindControl("hlTopic") as HyperLink;
                if (hlTopic != null)
                {
                    ForumTopic forumTopic = forumPost.Topic;
                    if (forumTopic != null)
                    {
                        hlTopic.Text        = Server.HtmlEncode(forumTopic.Subject);
                        hlTopic.NavigateUrl = SEOHelper.GetForumTopicUrl(forumPost.TopicId);
                    }
                }

                //post date
                Label lblPosted = e.Row.FindControl("lblPosted") as Label;
                if (lblPosted != null)
                {
                    string dateStr = string.Empty;
                    if (this.ForumService.RelativeDateTimeFormattingEnabled)
                    {
                        dateStr = forumPost.CreatedOn.RelativeFormat(true, "f");
                    }
                    else
                    {
                        dateStr = DateTimeHelper.ConvertToUserTime(forumPost.CreatedOn, DateTimeKind.Utc).ToString("f");
                    }

                    lblPosted.Text = dateStr;
                }

                //forum post
                Label lblPost = e.Row.FindControl("lblPost") as Label;
                if (lblPost != null)
                {
                    lblPost.Text = forumPost.FormatPostText();
                }
            }
        }
コード例 #4
0
 public virtual void AddForumPostTokens(IList <Token> tokens, ForumPost forumPost)
 {
     tokens.Add(new Token("Forums.PostAuthor", forumPost.Customer.FormatUserName()));
     tokens.Add(new Token("Forums.PostBody", forumPost.FormatPostText(), true));
 }
コード例 #5
0
        public void BindData()
        {
            if (forumPost != null)
            {
                lAnchor.Text = string.Format("<a name=\"{0}\"></a>", forumPost.ForumPostId);

                btnEdit.Visible         = this.ForumService.IsUserAllowedToEditPost(NopContext.Current.User, forumPost);
                btnDelete.Visible       = this.ForumService.IsUserAllowedToDeletePost(NopContext.Current.User, forumPost);
                btnDelete.OnClientClick = string.Format("return confirm('{0}')", GetLocaleResourceString("Common.AreYouSure"));

                //post date
                string dateStr = string.Empty;
                if (this.ForumService.RelativeDateTimeFormattingEnabled)
                {
                    dateStr = forumPost.CreatedOn.RelativeFormat(true, "f");
                }
                else
                {
                    dateStr = DateTimeHelper.ConvertToUserTime(forumPost.CreatedOn, DateTimeKind.Utc).ToString("f");
                }
                lblDate.Text = dateStr;

                //forum text
                lText.Text          = forumPost.FormatPostText();
                lblForumPostId.Text = forumPost.ForumPostId.ToString();

                var customer = forumPost.User;
                if (customer != null)
                {
                    if (this.CustomerService.AllowViewingProfiles && !customer.IsGuest)
                    {
                        hlUser.Text        = Server.HtmlEncode(customer.FormatUserName(true));
                        hlUser.NavigateUrl = SEOHelper.GetUserProfileUrl(customer.CustomerId);
                        lblUser.Visible    = false;
                    }
                    else
                    {
                        lblUser.Text   = Server.HtmlEncode(customer.FormatUserName(true));
                        hlUser.Visible = false;
                    }

                    if (this.CustomerService.AllowCustomersToUploadAvatars)
                    {
                        var customerAvatar = customer.Avatar;
                        int avatarSize     = this.SettingManager.GetSettingValueInteger("Media.Customer.AvatarSize", 85);
                        if (customerAvatar != null)
                        {
                            string pictureUrl = this.PictureService.GetPictureUrl(customerAvatar, avatarSize, false);
                            this.imgAvatar.ImageUrl = pictureUrl;
                        }
                        else
                        {
                            if (this.CustomerService.DefaultAvatarEnabled)
                            {
                                string pictureUrl = this.PictureService.GetDefaultPictureUrl(PictureTypeEnum.Avatar, avatarSize);
                                this.imgAvatar.ImageUrl = pictureUrl;
                            }
                            else
                            {
                                imgAvatar.Visible = false;
                            }
                        }
                    }
                    else
                    {
                        imgAvatar.Visible = false;
                    }

                    if (customer.IsForumModerator)
                    {
                        lblStatus.Text = GetLocaleResourceString("Forum.Moderator");
                    }
                    else
                    {
                        phStatus.Visible = false;
                    }

                    if (this.ForumService.ShowCustomersPostCount && !customer.IsGuest)
                    {
                        lblTotalPosts.Text = customer.TotalForumPosts.ToString();
                    }
                    else
                    {
                        phTotalPosts.Visible = false;
                    }

                    if (this.CustomerService.ShowCustomersJoinDate && !customer.IsGuest)
                    {
                        lblJoined.Text = DateTimeHelper.ConvertToUserTime(customer.RegistrationDate, DateTimeKind.Utc).ToString("d");
                    }
                    else
                    {
                        phJoined.Visible = false;
                    }

                    if (this.CustomerService.ShowCustomersLocation && !customer.IsGuest)
                    {
                        var country = this.CountryService.GetCountryById(customer.CountryId);
                        if (country != null)
                        {
                            lblLocation.Text = Server.HtmlEncode(country.Name);
                        }
                        else
                        {
                            phLocation.Visible = false;
                        }
                    }
                    else
                    {
                        phLocation.Visible = false;
                    }

                    if (this.ForumService.AllowPrivateMessages && !customer.IsGuest)
                    {
                        btnSendPM.CustomerId = customer.CustomerId;
                        phPM.Visible         = true;
                    }
                    else
                    {
                        phPM.Visible = false;
                    }

                    if (this.ForumService.SignaturesEnabled && !String.IsNullOrEmpty(customer.Signature))
                    {
                        lblSignature.Text = customer.Signature.FormatForumSignatureText();
                    }
                    else
                    {
                        pnlSignature.Visible = false;
                    }
                }
                else
                {
                    //error, cannot be
                }
            }
        }