コード例 #1
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")}";
        }
コード例 #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);

            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")}";
        }
コード例 #3
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));
      }
    }
コード例 #4
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;
        }
コード例 #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 = (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
            });
        }
コード例 #6
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;
        }
コード例 #7
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 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>
                         ";
        }
コード例 #8
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;
            }
        }
コード例 #9
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>
                         ";
        }
コード例 #10
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;
            }
        }