Ejemplo n.º 1
0
        protected void LatestPosts_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            // populate the controls here...
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DataRowView currentRow = ( DataRowView )e.Item.DataItem;
                // make message url...
                string messageUrl = YAF.Classes.Utils.YafBuildLink.GetLinkNotEscaped(YAF.Classes.Utils.ForumPages.posts, "m={0}#post{0}", currentRow ["LastMessageID"]);
                // get the controls
                HyperLink  textMessageLink     = (HyperLink)e.Item.FindControl("TextMessageLink");
                HyperLink  imageMessageLink    = (HyperLink)e.Item.FindControl("ImageMessageLink");
                ThemeImage lastPostedImage     = (ThemeImage)e.Item.FindControl("LastPostedImage");
                UserLink   lastUserLink        = ( UserLink )e.Item.FindControl("LastUserLink");
                Label      lastPostedDateLabel = ( Label )e.Item.FindControl("LastPostedDateLabel");
                HyperLink  forumLink           = ( HyperLink )e.Item.FindControl("ForumLink");

                // populate them...
                textMessageLink.Text         = YAF.Classes.Utils.General.BadWordReplace(currentRow["Topic"].ToString());
                textMessageLink.NavigateUrl  = messageUrl;
                imageMessageLink.NavigateUrl = messageUrl;
                // Just in case...
                if (currentRow ["LastUserID"] != DBNull.Value)
                {
                    lastUserLink.UserID   = Convert.ToInt32(currentRow ["LastUserID"]);
                    lastUserLink.UserName = currentRow ["LastUserName"].ToString();
                }
                if (currentRow ["LastPosted"] != DBNull.Value)
                {
                    lastPostedDateLabel.Text = YafDateTime.FormatDateTimeTopic(currentRow ["LastPosted"]);
                    lastPostedImage.ThemeTag = (DateTime.Parse(currentRow ["LastPosted"].ToString()) > YAF.Classes.Utils.Mession.GetTopicRead(Convert.ToInt32(currentRow ["TopicID"]))) ? "ICON_NEWEST" : "ICON_LATEST";
                }
                forumLink.Text        = currentRow["Forum"].ToString();
                forumLink.NavigateUrl = YAF.Classes.Utils.YafBuildLink.GetLinkNotEscaped(YAF.Classes.Utils.ForumPages.topics, "f={0}", currentRow ["ForumID"]);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles the PreRender event
        /// </summary>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            if (((DataRow[])this.DataSource).Length == 0)
            {
                this.ShowMods.Visible = false;

                return;
            }

            this.PageContext.PageElements.RegisterJsBlockStartup(
                "ForumModsPopoverJs",
                JavaScriptBlocks.ForumModsPopoverJs(
                    $"<i class=\"fa fa-user-secret fa-fw text-secondary\"></i>&nbsp;{this.GetText("DEFAULT", "MODERATORS")} ..."));

            var content = new StringBuilder();

            content.Append(@"<ol class=""list-unstyled"">");

            this.DataSource.Cast <DataRow>().ForEach(
                row =>
            {
                content.Append("<li>");

                if (row["IsGroup"].ToType <int>() == 0)
                {
                    // Render Moderator User Link
                    var userLink = new UserLink
                    {
                        Style       = row["Style"].ToString(),
                        UserID      = row["ModeratorID"].ToType <int>(),
                        ReplaceName = row[this.Get <BoardSettings>().EnableDisplayName
                                                                     ? "ModeratorDisplayName"
                                                                     : "ModeratorName"].ToString()
                    };

                    content.Append(userLink.RenderToString());
                }
                else
                {
                    // render mod group
                    content.Append(
                        row[this.Get <BoardSettings>().EnableDisplayName
                                    ? "ModeratorDisplayName"
                                    : "ModeratorName"]);
                }

                content.Append(@"</li>");
            });

            content.Append("</ol>");

            this.ShowMods.DataContent = content.ToString().ToJsString();
            this.ShowMods.Text        = $"{this.GetText("SHOW")} {this.GetText("DEFAULT", "MODERATORS")}";
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Handles the PreRender event
        /// </summary>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            this.PageContext.PageElements.RegisterJsBlockStartup(
                "ForumModsPopoverJs",
                JavaScriptBlocks.ForumModsPopoverJs(
                    $"<i class=\"fa fa-user-secret fa-fw text-secondary\"></i>&nbsp;{this.GetText("DEFAULT", "MODERATORS")} ..."));

            var content = new StringBuilder();

            content.Append(@"<ol class=""list-unstyled"">");

            this.DataSource.ForEach(
                row =>
            {
                content.Append("<li>");

                if (row.IsGroup)
                {
                    // render mod group
                    content.Append(
                        this.PageContext.BoardSettings.EnableDisplayName
                                    ? row.DisplayName
                                    : row.Name);
                }
                else
                {
                    // Render Moderator User Link
                    var userLink = new UserLink
                    {
                        Style       = row.Style,
                        UserID      = row.ModeratorID,
                        ReplaceName = this.PageContext.BoardSettings.EnableDisplayName
                                                                     ? row.DisplayName
                                                                     : row.Name
                    };

                    content.Append(userLink.RenderToString());
                }

                content.Append(@"</li>");
            });

            content.Append("</ol>");

            this.ShowMods.DataContent = content.ToString().ToJsString();
            this.ShowMods.Text        = $"{this.GetText("SHOW")} {this.GetText("DEFAULT", "MODERATORS")}";
        }
Ejemplo n.º 4
0
        /// <summary>
    /// The render.
    /// </summary>
    /// <param name="writer">
    /// The writer.
    /// </param>
    protected override void Render(HtmlTextWriter writer)
    {
      var userName = Parameters["inner"];

      if (userName.IsNotSet() || userName.Length > 50)
      {
        return;
      }

      var userId = this.Get<IUserDisplayName>().GetId(userName.Trim());

      if (userId.HasValue)
      {
        var stringBuilder = new StringBuilder();

          var userLink = new UserLink
              {
                  UserID = (int)userId,
                  CssClass = "UserLinkBBCode",
                  BlankTarget = true,
                  ID = "UserLinkBBCodeFor{0}".FormatWith(userId)
              };

          var showOnlineStatusImage = this.Get<YafBoardSettings>().ShowUserOnlineStatus &&
                                    !UserMembershipHelper.IsGuestUser(userId);

          var onlineStatusImage = new OnlineStatusImage { ID = "OnlineStatusImage", Style = "vertical-align: bottom", UserID = (int)userId };

        stringBuilder.AppendLine("<!-- BEGIN userlink -->");
        stringBuilder.AppendLine(@"<span class=""userLinkContainer"">");
        stringBuilder.AppendLine(userLink.RenderToString());

        if (showOnlineStatusImage)
        {
          stringBuilder.AppendLine(onlineStatusImage.RenderToString()); 
        }

        stringBuilder.AppendLine("</span>");
        stringBuilder.AppendLine("<!-- END userlink -->");

        writer.Write(stringBuilder.ToString());
      }
      else
      {
        writer.Write(this.HtmlEncode(userName));
      }
    }
