コード例 #1
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            doComment = this.DataObject as DataObjectComment;
            Control          ctrl       = this.LoadControl("/UserControls/Templates/SmallOutputUser2.ascx");
            SmallOutputUser2 userOutput = ctrl as SmallOutputUser2;

            SetUserOutput(userOutput, doComment.UserID.Value, doComment.Nickname);

            phUserOutput.Controls.Add(userOutput);

            if (doComment.CommentStatus == 0)
            {
                CommentPreview commentPreview = (CommentPreview)LoadControl("/UserControls/Dashboard/CommentPreview.ascx");
                commentPreview.Comment   = doComment;
                commentPreview.StripHtml = false;
                commentPreview.Type      = "Comment";
                phCommentOuput.Controls.Add(commentPreview);
                LbtnDel.Visible = false;
                if (UserDataContext.GetUserDataContext().IsAdmin&& doComment.CommentStatus != 1)
                {
                    LbtnDel.Visible         = true;
                    LbtnDel.ID              = "del_" + doComment.ObjectID.ToString().Replace("-", "");
                    LbtnDel.CommandArgument = doComment.ObjectID.ToString();
                }
            }
            else
            {
                phCommentOuput.Controls.Add(new LiteralControl(languageShared.GetString("MessageCommentDeletedByAdmin")));
                LbtnDel.Visible = false;
            }
        }
コード例 #2
0
 private void SetUserOutput(SmallOutputUser2 userOutput, Guid userId, string userName)
 {
     if (userId != Constants.ANONYMOUS_USERID.ToGuid())
     {
         userOutput.DataObjectUser = DataObject.Load <DataObjectUser>(userId);
         userOutput.LinkActive     = true;
     }
     else
     {
         userOutput.UserName       = userName;
         userOutput.UserDetailURL  = string.Empty;
         userOutput.UserPictureURL = _4screen.CSB.Common.SiteConfig.MediaDomainName + Helper.GetObjectType("User").DefaultImageURL;
         userOutput.PrimaryColor   = Helper.GetDefaultUserPrimaryColor();
         userOutput.SecondaryColor = Helper.GetDefaultUserSecondaryColor();
     }
 }
