public void BindData()
        {
            if (forumPost != null)
            {
                //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");
                }

                lblLastPostDate.Text = dateStr;

                //topic
                var forumTopic = forumPost.Topic;
                if (forumTopic != null)
                {
                    hlTopic.Text        = Server.HtmlEncode(forumTopic.StripTopicSubject());
                    hlTopic.ToolTip     = Server.HtmlEncode(forumTopic.Subject);
                    hlTopic.NavigateUrl = SEOHelper.GetForumTopicUrl(forumTopic);
                }

                //customer
                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;
                    }
                }

                pnlPostInfo.Visible = true;
                pnlNoPost.Visible   = false;
            }
            else
            {
                pnlPostInfo.Visible = false;
                pnlNoPost.Visible   = true;
            }
        }
Esempio n. 2
0
        protected string GetToInfo(int customerId)
        {
            string customerInfo = string.Empty;
            var    customer     = this.CustomerService.GetCustomerById(customerId);

            if (customer != null && !customer.IsGuest)
            {
                if (this.CustomerService.AllowViewingProfiles)
                {
                    customerInfo = string.Format("<a href=\"{0}\">{1}</a>", SEOHelper.GetUserProfileUrl(customer.CustomerId), Server.HtmlEncode(customer.FormatUserName()));
                }
                else
                {
                    customerInfo = Server.HtmlEncode(customer.FormatUserName());
                }
            }
            return(customerInfo);
        }
        protected void rptrTopics_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var forumTopic = e.Item.DataItem as ForumTopic;
                var customer   = forumTopic.User;

                var hlTopic = e.Item.FindControl("hlTopic") as HyperLink;
                if (hlTopic != null)
                {
                    hlTopic.NavigateUrl = SEOHelper.GetForumTopicUrl(forumTopic);
                    hlTopic.Text        = Server.HtmlEncode(forumTopic.Subject);
                }

                var hlTopicStarter = e.Item.FindControl("hlTopicStarter") as HyperLink;
                if (hlTopicStarter != null)
                {
                    if (customer != null && CustomerManager.AllowViewingProfiles && !customer.IsGuest)
                    {
                        hlTopicStarter.Text        = Server.HtmlEncode(CustomerManager.FormatUserName(customer, true));
                        hlTopicStarter.NavigateUrl = SEOHelper.GetUserProfileUrl(customer.CustomerId);
                    }
                    else
                    {
                        hlTopicStarter.Visible = false;
                    }
                }

                var lblTopicStarter = e.Item.FindControl("lblTopicStarter") as Label;
                if (lblTopicStarter != null)
                {
                    if (customer != null && (!CustomerManager.AllowViewingProfiles || customer.IsGuest))
                    {
                        lblTopicStarter.Text = Server.HtmlEncode(CustomerManager.FormatUserName(customer, true));
                    }
                    else
                    {
                        lblTopicStarter.Visible = false;
                    }
                }
            }
        }
Esempio n. 4
0
        public void BindData()
        {
            if (forumPost != null)
            {
                lblLastPostDate.Text = DateTimeHelper.ConvertToUserTime(forumPost.CreatedOn, DateTimeKind.Utc).ToString("f");
                var forumTopic = forumPost.Topic;
                if (forumTopic != null)
                {
                    hlTopic.Text        = Server.HtmlEncode(ForumManager.StripTopicSubject(forumTopic.Subject));
                    hlTopic.ToolTip     = Server.HtmlEncode(forumTopic.Subject);
                    hlTopic.NavigateUrl = SEOHelper.GetForumTopicUrl(forumTopic);
                }
                var customer = forumPost.User;
                if (customer != null)
                {
                    if (CustomerManager.AllowViewingProfiles && !customer.IsGuest)
                    {
                        hlUser.Text        = Server.HtmlEncode(CustomerManager.FormatUserName(customer, true));
                        hlUser.NavigateUrl = SEOHelper.GetUserProfileUrl(customer.CustomerId);
                        lblUser.Visible    = false;
                    }
                    else
                    {
                        lblUser.Text   = Server.HtmlEncode(CustomerManager.FormatUserName(customer, true));
                        hlUser.Visible = false;
                    }
                }

                pnlPostInfo.Visible = true;
                pnlNoPost.Visible   = false;
            }
            else
            {
                pnlPostInfo.Visible = false;
                pnlNoPost.Visible   = true;
            }
        }
        public void BindData()
        {
            if (blogComment != null)
            {
                lblCreatedOn.Text     = DateTimeHelper.ConvertToUserTime(blogComment.CreatedOn, DateTimeKind.Utc).ToString("g");
                lblComment.Text       = blogComment.FormatCommentText();
                lblBlogCommentId.Text = blogComment.BlogCommentId.ToString();

                var customer = blogComment.Customer;
                if (customer != null)
                {
                    if (this.CustomerService.AllowViewingProfiles)
                    {
                        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;
                    }
                }
                else
                {
                    lblUser.Text   = GetLocaleResourceString("Customer.NotRegistered");
                    hlUser.Visible = false;
                    if (this.CustomerService.AllowCustomersToUploadAvatars && this.CustomerService.DefaultAvatarEnabled)
                    {
                        int    avatarSize = this.SettingManager.GetSettingValueInteger("Media.Customer.AvatarSize", 85);
                        string pictureUrl = this.PictureService.GetDefaultPictureUrl(PictureTypeEnum.Avatar, avatarSize);
                        this.imgAvatar.ImageUrl = pictureUrl;
                    }
                    else
                    {
                        imgAvatar.Visible = false;
                    }
                }
            }
        }