Ejemplo n.º 5
0
        /// <summary>
        /// The activity stream_ on item data bound.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void ActivityStream_OnItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }

            var activity = (Tuple <Activity, User, Topic>)e.Item.DataItem;

            var messageHolder   = e.Item.FindControlAs <PlaceHolder>("Message");
            var displayDateTime = e.Item.FindControlAs <DisplayDateTime>("DisplayDateTime");
            var markRead        = e.Item.FindControlAs <ThemeButton>("MarkRead");
            var iconLabel       = e.Item.FindControlAs <Label>("Icon");

            var message = string.Empty;
            var icon    = string.Empty;

            var topicLink = new ThemeButton
            {
                NavigateUrl = BuildLink.GetTopicLink(activity.Item1.MessageID.Value, activity.Item3.TopicName),
                Type        = ButtonStyle.None,
                Text        = activity.Item3.TopicName,
                Icon        = "comment"
            };

            if (activity.Item1.ActivityFlags.ReceivedThanks)
            {
                var userLink = new UserLink
                {
                    UserID      = activity.Item1.FromUserID.Value,
                    Suspended   = activity.Item2.Suspended,
                    Style       = activity.Item2.UserStyle,
                    ReplaceName = this.PageContext.BoardSettings.EnableDisplayName
                        ? activity.Item2.DisplayName
                        : activity.Item2.Name
                };

                icon    = "heart";
                message = this.GetTextFormatted(
                    "RECEIVED_THANKS_MSG",
                    userLink.RenderToString(),
                    topicLink.RenderToString());
            }

            if (activity.Item1.ActivityFlags.WasMentioned)
            {
                var userLink = new UserLink
                {
                    UserID      = activity.Item1.FromUserID.Value,
                    Suspended   = activity.Item2.Suspended,
                    Style       = activity.Item2.UserStyle,
                    ReplaceName = this.PageContext.BoardSettings.EnableDisplayName
                        ? activity.Item2.DisplayName
                        : activity.Item2.Name
                };

                icon    = "at";
                message = this.GetTextFormatted(
                    "WAS_MENTIONED_MSG",
                    userLink.RenderToString(),
                    topicLink.RenderToString());
            }

            if (activity.Item1.ActivityFlags.WasQuoted)
            {
                var userLink = new UserLink
                {
                    UserID      = activity.Item1.FromUserID.Value,
                    Suspended   = activity.Item2.Suspended,
                    Style       = activity.Item2.UserStyle,
                    ReplaceName = this.PageContext.BoardSettings.EnableDisplayName
                        ? activity.Item2.DisplayName
                        : activity.Item2.Name
                };

                icon    = "quote-left";
                message = this.GetTextFormatted(
                    "WAS_QUOTED_MSG",
                    userLink.RenderToString(),
                    topicLink.RenderToString());
            }

            var notify = activity.Item1.Notification ? "text-success" : "text-secondary";

            iconLabel.Text = $@"<i class=""fas fa-circle fa-stack-2x {notify}""></i>
               <i class=""fas fa-{icon} fa-stack-1x fa-inverse""></i>";

            displayDateTime.DateTime = activity.Item1.Created;

            messageHolder.Controls.Add(new Literal {
                Text = message
            });

            if (!activity.Item1.Notification)
            {
                return;
            }

            markRead.CommandArgument = activity.Item1.MessageID.Value.ToString();
            markRead.Visible         = true;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Render The User related Links
        /// </summary>
        private void RenderUserContainer()
        {
            if (this.PageContext.IsGuest)
            {
                return;
            }

            this.UserContainer.Visible = true;

            // My Profile
            this.MyProfile.ToolTip     = this.GetText("TOOLBAR", "MYPROFILE_TITLE");
            this.MyProfile.NavigateUrl = YafBuildLink.GetLink(ForumPages.cp_profile);
            this.MyProfile.Text        = this.GetText("TOOLBAR", "MYPROFILE");

            // My Inbox
            if (this.Get <YafBoardSettings>().AllowPrivateMessages)
            {
                RenderMenuItem(
                    this.MyInboxItem,
                    "menuMy myPm",
                    null,
                    this.GetText("TOOLBAR", "INBOX"),
                    this.GetText("TOOLBAR", "INBOX_TITLE"),
                    YafBuildLink.GetLink(ForumPages.cp_pm),
                    false,
                    this.PageContext.UnreadPrivate > 0,
                    this.PageContext.UnreadPrivate.ToString(),
                    this.GetText("TOOLBAR", "NEWPM").FormatWith(this.PageContext.UnreadPrivate));
            }

            // My Buddies
            if (this.Get <YafBoardSettings>().EnableBuddyList&& this.PageContext.UserHasBuddies)
            {
                RenderMenuItem(
                    this.MyBuddiesItem,
                    "menuMy myBuddies",
                    null,
                    this.GetText("TOOLBAR", "BUDDIES"),
                    this.GetText("TOOLBAR", "BUDDIES_TITLE"),
                    YafBuildLink.GetLink(ForumPages.cp_editbuddies),
                    false,
                    this.PageContext.PendingBuddies > 0,
                    this.PageContext.PendingBuddies.ToString(),
                    this.GetText("TOOLBAR", "BUDDYREQUEST").FormatWith(this.PageContext.PendingBuddies));
            }

            // My Albums
            if (this.Get <YafBoardSettings>().EnableAlbum&& (this.PageContext.UsrAlbums > 0 || this.PageContext.NumAlbums > 0))
            {
                RenderMenuItem(
                    this.MyAlbumsItem,
                    "menuMy myAlbums",
                    null,
                    this.GetText("TOOLBAR", "MYALBUMS"),
                    this.GetText("TOOLBAR", "MYALBUMS_TITLE"),
                    YafBuildLink.GetLinkNotEscaped(ForumPages.albums, "u={0}", this.PageContext.PageUserID),
                    false,
                    false,
                    null,
                    null);
            }

            var unread = this.PageContext.UnreadPrivate > 0 || this.PageContext.PendingBuddies > 0 /* ||
                                                                                                    * this.PageContext.UnreadTopics > 0*/;

            // My Topics
            RenderMenuItem(
                this.MyTopicItem,
                "menuMy myTopics",
                null,
                this.GetText("TOOLBAR", "MYTOPICS"),
                this.GetText("TOOLBAR", "MYTOPICS"),
                YafBuildLink.GetLink(ForumPages.mytopics),
                false,
                false,         //this.PageContext.UnreadTopics > 0,
                string.Empty,  //this.PageContext.UnreadTopics.ToString(),
                string.Empty); //this.GetText("TOOLBAR", "UNREADTOPICS").FormatWith(this.PageContext.UnreadTopics));

            // Logout
            if (!Config.IsAnyPortal && Config.AllowLoginAndLogoff)
            {
                this.LogutItem.Visible    = true;
                this.LogOutButton.Text    = this.GetText("TOOLBAR", "LOGOUT");
                this.LogOutButton.ToolTip = this.GetText("TOOLBAR", "LOGOUT");
            }

            // Logged in as : username
            this.LoggedInUserPanel.Visible = true;

            if (unread)
            {
                this.LoggedInUserPanel.CssClass = "loggedInUser unread";
            }

            this.LoggedInUserPanel.Controls.Add(
                new Label {
                Text = this.GetText("TOOLBAR", "LOGGED_IN_AS").FormatWith("&nbsp;")
            });

            var userLink = new UserLink
            {
                ID              = "UserLoggedIn",
                UserID          = this.PageContext.PageUserID,
                CssClass        = "currentUser",
                EnableHoverCard = false
            };

            this.LoggedInUserPanel.Controls.Add(userLink);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// The attach.
 /// </summary>
 /// <param name="userLinkControl">
 /// The user link control.
 /// </param>
 public void Attach([NotNull] UserLink userLinkControl)
 {
     this.ButtonId = userLinkControl.ClientID;
 }
Ejemplo n.º 8
0
        /// <summary>
        /// The activity stream_ on item data bound.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void ActivityStream_OnItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }

            var activity = (Tuple <Activity, Topic>)e.Item.DataItem;

            var card            = e.Item.FindControlAs <Panel>("Card");
            var iconLabel       = e.Item.FindControlAs <Label>("Icon");
            var title           = e.Item.FindControlAs <Literal>("Title");
            var messageHolder   = e.Item.FindControlAs <PlaceHolder>("Message");
            var displayDateTime = e.Item.FindControlAs <DisplayDateTime>("DisplayDateTime");
            var markRead        = e.Item.FindControlAs <ThemeButton>("MarkRead");

            var message = string.Empty;
            var icon    = string.Empty;

            var topicLink = new ThemeButton
            {
                NavigateUrl  = this.Get <LinkBuilder>().GetTopicLink(activity.Item2.ID, activity.Item2.TopicName),
                Type         = ButtonStyle.None,
                Text         = activity.Item2.TopicName,
                Icon         = "comment",
                IconCssClass = "far"
            };

            if (activity.Item1.ActivityFlags.CreatedTopic)
            {
                topicLink.NavigateUrl = this.Get <LinkBuilder>().GetTopicLink(activity.Item1.TopicID.Value, activity.Item2.TopicName);
                title.Text            = this.GetText("ACCOUNT", "CREATED_TOPIC");
                icon    = "comment";
                message = this.GetTextFormatted("CREATED_TOPIC_MSG", topicLink.RenderToString());
            }

            if (activity.Item1.ActivityFlags.CreatedReply)
            {
                title.Text = this.GetText("ACCOUNT", "CREATED_REPLY");
                icon       = "comment";
                message    = this.GetTextFormatted("CREATED_REPLY_MSG", topicLink.RenderToString());
            }

            if (activity.Item1.ActivityFlags.GivenThanks)
            {
                var user = this.GetRepository <User>().GetById(activity.Item1.FromUserID.Value);

                var userLink = new UserLink
                {
                    UserID      = activity.Item1.FromUserID.Value,
                    Suspended   = user.Suspended,
                    Style       = user.UserStyle,
                    ReplaceName = user.DisplayOrUserName()
                };

                title.Text = this.GetText("ACCOUNT", "GIVEN_THANKS");
                icon       = "heart";
                message    = this.GetTextFormatted(
                    "GIVEN_THANKS_MSG",
                    userLink.RenderToString(),
                    topicLink.RenderToString());
            }

            var notify = activity.Item1.Notification ? "text-success" : "text-secondary";

            card.CssClass = activity.Item1.Notification ? "card shadow" : "card";

            iconLabel.Text = $@"<i class=""fas fa-circle fa-stack-2x {notify}""></i>
               <i class=""fas fa-{icon} fa-stack-1x fa-inverse""></i>";

            displayDateTime.DateTime = activity.Item1.Created;

            messageHolder.Controls.Add(new Literal {
                Text = message
            });

            if (!activity.Item1.Notification)
            {
                return;
            }

            markRead.CommandArgument = activity.Item1.MessageID.Value.ToString();
            markRead.Visible         = true;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// The activity stream_ on item data bound.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void ActivityStream_OnItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }

            var activity = (Activity)e.Item.DataItem;

            var iconLabel       = e.Item.FindControlAs <Label>("Icon");
            var title           = e.Item.FindControlAs <Literal>("Title");
            var messageHolder   = e.Item.FindControlAs <PlaceHolder>("Message");
            var displayDateTime = e.Item.FindControlAs <DisplayDateTime>("DisplayDateTime");

            var message = string.Empty;
            var icon    = string.Empty;

            var topicLink = new ThemeButton
            {
                NavigateUrl =
                    YafBuildLink.GetLink(
                        ForumPages.posts,
                        "m={0}#post{0}",
                        activity.MessageID.Value),
                Type = ButtonAction.OutlineSecondary,
                Text = this.GetRepository <Topic>().GetById(activity.TopicID.Value)
                       .TopicName,
                Icon = "comment"
            };

            if (activity.ActivityFlags.CreatedTopic)
            {
                topicLink.NavigateUrl = YafBuildLink.GetLink(ForumPages.posts, "t={0}", activity.TopicID.Value);

                title.Text = this.GetText("CP_PROFILE", "CREATED_TOPIC");
                icon       = "comment";
                message    = this.GetTextFormatted("CREATED_TOPIC_MSG", topicLink.RenderToString());
            }

            if (activity.ActivityFlags.CreatedReply)
            {
                title.Text = this.GetText("CP_PROFILE", "CREATED_REPLY");
                icon       = "comment";
                message    = this.GetTextFormatted("CREATED_REPLY_MSG", topicLink.RenderToString());
            }

            if (activity.ActivityFlags.GivenThanks)
            {
                var userLink = new UserLink {
                    UserID = activity.FromUserID.Value
                };

                title.Text = this.GetText("CP_PROFILE", "GIVEN_THANKS");
                icon       = "heart";
                message    = this.GetTextFormatted("GIVEN_THANKS_MSG", userLink.RenderToString(), topicLink.RenderToString());
            }

            if (activity.ActivityFlags.ReceivedThanks)
            {
                var userLink = new UserLink {
                    UserID = activity.FromUserID.Value
                };

                title.Text = this.GetText("CP_PROFILE", "RECEIVED_THANKS");
                icon       = "heart";
                message    = this.GetTextFormatted("RECEIVED_THANKS_MSG", userLink.RenderToString(), topicLink.RenderToString());
            }

            if (activity.ActivityFlags.WasMentioned)
            {
                var userLink = new UserLink {
                    UserID = activity.FromUserID.Value
                };

                title.Text = this.GetText("CP_PROFILE", "WAS_MENTIONED");
                icon       = "at";
                message    = this.GetTextFormatted("WAS_MENTIONED_MSG", userLink.RenderToString(), topicLink.RenderToString());
            }

            if (activity.ActivityFlags.WasQuoted)
            {
                var userLink = new UserLink {
                    UserID = activity.FromUserID.Value
                };

                title.Text = this.GetText("CP_PROFILE", "WAS_QUOTED");
                icon       = "quote-left";
                message    = this.GetTextFormatted("WAS_QUOTED_MSG", userLink.RenderToString(), topicLink.RenderToString());
            }

            iconLabel.Text = $@"<i class=""fas fa-circle fa-stack-2x text-secondary""></i>
               <i class=""fas fa-{icon} fa-stack-1x fa-inverse""></i>;";

            displayDateTime.DateTime = activity.Created;

            messageHolder.Controls.Add(new Literal {
                Text = message
            });
        }
