private static string ParsePreview(int portalId, string template, string message, int moduleId) { //TODO: Legacy Attachments Functionality - Probably can remove. if (message.Contains("[IMAGE:")) { var strHost = Common.Globals.AddHTTP(Common.Globals.GetDomainName(HttpContext.Current.Request)) + "/"; const string pattern = "([IMAGE:(.+?)])"; foreach (Match match in Regex.Matches(message, pattern)) { var sImage = "<img src=\"" + strHost + "DesktopModules/ActiveForums/viewer.aspx?portalid=" + portalId + "&moduleid=" + moduleId + "&attachid=" + match.Groups[2].Value + "\" border=\"0\" />"; message = message.Replace(match.Value, sImage); } } //TODO: Legacy Attachments Functionality - Probably can remove. if (message.Contains("[THUMBNAIL:")) { var strHost = Common.Globals.AddHTTP(Common.Globals.GetDomainName(HttpContext.Current.Request)) + "/"; const string pattern = "([THUMBNAIL:(.+?)])"; foreach (Match match in Regex.Matches(message, pattern)) { var thumbId = match.Groups[2].Value.Split(':')[0]; var parentId = match.Groups[2].Value.Split(':')[1]; var sImage = "<a href=\"" + strHost + "DesktopModules/ActiveForums/viewer.aspx?portalid=" + portalId + "&moduleid=" + moduleId + "&attachid=" + parentId + "\" target=\"_blank\"><img src=\"" + strHost + "DesktopModules/ActiveForums/viewer.aspx?portalid=" + portalId + "&moduleid=" + moduleId + "&attachid=" + thumbId + "\" border=\"0\" /></a>"; message = message.Replace(match.Value, sImage); } } template = template.Replace("[BODY]", message); if (Regex.IsMatch(template, "<CODE([^>]*)>", RegexOptions.IgnoreCase)) { if (Regex.IsMatch(message, "<CODE([^>]*)>", RegexOptions.IgnoreCase)) { foreach (Match m in Regex.Matches(message, "<CODE([^>]*)>(.*?)</CODE>", RegexOptions.IgnoreCase)) message = message.Replace(m.Value, m.Value.Replace("<br>", System.Environment.NewLine)); } var objCode = new CodeParser(); template = CodeParser.ParseCode(Utilities.HTMLDecode(template)); } return template; }
/// <summary> /// Prepares the post form for creating a reply. /// </summary> private void PrepareReply() { ctlForm.EditorMode = Modules.ActiveForums.Controls.SubmitForm.EditorModes.Reply; string template; if (_fi.ReplyFormId == 0) { var myFile = Request.MapPath(Common.Globals.ApplicationPath) + "\\DesktopModules\\ActiveForums\\config\\templates\\ReplyEditor.txt"; template = File.ReadAllText(myFile); } else { var tc = new TemplateController(); var ti = tc.Template_Get(_fi.ReplyFormId, PortalId, ForumModuleId); template = ti.TemplateHTML; } if (MainSettings.UseSkinBreadCrumb) template = template.Replace("<div class=\"afcrumb\">[AF:LINK:FORUMMAIN] > [AF:LINK:FORUMGROUP] > [AF:LINK:FORUMNAME]</div>", string.Empty); ctlForm.Template = template; if (!(TopicId > 0)) { //Can't Find Topic var im = new InfoMessage { Message = GetSharedResource("[RESX:Message:LoadTopicFailed]") }; plhContent.Controls.Add(im); } else if (!CanReply) { //No permission to reply var im = new InfoMessage { Message = GetSharedResource("[RESX:Message:AccessDenied]") }; plhContent.Controls.Add(im); } else { var tc = new TopicsController(); var ti = tc.Topics_Get(PortalId, ForumModuleId, TopicId, ForumId, UserId, true); if(ti == null) Response.Redirect(NavigateUrl(ForumTabId)); ctlForm.Subject = Utilities.GetSharedResource("[RESX:SubjectPrefix]") + " " + ti.Content.Subject; ctlForm.TopicSubject = ti.Content.Subject; var body = string.Empty; if (ti.IsLocked && (CurrentUserType == CurrentUserTypes.Anon || CurrentUserType == CurrentUserTypes.Auth)) Response.Redirect(NavigateUrl(ForumTabId)); if (Request.Params[ParamKeys.QuoteId] != null | Request.Params[ParamKeys.ReplyId] != null | Request.Params[ParamKeys.PostId] != null) { //Setup form for Quote or Reply with body display var isQuote = false; var postId = 0; var sPostedBy = Utilities.GetSharedResource("[RESX:PostedBy]") + " {0} {1} {2}"; if (Request.Params[ParamKeys.QuoteId] != null) { isQuote = true; if (SimulateIsNumeric.IsNumeric(Request.Params[ParamKeys.QuoteId])) postId = Convert.ToInt32(Request.Params[ParamKeys.QuoteId]); } else if (Request.Params[ParamKeys.ReplyId] != null) { if (SimulateIsNumeric.IsNumeric(Request.Params[ParamKeys.ReplyId])) postId = Convert.ToInt32(Request.Params[ParamKeys.ReplyId]); } else if (Request.Params[ParamKeys.PostId] != null) { if (SimulateIsNumeric.IsNumeric(Request.Params[ParamKeys.PostId])) postId = Convert.ToInt32(Request.Params[ParamKeys.PostId]); } if (postId != 0) { var userDisplay = MainSettings.UserNameDisplay; if (_editorType == EditorTypes.TEXTBOX) userDisplay = "none"; Content ci; if (postId == TopicId) { ti = tc.Topics_Get(PortalId, ForumModuleId, TopicId); ci = ti.Content; sPostedBy = string.Format(sPostedBy, UserProfiles.GetDisplayName(ForumModuleId, true, false, false, ti.Content.AuthorId, ti.Author.Username, ti.Author.FirstName, ti.Author.LastName, ti.Author.DisplayName), Utilities.GetSharedResource("On.Text"), GetServerDateTime(ti.Content.DateCreated)); } else { var rc = new ReplyController(); var ri = rc.Reply_Get(PortalId, ForumModuleId, TopicId, postId); ci = ri.Content; sPostedBy = string.Format(sPostedBy, UserProfiles.GetDisplayName(ForumModuleId, true, false, false, ri.Content.AuthorId, ri.Author.Username, ri.Author.FirstName, ri.Author.LastName, ri.Author.DisplayName), Utilities.GetSharedResource("On.Text"), GetServerDateTime(ri.Content.DateCreated)); } if (ci != null) body = ci.Body; } if (_allowHTML && _editorType != EditorTypes.TEXTBOX) { if (body.ToUpper().Contains("<CODE") | body.ToUpper().Contains("[CODE]")) { var objCode = new CodeParser(); body = CodeParser.ParseCode(Utilities.HTMLDecode(body)); } } else { body = Utilities.PrepareForEdit(PortalId, ForumModuleId, ImagePath, body, _allowHTML, _editorType); } if (isQuote) { ctlForm.EditorMode = SubmitForm.EditorModes.Quote; if (_allowHTML && _editorType != EditorTypes.TEXTBOX) { body = "<blockquote>" + System.Environment.NewLine + sPostedBy + System.Environment.NewLine + "<br />" + System.Environment.NewLine + body + System.Environment.NewLine + "</blockquote><br /><br />"; } else { body = "[quote]" + System.Environment.NewLine + sPostedBy + System.Environment.NewLine + body + System.Environment.NewLine + "[/quote]" + System.Environment.NewLine; } } else { ctlForm.EditorMode = SubmitForm.EditorModes.ReplyWithBody; body = sPostedBy + "<br />" + body; } ctlForm.Body = body; } } if (ctlForm.EditorMode != SubmitForm.EditorModes.EditReply && _canModApprove) { ctlForm.ShowModOptions = false; } }