Esempio n. 6
0
        protected void rptrSearchResults_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var forumTopic = e.Item.DataItem as ForumTopic;
                var customer   = forumTopic.User;

                var pnlTopicImage = e.Item.FindControl("pnlTopicImage") as Panel;
                if (pnlTopicImage != null)
                {
                    switch (forumTopic.TopicType)
                    {
                    case ForumTopicTypeEnum.Normal:
                        pnlTopicImage.CssClass = "post";
                        break;

                    case ForumTopicTypeEnum.Sticky:
                        pnlTopicImage.CssClass = "poststicky";
                        break;

                    case ForumTopicTypeEnum.Announcement:
                        pnlTopicImage.CssClass = "postannoucement";
                        break;

                    default:
                        pnlTopicImage.CssClass = "post";
                        break;
                    }
                }

                var lblTopicType = e.Item.FindControl("lblTopicType") as Label;
                if (lblTopicType != null)
                {
                    switch (forumTopic.TopicType)
                    {
                    case ForumTopicTypeEnum.Sticky:
                        lblTopicType.Text = string.Format("[{0}]", GetLocaleResourceString("Forum.Sticky"));
                        break;

                    case ForumTopicTypeEnum.Announcement:
                        lblTopicType.Text = string.Format("[{0}]", GetLocaleResourceString("Forum.Announcement"));
                        break;

                    default:
                        lblTopicType.Visible = false;
                        break;
                    }
                }

                var hlTopic = e.Item.FindControl("hlTopic") as HyperLink;
                if (hlTopic != null)
                {
                    hlTopic.NavigateUrl = SEOHelper.GetForumTopicUrl(forumTopic.ForumTopicId);
                    hlTopic.Text        = Server.HtmlEncode(forumTopic.Subject);
                }

                var hlTopicStarter = e.Item.FindControl("hlTopicStarter") as HyperLink;
                if (hlTopicStarter != null)
                {
                    if (customer != null && CustomerManager.AllowViewingProfiles && !customer.IsGuest)
                    {
                        hlTopicStarter.Text        = Server.HtmlEncode(CustomerManager.FormatUserName(customer));
                        hlTopicStarter.NavigateUrl = SEOHelper.GetUserProfileUrl(customer.CustomerId);
                    }
                    else
                    {
                        hlTopicStarter.Visible = false;
                    }
                }

                var lblTopicStarter = e.Item.FindControl("lblTopicStarter") as Label;
                if (lblTopicStarter != null)
                {
                    if (customer != null && (!CustomerManager.AllowViewingProfiles || customer.IsGuest))
                    {
                        lblTopicStarter.Text = Server.HtmlEncode(CustomerManager.FormatUserName(customer));
                    }
                    else
                    {
                        lblTopicStarter.Visible = false;
                    }
                }
            }
        }