Ejemplo n.º 10
0
 /// <summary>
 /// The attach.
 /// </summary>
 /// <param name="userLinkControl">
 /// The user link control.
 /// </param>
 public void Attach([NotNull] UserLink userLinkControl)
 {
     userLinkControl.OnClick     = this.ControlOnClick;
     userLinkControl.OnMouseOver = this.ControlOnMouseOver;
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Render The User related Links
        /// </summary>
        private void RenderUserContainer()
        {
            if (this.PageContext.IsGuest)
            {
                return;
            }

            this.UserContainer.Visible = true;

            // My Profile
            this.MyProfile.ToolTip = this.GetText("TOOLBAR", "MYPROFILE_TITLE");
            this.MyProfile.NavigateUrl = YafBuildLink.GetLink(ForumPages.cp_profile);
            this.MyProfile.Text = this.GetText("TOOLBAR", "MYPROFILE");

            // My Inbox
            if (this.Get<YafBoardSettings>().AllowPrivateMessages)
            {
                RenderMenuItem(
                    this.MyInboxItem,
                    "menuMy myPm",
                    null,
                    this.GetText("TOOLBAR", "INBOX"),
                    this.GetText("TOOLBAR", "INBOX_TITLE"),
                    YafBuildLink.GetLink(ForumPages.cp_pm),
                    false,
                    this.PageContext.UnreadPrivate > 0,
                    this.PageContext.UnreadPrivate.ToString(),
                    this.GetText("TOOLBAR", "NEWPM").FormatWith(this.PageContext.UnreadPrivate));
            }

            // My Buddies
            if (this.Get<YafBoardSettings>().EnableBuddyList && this.PageContext.UserHasBuddies)
            {
                RenderMenuItem(
                    this.MyBuddiesItem,
                    "menuMy myBuddies",
                    null,
                    this.GetText("TOOLBAR", "BUDDIES"),
                    this.GetText("TOOLBAR", "BUDDIES_TITLE"),
                    YafBuildLink.GetLink(ForumPages.cp_editbuddies),
                    false,
                    this.PageContext.PendingBuddies > 0,
                    this.PageContext.PendingBuddies.ToString(),
                    this.GetText("TOOLBAR", "BUDDYREQUEST").FormatWith(this.PageContext.PendingBuddies));
            }

            // My Albums
            if (this.Get<YafBoardSettings>().EnableAlbum && (this.PageContext.UsrAlbums > 0 || this.PageContext.NumAlbums > 0))
            {
                RenderMenuItem(
                    this.MyAlbumsItem,
                    "menuMy myAlbums",
                    null,
                    this.GetText("TOOLBAR", "MYALBUMS"),
                    this.GetText("TOOLBAR", "MYALBUMS_TITLE"),
                    YafBuildLink.GetLinkNotEscaped(ForumPages.albums, "u={0}", this.PageContext.PageUserID),
                    false,
                    false,
                    null,
                    null);
            }

            var unread = this.PageContext.UnreadPrivate > 0 || this.PageContext.PendingBuddies > 0/* ||
                          this.PageContext.UnreadTopics > 0*/;

            // My Topics
            RenderMenuItem(
                this.MyTopicItem,
                "menuMy myTopics",
                null,
                this.GetText("TOOLBAR", "MYTOPICS"),
                this.GetText("TOOLBAR", "MYTOPICS"),
                YafBuildLink.GetLink(ForumPages.mytopics),
                false,
                false,//this.PageContext.UnreadTopics > 0,
                string.Empty,//this.PageContext.UnreadTopics.ToString(),
                string.Empty);//this.GetText("TOOLBAR", "UNREADTOPICS").FormatWith(this.PageContext.UnreadTopics));
            
            // Logout
            if (!Config.IsAnyPortal && Config.AllowLoginAndLogoff)
            {
                this.LogutItem.Visible = true;
                this.LogOutButton.Text = this.GetText("TOOLBAR", "LOGOUT");
                this.LogOutButton.ToolTip = this.GetText("TOOLBAR", "LOGOUT");
            }

            // Logged in as : username
            this.LoggedInUserPanel.Visible = true;

            if (unread)
            {
                this.LoggedInUserPanel.CssClass = "loggedInUser unread";
            }

            this.LoggedInUserPanel.Controls.Add(
                new Label { Text = this.GetText("TOOLBAR", "LOGGED_IN_AS").FormatWith("&nbsp;") });

            var userLink = new UserLink
                {
                    ID = "UserLoggedIn", 
                    UserID = this.PageContext.PageUserID,
                    CssClass = "currentUser",
                    EnableHoverCard = false
                };

            this.LoggedInUserPanel.Controls.Add(userLink);
        }
Ejemplo n.º 12
0
    /// <summary>
    /// Raises PreRender event and prepares control for rendering by creating links to active users.
    /// </summary>
    /// <param name="e">
    /// The e.
    /// </param>
    protected override void OnPreRender([NotNull] EventArgs e)
    {
      // IMPORTANT : call base implementation, raises PreRender event
      base.OnPreRender(e);

        // we shall continue only if there are active user data available
        if (this.ActiveUserTable == null)
        {
            return;
        }

        // add style column if there is no such column in the table
        // style column defines how concrete user's link should be styled
        if (!this.ActiveUserTable.Columns.Contains("Style"))
        {
            this.ActiveUserTable.Columns.Add("Style", typeof(string));
            this.ActiveUserTable.AcceptChanges();
        }

        var crawlers = new List<string>();

        // go through the table and process each row
        foreach (DataRow row in this.ActiveUserTable.Rows)
        {
            UserLink userLink;
           
            bool isCrawler = row["IsCrawler"].ToType<int>() > 0;
            
            // create new link and set its parameters
            if (isCrawler)
            {
               if  (crawlers.Contains(row["Browser"].ToString()))
               {
                  continue;
               }
                crawlers.Add(row["Browser"].ToString());
                userLink = new UserLink
                    {
                        CrawlerName = row["Browser"].ToString(), 
                        UserID = row["UserID"].ToType<int>(), 
                        Style =
                            this.Get<YafBoardSettings>().UseStyledNicks
                                ? this.Get<IStyleTransform>().DecodeStyleByString(row["Style"].ToString(), false)
                                : string.Empty
                    };
                userLink.ID += userLink.CrawlerName;
            }
            else
            {
                userLink = new UserLink
                    {
                        UserID = row["UserID"].ToType<int>(), 
                        Style =
                            this.Get<YafBoardSettings>().UseStyledNicks
                                ? this.Get<IStyleTransform>().DecodeStyleByString(row["Style"].ToString(), false)
                                : string.Empty,
                        ReplaceName = this.Get<YafBoardSettings>().EnableDisplayName
                              ? row["UserDisplayName"].ToString()
                              : row["UserName"].ToString()
                    };
                userLink.ID = "UserLink{0}{1}".FormatWith(this.InstantId, userLink.UserID);
                
               
            }

            // how many users of this type is present (valid for guests, others have it 1)
            int userCount = row["UserCount"].ToType<int>();
            if (userCount > 1 && (!isCrawler || !this.Get<YafBoardSettings>().ShowCrawlersInActiveList))
            {
                // add postfix if there is more the one user of this name
                userLink.PostfixText = " ({0})".FormatWith(userCount);
            }

            // indicates whether user link should be added or not
            bool addControl = true;
            // we might not want to add this user link if user is marked as hidden
            if (Convert.ToBoolean(row["IsHidden"]) || // or if user is guest and guest should be hidden
                (this.TreatGuestAsHidden && Convert.ToBoolean(row["IsGuest"])))
            {
                // hidden user are always visible to admin and himself)
                if (this.PageContext.IsAdmin || userLink.UserID == this.PageContext.PageUserID)
                {
                    // but use css style to distinguish such users
                    userLink.CssClass = "active_hidden";

                    // and also add postfix
                    userLink.PostfixText = " ({0})".FormatWith(this.GetText("HIDDEN"));
                }
                else
                {
                    // user is hidden from this user...
                    addControl = false;
                }
            }

            // add user link if it's not supressed
            if (!addControl)
            {
                continue;
            }

            // vzrus: if guests or crawlers there can be a control with the same id. 
            var ul = this.FindControlRecursiveAs<UserLink>(userLink.ID);
            if (ul != null)
            {
                this.Controls.Remove(ul);
            }

            this.Controls.Add(userLink);
        }
    }
Ejemplo n.º 13
0
        /// <summary>
        /// Handles the PreRender event
        /// </summary>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            if (this.DataSource == null)
            {
                return;
            }

            this.PageContext.PageElements.RegisterJsBlockStartup(
                "TopicLinkPopoverJs",
                JavaScriptBlocks.TopicLinkPopoverJs(
                    $"{this.GetText("LASTPOST")}&nbsp;{this.GetText("SEARCH", "BY")} ...",
                    ".topic-link-popover",
                    "focus hover"));

            if (!this.DataSource.ReadAccess)
            {
                this.TopicInPlaceHolder.Visible = false;

                // show "no posts"
                this.LastPostedHolder.Visible   = false;
                this.NoPostsPlaceHolder.Visible = true;

                return;
            }

            if (this.DataSource.LastPosted.HasValue)
            {
                this.topicLink.Text = this.Get <IBadWordReplace>()
                                      .Replace(this.HtmlEncode(this.DataSource.LastTopicName)).Truncate(50);

                // Last Post Date
                var lastPostedDateTime = this.DataSource.LastPosted.Value;

                // Topic Link
                this.topicLink.NavigateUrl = BuildLink.GetLink(
                    ForumPages.Posts, "t={0}&name={1}", this.DataSource.LastTopicID, this.topicLink.Text);

                var styles = this.PageContext.BoardSettings.UseStyledTopicTitles
                                 ? this.Get <IStyleTransform>().Decode(
                    this.DataSource.LastTopicStyles)
                                 : string.Empty;

                if (styles.IsSet())
                {
                    this.topicLink.Attributes.Add("style", styles);
                }

                // Last Topic User
                var lastUserLink = new UserLink
                {
                    Suspended = this.DataSource.LastUserSuspended,
                    UserID    = this.DataSource.LastUserID.Value,
                    IsGuest   = true,
                    Style     = this.PageContext.BoardSettings.UseStyledNicks && this.DataSource.Style.IsSet()
                                                       ? this.Get <IStyleTransform>().Decode(
                        this.DataSource.Style)
                                                       : string.Empty,
                    ReplaceName = this.PageContext.BoardSettings.EnableDisplayName
                                                            ? this.DataSource.LastUserDisplayName
                                                            : this.DataSource.LastUser
                };

                var lastRead = this.Get <IReadTrackCurrentUser>().GetForumTopicRead(
                    this.DataSource.ForumID,
                    this.DataSource.LastTopicID,
                    this.DataSource.LastForumAccess,
                    this.DataSource.LastTopicAccess);

                var formattedDatetime = this.PageContext.BoardSettings.ShowRelativeTime
                                            ? lastPostedDateTime.ToString(
                    "yyyy-MM-ddTHH:mm:ssZ",
                    CultureInfo.InvariantCulture)
                                            : this.Get <IDateTime>().Format(
                    DateTimeFormat.BothTopic,
                    lastPostedDateTime);

                var span = this.PageContext.BoardSettings.ShowRelativeTime ? @"<span class=""popover-timeago"">" : "<span>";

                this.Info.DataContent = $@"
                          {lastUserLink.RenderToString()}
                          <span class=""fa-stack"">
                                                    <i class=""fa fa-calendar-day fa-stack-1x text-secondary""></i>
                                                    <i class=""fa fa-circle fa-badge-bg fa-inverse fa-outline-inverse""></i>
                                                    <i class=""fa fa-clock fa-badge text-secondary""></i>
                                                </span>&nbsp;{span}{formattedDatetime}</span>
                         ";

                this.Info.Text = string.Format(
                    this.GetText("Default", "BY"),
                    this.PageContext.BoardSettings.EnableDisplayName ? this.DataSource.LastUserDisplayName : this.DataSource.LastUser);

                if (this.DataSource.LastPosted.Value > lastRead)
                {
                    this.NewMessage.Visible = true;
                    this.NewMessage.Text    = $" <span class=\"badge bg-success\">{this.GetText("NEW_POSTS")}</span>";
                }
                else
                {
                    this.NewMessage.Visible = false;
                }

                this.LastPostedHolder.Visible   = true;
                this.NoPostsPlaceHolder.Visible = false;
            }
            else
            {
                // show "no posts"
                this.LastPostedHolder.Visible   = false;
                this.NoPostsPlaceHolder.Visible = true;
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Raises PreRender event and prepares control for rendering by creating links to active users.
        /// </summary>
        /// <param name="e">
        /// The e.
        /// </param>
        protected override void OnPreRender([NotNull] EventArgs e)
        {
            // IMPORTANT : call base implementation, raises PreRender event
            base.OnPreRender(e);

            // we shall continue only if there are active user data available
            if (this.ActiveUserTable == null)
            {
                return;
            }

            // add style column if there is no such column in the table
            // style column defines how concrete user's link should be styled
            if (!this.ActiveUserTable.Columns.Contains("Style"))
            {
                this.ActiveUserTable.Columns.Add("Style", typeof(string));
                this.ActiveUserTable.AcceptChanges();
            }

            var crawlers = new List <string>();

            // go through the table and process each row
            foreach (DataRow row in this.ActiveUserTable.Rows)
            {
                UserLink userLink;

                bool isCrawler = row["IsCrawler"].ToType <int>() > 0;

                // create new link and set its parameters
                if (isCrawler)
                {
                    if (crawlers.Contains(row["Browser"].ToString()))
                    {
                        continue;
                    }
                    crawlers.Add(row["Browser"].ToString());
                    userLink = new UserLink
                    {
                        CrawlerName = row["Browser"].ToString(),
                        UserID      = row["UserID"].ToType <int>(),
                        Style       =
                            this.Get <YafBoardSettings>().UseStyledNicks
                                ? this.Get <IStyleTransform>().DecodeStyleByString(row["Style"].ToString(), false)
                                : string.Empty
                    };
                    userLink.ID += userLink.CrawlerName;
                }
                else
                {
                    userLink = new UserLink
                    {
                        UserID = row["UserID"].ToType <int>(),
                        Style  =
                            this.Get <YafBoardSettings>().UseStyledNicks
                                ? this.Get <IStyleTransform>().DecodeStyleByString(row["Style"].ToString(), false)
                                : string.Empty,
                        ReplaceName = this.Get <YafBoardSettings>().EnableDisplayName
                              ? row["UserDisplayName"].ToString()
                              : row["UserName"].ToString()
                    };
                    userLink.ID = "UserLink{0}{1}".FormatWith(this.InstantId, userLink.UserID);
                }

                // how many users of this type is present (valid for guests, others have it 1)
                int userCount = row["UserCount"].ToType <int>();
                if (userCount > 1 && (!isCrawler || !this.Get <YafBoardSettings>().ShowCrawlersInActiveList))
                {
                    // add postfix if there is more the one user of this name
                    userLink.PostfixText = " ({0})".FormatWith(userCount);
                }

                // indicates whether user link should be added or not
                bool addControl = true;
                // we might not want to add this user link if user is marked as hidden
                if (Convert.ToBoolean(row["IsHidden"]) || // or if user is guest and guest should be hidden
                    (this.TreatGuestAsHidden && Convert.ToBoolean(row["IsGuest"])))
                {
                    // hidden user are always visible to admin and himself)
                    if (this.PageContext.IsAdmin || userLink.UserID == this.PageContext.PageUserID)
                    {
                        // but use css style to distinguish such users
                        userLink.CssClass = "active_hidden";

                        // and also add postfix
                        userLink.PostfixText = " ({0})".FormatWith(this.GetText("HIDDEN"));
                    }
                    else
                    {
                        // user is hidden from this user...
                        addControl = false;
                    }
                }

                // add user link if it's not supressed
                if (!addControl)
                {
                    continue;
                }

                // vzrus: if guests or crawlers there can be a control with the same id.
                var ul = this.FindControlRecursiveAs <UserLink>(userLink.ID);
                if (ul != null)
                {
                    this.Controls.Remove(ul);
                }

                this.Controls.Add(userLink);
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// The latest posts_ item data bound.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void LatestPosts_ItemDataBound([NotNull] object sender, [NotNull] RepeaterItemEventArgs e)
        {
            // populate the controls here...
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }

            var item = (dynamic)e.Item.DataItem;

            var topicSubject = this.Get <IBadWordReplace>().Replace(this.HtmlEncode((string)item.Topic));

            // get the controls
            var postIcon            = e.Item.FindControlAs <Label>("PostIcon");
            var textMessageLink     = e.Item.FindControlAs <ThemeButton>("TextMessageLink");
            var forumLink           = e.Item.FindControlAs <ThemeButton>("ForumLink");
            var info                = e.Item.FindControlAs <ThemeButton>("Info");
            var lastUserLink        = new UserLink();
            var lastPostedDateLabel = new DisplayDateTime {
                Format = DateTimeFormat.BothTopic
            };

            var topicStyle = (string)item.Styles;

            var styles = this.PageContext.BoardSettings.UseStyledTopicTitles && topicStyle.IsSet()
                ? this.Get <IStyleTransform>().Decode((string)item.Styles)
                : string.Empty;

            if (styles.IsSet())
            {
                textMessageLink.Attributes.Add("style", styles);
            }

            textMessageLink.Text = topicSubject;

            var startedByText = this.GetTextFormatted(
                "VIEW_TOPIC_STARTED_BY",
                this.PageContext.BoardSettings.EnableDisplayName ? (string)item.UserDisplayName : (string)item.UserName);

            var inForumText = this.GetTextFormatted("IN_FORUM", this.HtmlEncode((string)item.Forum));

            textMessageLink.TitleNonLocalized = $"{startedByText} {inForumText}";
            textMessageLink.NavigateUrl       = BuildLink.GetLink(
                ForumPages.Posts,
                "t={0}&name={1}",
                item.TopicID,
                topicSubject);

            forumLink.Text        = $"({item.Forum})";
            forumLink.NavigateUrl = BuildLink.GetForumLink(item.ForumID, item.Forum);

            lastUserLink.UserID      = item.LastUserID;
            lastUserLink.Style       = item.LastUserStyle;
            lastUserLink.Suspended   = item.LastUserSuspended;
            lastUserLink.ReplaceName = this.PageContext.BoardSettings.EnableDisplayName
                ? item.LastUserDisplayName
                : item.LastUserName;

            lastPostedDateLabel.DateTime = item.LastPosted;

            var lastRead = this.Get <IReadTrackCurrentUser>().GetForumTopicRead(
                (int)item.ForumID,
                (int)item.TopicID,
                (DateTime?)item.LastForumAccess ?? DateTimeHelper.SqlDbMinTime(),
                (DateTime?)item.LastTopicAccess ?? DateTimeHelper.SqlDbMinTime());

            if ((DateTime)item.LastPosted > lastRead)
            {
                postIcon.Visible  = true;
                postIcon.CssClass = "badge bg-success";

                postIcon.Text = this.GetText("NEW_MESSAGE");
            }

            var lastPostedDateTime = (DateTime)item.LastPosted;

            var formattedDatetime = this.PageContext.BoardSettings.ShowRelativeTime
                                        ? lastPostedDateTime.ToString(
                "yyyy-MM-ddTHH:mm:ssZ",
                CultureInfo.InvariantCulture)
                                        : this.Get <IDateTime>().Format(
                DateTimeFormat.BothTopic,
                lastPostedDateTime);

            var span = this.PageContext.BoardSettings.ShowRelativeTime ? @"<span class=""popover-timeago"">" : "<span>";

            info.TextLocalizedTag  = "by";
            info.TextLocalizedPage = "DEFAULT";
            info.ParamText0        = this.PageContext.BoardSettings.EnableDisplayName
                                  ? item.UserDisplayName
                                  : item.UserName;

            info.DataContent = $@"
                          {lastUserLink.RenderToString()}
                          <span class=""fa-stack"">
                                                    <i class=""fa fa-calendar-day fa-stack-1x text-secondary""></i>
                                                    <i class=""fa fa-circle fa-badge-bg fa-inverse fa-outline-inverse""></i>
                                                    <i class=""fa fa-clock fa-badge text-secondary""></i>
                                                </span>&nbsp;{span}{formattedDatetime}</span>
                         ";
        }
        /// <summary>
        /// The latest posts_ item data bound.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void LatestPosts_ItemDataBound([NotNull] object sender, [NotNull] RepeaterItemEventArgs e)
        {
            // populate the controls here...
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }

            var currentRow = (DataRowView)e.Item.DataItem;

            // make message url...
            var messageUrl = BuildLink.GetLinkNotEscaped(
                ForumPages.Posts, "m={0}#post{0}", currentRow["LastMessageID"]);

            // get the controls
            var postIcon                   = e.Item.FindControlAs <Label>("PostIcon");
            var textMessageLink            = e.Item.FindControlAs <HyperLink>("TextMessageLink");
            var info                       = e.Item.FindControlAs <ThemeButton>("Info");
            var imageMessageLink           = e.Item.FindControlAs <ThemeButton>("GoToLastPost");
            var imageLastUnreadMessageLink = e.Item.FindControlAs <ThemeButton>("GoToLastUnread");
            var lastUserLink               = new UserLink();
            var lastPostedDateLabel        = new DisplayDateTime {
                Format = DateTimeFormat.BothTopic
            };

            var topicSubject = this.Get <IBadWordReplace>().Replace(this.HtmlEncode(currentRow["Topic"]));

            var styles = this.Get <BoardSettings>().UseStyledTopicTitles
                             ? this.Get <IStyleTransform>().DecodeStyleByString(currentRow["Styles"].ToString())
                             : string.Empty;

            if (styles.IsSet())
            {
                textMessageLink.Attributes.Add("style", styles);
            }

            textMessageLink.Text = topicSubject;

            var startedByText = this.GetTextFormatted(
                "VIEW_TOPIC_STARTED_BY",
                currentRow[this.Get <BoardSettings>().EnableDisplayName ? "UserDisplayName" : "UserName"].ToString());

            var inForumText = this.GetTextFormatted("IN_FORUM", this.HtmlEncode(currentRow["Forum"].ToString()));

            textMessageLink.ToolTip =
                $"{startedByText} {inForumText}";
            textMessageLink.Attributes.Add("data-toggle", "tooltip");

            textMessageLink.NavigateUrl = BuildLink.GetLinkNotEscaped(
                ForumPages.Posts, "t={0}&find=unread", currentRow["TopicID"]);

            imageMessageLink.NavigateUrl = messageUrl;

            if (imageLastUnreadMessageLink.Visible)
            {
                imageLastUnreadMessageLink.NavigateUrl = BuildLink.GetLinkNotEscaped(
                    ForumPages.Posts,
                    "t={0}&find=unread",
                    currentRow["TopicID"]);
            }

            // Just in case...
            if (currentRow["LastUserID"] != DBNull.Value)
            {
                lastUserLink.UserID      = currentRow["LastUserID"].ToType <int>();
                lastUserLink.Style       = currentRow["LastUserStyle"].ToString();
                lastUserLink.ReplaceName = this.Get <BoardSettings>().EnableDisplayName
                              ? currentRow["LastUserDisplayName"].ToString()
                              : currentRow["LastUserName"].ToString();
            }

            if (currentRow["LastPosted"] != DBNull.Value)
            {
                lastPostedDateLabel.DateTime = currentRow["LastPosted"];

                var lastRead =
                    this.Get <IReadTrackCurrentUser>().GetForumTopicRead(
                        currentRow["ForumID"].ToType <int>(),
                        currentRow["TopicID"].ToType <int>(),
                        currentRow["LastForumAccess"].ToType <DateTime?>() ?? DateTimeHelper.SqlDbMinTime(),
                        currentRow["LastTopicAccess"].ToType <DateTime?>() ?? DateTimeHelper.SqlDbMinTime());

                if (DateTime.Parse(currentRow["LastPosted"].ToString()) > lastRead)
                {
                    postIcon.CssClass = "badge badge-success";

                    postIcon.Text = this.GetText("NEW_MESSAGE");
                }
            }

            var lastPostedDateTime = currentRow["LastPosted"].ToType <DateTime>();

            var formattedDatetime = this.Get <BoardSettings>().ShowRelativeTime
                                        ? lastPostedDateTime.ToString(
                "yyyy-MM-ddTHH:mm:ssZ",
                CultureInfo.InvariantCulture)
                                        : this.Get <IDateTime>().Format(
                DateTimeFormat.BothTopic,
                lastPostedDateTime);

            var span = this.Get <BoardSettings>().ShowRelativeTime ? @"<span class=""popover-timeago"">" : "<span>";

            info.TextLocalizedTag  = "by";
            info.TextLocalizedPage = "DEFAULT";
            info.ParamText0        = this.Get <BoardSettings>().EnableDisplayName
                                  ? currentRow["LastUserDisplayName"].ToString()
                                  : currentRow["LastUserName"].ToString();

            info.DataContent = $@"
                          {lastUserLink.RenderToString()}
                          <span class=""fa-stack"">
                                                    <i class=""fa fa-calendar-day fa-stack-1x text-secondary""></i>
                                                    <i class=""fa fa-circle fa-badge-bg fa-inverse fa-outline-inverse""></i>
                                                    <i class=""fa fa-clock fa-badge text-secondary""></i>
                                                </span>&nbsp;{span}{formattedDatetime}</span>
                         ";
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Handles the PreRender event
        /// </summary>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            if (this.DataRow == null)
            {
                return;
            }

            this.PageContext.PageElements.RegisterJsBlockStartup(
                "TopicLinkPopoverJs",
                JavaScriptBlocks.TopicLinkPopoverJs(
                    $"{this.GetText("LASTPOST")}&nbsp;{this.GetText("SEARCH", "BY")} ...",
                    ".topic-link-popover",
                    "focus hover"));

            var showLastLinks = true;

            if (this.DataRow["ReadAccess"].ToType <int>() == 0)
            {
                this.TopicInPlaceHolder.Visible = false;
                showLastLinks = false;
            }

            if (this.DataRow["LastPosted"] != DBNull.Value)
            {
                // Last Post Date
                var lastPostedDateTime = this.DataRow["LastPosted"].ToType <DateTime>();

                // Topic Link
                this.topicLink.NavigateUrl = BuildLink.GetLinkNotEscaped(
                    ForumPages.Posts, "t={0}", this.DataRow["LastTopicID"]);

                this.topicLink.ToolTip = this.GetText("COMMON", "VIEW_TOPIC");

                var styles = this.Get <BoardSettings>().UseStyledTopicTitles
                                 ? this.Get <IStyleTransform>().DecodeStyleByString(
                    this.DataRow["LastTopicStyles"].ToString())
                                 : string.Empty;

                if (styles.IsSet())
                {
                    this.topicLink.Attributes.Add("style", styles);
                }

                this.topicLink.Text = this.Get <IBadWordReplace>()
                                      .Replace(this.HtmlEncode(this.DataRow["LastTopicName"].ToString())).Truncate(50);

                // Last Topic User
                var lastUserLink = new UserLink
                {
                    UserID = this.DataRow["LastUserID"].ToType <int>(),
                    Style  = this.Get <BoardSettings>().UseStyledNicks
                                                       ? this.Get <IStyleTransform>().DecodeStyleByString(
                        this.DataRow["Style"].ToString())
                                                       : string.Empty,
                    ReplaceName = this
                                  .DataRow[this.Get <BoardSettings>().EnableDisplayName
                                                            ? "LastUserDisplayName"
                                                            : "LastUser"].ToString()
                };

                this.LastTopicImgLink.NavigateUrl = BuildLink.GetLinkNotEscaped(
                    ForumPages.Posts, "m={0}#post{0}", this.DataRow["LastMessageID"]);

                this.ImageLastUnreadMessageLink.NavigateUrl = BuildLink.GetLinkNotEscaped(
                    ForumPages.Posts, "t={0}&find=unread", this.DataRow["LastTopicID"]);

                var lastRead =
                    this.Get <IReadTrackCurrentUser>().GetForumTopicRead(
                        this.DataRow["ForumID"].ToType <int>(),
                        this.DataRow["LastTopicID"].ToType <int>(),
                        this.DataRow["LastForumAccess"].ToType <DateTime?>(),
                        this.DataRow["LastTopicAccess"].ToType <DateTime?>());

                var formattedDatetime = this.Get <BoardSettings>().ShowRelativeTime
                                            ? lastPostedDateTime.ToString(
                    "yyyy-MM-ddTHH:mm:ssZ",
                    CultureInfo.InvariantCulture)
                                            : this.Get <IDateTime>().Format(
                    DateTimeFormat.BothTopic,
                    lastPostedDateTime);

                var span = this.Get <BoardSettings>().ShowRelativeTime ? @"<span class=""popover-timeago"">" : "<span>";

                this.Info.DataContent = $@"
                          {lastUserLink.RenderToString()}
                          <span class=""fa-stack"">
                                                    <i class=""fa fa-calendar-day fa-stack-1x text-secondary""></i>
                                                    <i class=""fa fa-circle fa-badge-bg fa-inverse fa-outline-inverse""></i>
                                                    <i class=""fa fa-clock fa-badge text-secondary""></i>
                                                </span>&nbsp;{span}{formattedDatetime}</span>
                         ";

                this.Info.Text = string.Format(
                    this.GetText("Default", "BY"),
                    this.DataRow[this.Get <BoardSettings>().EnableDisplayName ? "LastUserDisplayName" : "LastUser"]);

                if (this.DataRow["LastPosted"].ToType <DateTime>() > lastRead)
                {
                    this.NewMessage.Visible = true;
                    this.NewMessage.Text    = $" <span class=\"badge badge-success\">{this.GetText("NEW_POSTS")}</span>";
                }
                else
                {
                    this.NewMessage.Visible = false;
                }

                this.LastPostedHolder.Visible   = showLastLinks;
                this.NoPostsPlaceHolder.Visible = false;
            }
            else
            {
                // show "no posts"
                this.LastPostedHolder.Visible   = false;
                this.NoPostsPlaceHolder.Visible = true;
            }
        }