/// <summary>
        /// Renders the edited message.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="edited">The edited date time.</param>
        /// <param name="editReason">The edit reason text.</param>
        /// <param name="messageId">The message id.</param>
        protected virtual void RenderEditedMessage(
            [NotNull] HtmlTextWriter writer, [NotNull] DateTime edited, [NotNull] string editReason, int?messageId)
        {
            var editedDateTime = new DisplayDateTime {
                DateTime = edited
            }.RenderToString();

            // vzrus: TODO:  Guests doesn't have right to view change history
            // reason was specified ?!
            var editReasonText = "{0}: {1}".FormatWith(
                this.GetText("EDIT_REASON"),
                !string.IsNullOrEmpty(this.Get <HttpContextBase>().Server.HtmlDecode(editReason))
                    ? this.Get <IFormatMessage>().RepairHtml(editReason, true)
                    : this.GetText("EDIT_REASON_NA"));

            // message has been edited
            // show, why the post was edited or deleted?
            var whoChanged = this.IsModeratorChanged
                                 ? this.GetText("POSTS", "EDITED_BY_MOD")
                                 : this.GetText("POSTS", "EDITED_BY_USER");

            writer.Write(
                @"<p class=""MessageDetails""><em><a title=""{3}"" alt=""title=""{3}"" href=""{4}"">{0} {1}</a>&nbsp;{2}&nbsp;|&nbsp;<span class=""editedinfo"">{3}</span></em></p>"
                .FormatWith(
                    this.GetText("EDITED"),
                    whoChanged,
                    editedDateTime,
                    editReasonText,
                    this.PageContext.IsGuest
                            ? "#"
                            : YafBuildLink.GetLink(ForumPages.messagehistory, "m={0}", messageId.ToType <int>())));
        }
Пример #2
0
        /// <summary>
        /// Renders the edited message.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="edited">The edited date time.</param>
        /// <param name="editReason">The edit reason text.</param>
        /// <param name="messageId">The message id.</param>
        protected virtual void RenderEditedMessage(
            [NotNull] HtmlTextWriter writer, [NotNull] DateTime edited, [NotNull] string editReason, int?messageId)
        {
            if (!this.Get <YafBoardSettings>().ShowEditedMessage)
            {
                return;
            }

            var editedDateTime = new DisplayDateTime {
                DateTime = edited
            }.RenderToString();

            // vzrus: TODO:  Guests doesn't have right to view change history
            // reason was specified ?!
            var editReasonText = "{0}: {1}".FormatWith(
                this.GetText("EDIT_REASON"),
                this.Get <HttpContextBase>().Server.HtmlDecode(editReason).IsSet()
                    ? this.Get <IFormatMessage>().RepairHtml(editReason, true)
                    : this.GetText("EDIT_REASON_NA"));

            // message has been edited
            // show, why the post was edited or deleted?
            var whoChanged = this.IsModeratorChanged
                                 ? this.GetText("POSTS", "EDITED_BY_MOD")
                                 : this.GetText("POSTS", "EDITED_BY_USER");

            writer.Write(
                @"<div class=""alert alert-secondary"" role=""alert"">
                      <a title=""{3}"" alt=""title=""{3}"" href=""{4}""><strong>{0}</strong> {1}</a>&nbsp;{2}&nbsp;|&nbsp;<em>{3}</em>
                      <button type=""button"" class=""close"" data-dismiss=""alert"" aria-label=""Close"">
                          <span aria-hidden=""true"">&times;</span>
                      </button></div>"
                .FormatWith(
                    this.GetText("EDITED"),
                    whoChanged,
                    editedDateTime,
                    editReasonText,
                    this.PageContext.IsGuest
                            ? "#"
                            : YafBuildLink.GetLink(ForumPages.messagehistory, "m={0}", messageId.ToType <int>())));
        }
        /// <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>
                         ";
        }
Пример #4
0
        /// <summary>
        /// Renders the edited message.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="edited">The edited date time.</param>
        /// <param name="editReason">The edit reason text.</param>
        /// <param name="messageId">The message id.</param>
        protected virtual void RenderEditedMessage(
            [NotNull] HtmlTextWriter writer, [NotNull] DateTime edited, [NotNull] string editReason, int? messageId)
        {
            var editedDateTime = new DisplayDateTime { DateTime = edited }.RenderToString();

            // vzrus: TODO:  Guests doesn't have right to view change history
            // reason was specified ?!
            var editReasonText = "{0}: {1}".FormatWith(
                this.GetText("EDIT_REASON"),
                !string.IsNullOrEmpty(this.Get<HttpContextBase>().Server.HtmlDecode(editReason))
                    ? this.Get<IFormatMessage>().RepairHtml(editReason, true)
                    : this.GetText("EDIT_REASON_NA"));

            // message has been edited
            // show, why the post was edited or deleted?
            var whoChanged = this.IsModeratorChanged
                                 ? this.GetText("POSTS", "EDITED_BY_MOD")
                                 : this.GetText("POSTS", "EDITED_BY_USER");

            writer.Write(
                @"<p class=""MessageDetails""><em><a title=""{3}"" alt=""title=""{3}"" href=""{4}"">{0} {1}</a>&nbsp;{2}&nbsp;|&nbsp;<span class=""editedinfo"">{3}</span></em></p>"
                    .FormatWith(
                        this.GetText("EDITED"),
                        whoChanged,
                        editedDateTime,
                        editReasonText,
                        this.PageContext.IsGuest
                            ? "#"
                            : YafBuildLink.GetLink(ForumPages.messagehistory, "m={0}", messageId.ToType<int>())));
        }
Пример #5
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>
                         ";
        }