Esempio n. 7
0
        public void BindData()
        {
            if (forumPost != null)
            {
                lAnchor.Text = string.Format("<a name=\"{0}\"></a>", forumPost.ForumPostId);

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

                lblDate.Text        = DateTimeHelper.ConvertToUserTime(forumPost.CreatedOn).ToString("f");
                lText.Text          = ForumManager.FormatPostText(forumPost.Text);
                lblForumPostId.Text = forumPost.ForumPostId.ToString();

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

                    if (CustomerManager.AllowCustomersToUploadAvatars)
                    {
                        var customerAvatar = customer.Avatar;
                        int avatarSize     = SettingManager.GetSettingValueInteger("Media.Customer.AvatarSize", 85);
                        if (customerAvatar != null)
                        {
                            string pictureUrl = PictureManager.GetPictureUrl(customerAvatar, avatarSize, false);
                            this.imgAvatar.ImageUrl = pictureUrl;
                        }
                        else
                        {
                            if (CustomerManager.DefaultAvatarEnabled)
                            {
                                string pictureUrl = PictureManager.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 (ForumManager.ShowCustomersPostCount && !customer.IsGuest)
                    {
                        lblTotalPosts.Text = customer.TotalForumPosts.ToString();
                    }
                    else
                    {
                        phTotalPosts.Visible = false;
                    }

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

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

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

                    if (ForumManager.SignaturesEnabled && !String.IsNullOrEmpty(customer.Signature))
                    {
                        lblSignature.Text = ForumManager.FormatSignatureText(customer.Signature);
                    }
                    else
                    {
                        pnlSignature.Visible = false;
                    }
                }
                else
                {
                    //error, cannot be
                }
            }
        }
        protected void rptrTopics_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var forumTopic = e.Item.DataItem as ForumTopic;
                var customer   = forumTopic.User;

                var pnlTopicImage = e.Item.FindControl("pnlTopicImage") as Panel;
                if (pnlTopicImage != null)
                {
                    switch (forumTopic.TopicType)
                    {
                    case ForumTopicTypeEnum.Normal:
                        pnlTopicImage.CssClass = "post";
                        break;

                    case ForumTopicTypeEnum.Sticky:
                        pnlTopicImage.CssClass = "poststicky";
                        break;

                    case ForumTopicTypeEnum.Announcement:
                        pnlTopicImage.CssClass = "postannoucement";
                        break;

                    default:
                        pnlTopicImage.CssClass = "post";
                        break;
                    }
                }

                var lblTopicType = e.Item.FindControl("lblTopicType") as Label;
                if (lblTopicType != null)
                {
                    switch (forumTopic.TopicType)
                    {
                    case ForumTopicTypeEnum.Sticky:
                        lblTopicType.Text = string.Format("[{0}]", GetLocaleResourceString("Forum.Sticky"));
                        break;

                    case ForumTopicTypeEnum.Announcement:
                        lblTopicType.Text = string.Format("[{0}]", GetLocaleResourceString("Forum.Announcement"));
                        break;

                    default:
                        lblTopicType.Visible = false;
                        break;
                    }
                }

                var hlTopic = e.Item.FindControl("hlTopic") as HyperLink;
                if (hlTopic != null)
                {
                    hlTopic.NavigateUrl = SEOHelper.GetForumTopicUrl(forumTopic);
                    hlTopic.Text        = Server.HtmlEncode(forumTopic.Subject);
                }

                var lPager = e.Item.FindControl("lPager") as Literal;
                if (lPager != null)
                {
                    string postPager = CreatePostPager(forumTopic);
                    if (!String.IsNullOrEmpty(postPager))
                    {
                        string postPagerFinal = string.Format("<br /><span class=\"topicspager\">{0}</span>", string.Format(GetLocaleResourceString("Forum.Topics.GotoPostPager"), postPager));
                        lPager.Text = postPagerFinal;
                    }
                    else
                    {
                        lPager.Visible = false;
                    }
                }

                var hlTopicStarter = e.Item.FindControl("hlTopicStarter") as HyperLink;
                if (hlTopicStarter != null)
                {
                    if (customer != null && this.CustomerService.AllowViewingProfiles && !customer.IsGuest)
                    {
                        hlTopicStarter.Text        = Server.HtmlEncode(customer.FormatUserName(true));
                        hlTopicStarter.NavigateUrl = SEOHelper.GetUserProfileUrl(customer.CustomerId);
                    }
                    else
                    {
                        hlTopicStarter.Visible = false;
                    }
                }

                var lblTopicStarter = e.Item.FindControl("lblTopicStarter") as Label;
                if (lblTopicStarter != null)
                {
                    if (customer != null && (!this.CustomerService.AllowViewingProfiles || customer.IsGuest))
                    {
                        lblTopicStarter.Text = Server.HtmlEncode(customer.FormatUserName(true));
                    }
                    else
                    {
                        lblTopicStarter.Visible = false;
                    }
                }
            }
        }