コード例 #3
0
        protected void OnForumTopicItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            DataObjectForumTopicItem item = (DataObjectForumTopicItem)e.Item.DataItem;
            Literal postDate = (Literal)e.Item.FindControl("LitPosterInfo");

            postDate.Text = string.Format("{0} {1}", item.Inserted.ToShortDateString(), item.Inserted.ToShortTimeString());

            Control          posterControl = e.Item.FindControl("PhPoster");
            SmallOutputUser2 poster        = (SmallOutputUser2)this.LoadControl("~/UserControls/Templates/SmallOutputUser2.ascx");

            if (item.UserID != Constants.ANONYMOUS_USERID.ToGuid())
            {
                poster.DataObjectUser = DataObject.Load <DataObjectUser>(item.UserID);
                poster.LinkActive     = true;
                posterControl.Controls.Add(poster);
                bool isPosterCommunityMember;
                bool isPosterCommunityOwner = Community.GetIsUserOwner(item.UserID.Value, forumTopic.CommunityID.Value, out isPosterCommunityMember);
                if (isPosterCommunityOwner)
                {
                    posterControl.Controls.Add(new LiteralControl("<div class=\"forumModerator\">" + language.GetString("LabelModerator") + "</div>"));
                }
            }
            else
            {
                poster.UserName       = item.Nickname;
                poster.UserDetailURL  = string.Empty;
                poster.UserPictureURL = _4screen.CSB.Common.SiteConfig.MediaDomainName + Helper.GetObjectType("User").DefaultImageURL;
                poster.PrimaryColor   = Helper.GetDefaultUserPrimaryColor();
                poster.SecondaryColor = Helper.GetDefaultUserSecondaryColor();
                posterControl.Controls.Add(poster);
            }

            Control placeHolderfunctions = (PlaceHolder)e.Item.FindControl("PhFunc");

            if (((forumTopic.TopicItemCreationUsers == CommunityUsersType.Members && isCommunityMember) ||
                 (forumTopic.TopicItemCreationUsers == CommunityUsersType.Authenticated && Request.IsAuthenticated) ||
                 isRoleAllowed) &&
                item.ItemStatus != CommentStatus.Deleted &&
                item.ShowState == ObjectShowState.Published)
            {
                HyperLink replyButton = new HyperLink();
                replyButton.CssClass    = "inputButton";
                replyButton.Text        = languageShared.GetString("CommandComment");
                replyButton.NavigateUrl = string.Format("javascript:radWinOpen('/Pages/Popups/ForumTopicItemComment.aspx?ObjID={0}&ObjIDRef={1}&ObjType={2}', '{3}', 470, 370, true)", forumTopic.ObjectID.Value, item.ObjectID.Value, Helper.GetObjectTypeNumericID("ForumTopic"), languageShared.GetString("CommandComment"));
                placeHolderfunctions.Controls.Add(replyButton);
            }
            if (isCommunityOwner && item.ShowState == ObjectShowState.Draft)
            {
                LinkButton publishButton = new LinkButton();
                publishButton.CssClass        = "inputButton";
                publishButton.Text            = language.GetString("CommandForumReleasing");
                publishButton.CommandArgument = item.ObjectID.ToString();
                publishButton.Click          += new EventHandler(OnPublishItemClick);
                placeHolderfunctions.Controls.Add(publishButton);
            }
            if (isCommunityOwner && item.ItemStatus == CommentStatus.None)
            {
                LinkButton removeButton = new LinkButton();
                removeButton.CssClass        = "inputButton";
                removeButton.Text            = language.GetString("CommandForumRemove");
                removeButton.CommandArgument = item.ObjectID.ToString();
                removeButton.Click          += new EventHandler(OnRemoveItemClick);
                placeHolderfunctions.Controls.Add(removeButton);
            }

            if (item.ShowState == ObjectShowState.Draft)
            {
                ((HtmlTableRow)e.Item.FindControl("Tr1")).Attributes.Add("class", "forumDraft");
                ((HtmlTableRow)e.Item.FindControl("Tr2")).Attributes.Add("class", "forumDraft");
            }

            Control topicItemContent = e.Item.FindControl("PhContent");

            if (item.ReferencedItemId.HasValue)
            {
                DataObjectForumTopicItem referencedItem = DataObject.Load <DataObjectForumTopicItem>(item.ReferencedItemId.Value, ObjectShowState.Published, false);
                if (referencedItem != null && referencedItem.State != ObjectState.Added)
                {
                    topicItemContent.Controls.Add(new LiteralControl(string.Format("<div class=\"forumCitation\"><div class=\"forumInfo\">{0}{1}</div><div>{2}</div></div>",
                                                                                   referencedItem.UserID != Constants.ANONYMOUS_USERID.ToGuid() ? string.Format("<a href='{0}'>{1}</a>", Helper.GetDetailLink("User", referencedItem.Nickname), referencedItem.Nickname) : referencedItem.Nickname,
                                                                                   string.Format(language.GetString("MessageForumTopicHasWrite"), referencedItem.Inserted.ToShortDateString() + " " + referencedItem.Inserted.ToShortTimeString()),
                                                                                   referencedItem.ItemStatus == CommentStatus.Deleted ? language.GetString("MessageForumRemove") : referencedItem.Description)));
                }
            }

            if (item.ItemStatus == CommentStatus.Deleted)
            {
                topicItemContent.Controls.Add(new LiteralControl(language.GetString("MessageForumRemove")));
            }
            else if (item.ShowState == ObjectShowState.Published || isCommunityOwner || item.UserID == udc.UserID)
            {
                topicItemContent.Controls.Add(new LiteralControl(item.Description));
            }
            else
            {
                e.Item.Visible = false;
            }
        }
コード例 #4
0
        protected void OnForumItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (!showTopicColumn)
            {
                e.Item.FindControl("TdTopicC").Visible = false;
            }
            if (!showStarterColumn)
            {
                e.Item.FindControl("TdStarterC").Visible = false;
            }
            if (!showInfoColumn)
            {
                e.Item.FindControl("TdInfoC").Visible = false;
            }
            if (!showLastPosterColumn)
            {
                e.Item.FindControl("TdLastPosterC").Visible = false;
            }

            DataObjectForumTopic forumTopic = (DataObjectForumTopic)e.Item.DataItem;

            HyperLink forumTopicLink = (HyperLink)e.Item.FindControl("LnkTopicLink");

            forumTopicLink.NavigateUrl = Helper.GetDetailLink("ForumTopic", forumTopic.ObjectID.Value.ToString());
            Literal forumTopicTitle = (Literal)e.Item.FindControl("LitTopicTitle");

            forumTopicTitle.Text = forumTopic.Title;
            Literal forumTopicDesc = (Literal)e.Item.FindControl("LitTopicDesc");

            forumTopicDesc.Text = forumTopic.Description.CropString(200);
            if (forumTopic.LastTopicItemID.HasValue)
            {
                ((HyperLink)e.Item.FindControl("LnkOpenLatestPost")).NavigateUrl = Helper.GetDetailLink(forumTopic.ObjectType, forumTopic.ObjectID.ToString(), false) + "&COID=" + forumTopic.LastTopicItemID;
                ((HyperLink)e.Item.FindControl("LnkOpenLatestPost")).Attributes.Add("style", "margin-top: 5px;");
                e.Item.FindControl("LnkOpenLatestPost").Visible = true;
                e.Item.FindControl("LnkOpenLatestPost").ID      = null;
            }

            Control          threadStarterControl = e.Item.FindControl("PhStarter");
            SmallOutputUser2 threadStarter        = (SmallOutputUser2)this.LoadControl("~/UserControls/Templates/SmallOutputUser2.ascx");
            DataObjectUser   threadStarterUser    = DataObject.Load <DataObjectUser>(forumTopic.UserID, ObjectShowState.Published, false);

            if (forumTopic.UserID != Constants.ANONYMOUS_USERID.ToGuid())
            {
                threadStarter.DataObjectUser = threadStarterUser;
                threadStarter.LinkActive     = true;
            }
            else
            {
                threadStarter.UserName       = forumTopic.Nickname;
                threadStarter.UserDetailURL  = string.Empty;
                threadStarter.UserPictureURL = _4screen.CSB.Common.SiteConfig.MediaDomainName + Helper.GetObjectType("User").DefaultImageURL;
                threadStarter.PrimaryColor   = Helper.GetDefaultUserPrimaryColor();
                threadStarter.SecondaryColor = Helper.GetDefaultUserSecondaryColor();
            }
            threadStarterControl.Controls.Add(threadStarter);
            Literal threadStarterInfo = (Literal)e.Item.FindControl("LitStarterInfo");

            threadStarterInfo.Text = forumTopic.Inserted.ToShortDateString() + " " + forumTopic.Inserted.ToShortTimeString();

            Literal numberPosts = (Literal)e.Item.FindControl("LitNumberPosts");

            numberPosts.Text = forumTopic.TopicItemCount.ToString("N0");
            Literal numberViews = (Literal)e.Item.FindControl("LitNumberViews");

            numberViews.Text = forumTopic.ViewCount.ToString("N0");
            PlaceHolder rating        = (PlaceHolder)e.Item.FindControl("PhRating");
            Control     ratingControl = LoadControl("/UserControls/Templates/ObjectVotingTelerik.ascx");

            ((IObjectVoting)ratingControl).DataObject = forumTopic;
            rating.Controls.Add(ratingControl);

            Control lastPosterControl = e.Item.FindControl("PhLastPoster");
            Literal lastPosterInfo    = (Literal)e.Item.FindControl("ListLastPosterInfo");

            if (forumTopic.TopicItemCount > 0)
            {
                SmallOutputUser2 lastPoster     = (SmallOutputUser2)this.LoadControl("~/UserControls/Templates/SmallOutputUser2.ascx");
                DataObjectUser   lastPosterUser = DataObject.Load <DataObjectUser>(forumTopic.LastTopicItemUserID, ObjectShowState.Published, false);
                if (forumTopic.LastTopicItemUserID != Constants.ANONYMOUS_USERID.ToGuid())
                {
                    lastPoster.DataObjectUser = lastPosterUser;
                    lastPoster.LinkActive     = true;
                }
                else
                {
                    lastPoster.UserName       = forumTopic.LastTopicItemNickname;
                    lastPoster.UserDetailURL  = string.Empty;
                    lastPoster.UserPictureURL = _4screen.CSB.Common.SiteConfig.MediaDomainName + Helper.GetObjectType("User").DefaultImageURL;
                    lastPoster.PrimaryColor   = Helper.GetDefaultUserPrimaryColor();
                    lastPoster.SecondaryColor = Helper.GetDefaultUserSecondaryColor();
                }
                lastPosterControl.Controls.Add(lastPoster);

                lastPosterInfo.Text = forumTopic.LastTopicItemDate.Value.ToShortDateString() + " " + forumTopic.LastTopicItemDate.Value.ToShortTimeString();
            }
            else
            {
                lastPosterControl.Controls.Add(new LiteralControl("&nbsp;"));
                lastPosterInfo.Text = "&nbsp;";
            }
        }