public string GetList(int currentIndex, int rows) { if (CurrentUser.UserID > 0) { isAdmin = CurrentUser.IsInRole(PortalSettings.AdministratorRoleName); } var jc = InternalJournalController.Instance; var sb = new StringBuilder(); string statusTemplate = Services.Localization.Localization.GetString("journal_status", resxPath); string linkTemplate = Services.Localization.Localization.GetString("journal_link", resxPath); string photoTemplate = Services.Localization.Localization.GetString("journal_photo", resxPath); string fileTemplate = Services.Localization.Localization.GetString("journal_file", resxPath); string rowTemplate = string.Empty; statusTemplate = Regex.Replace(statusTemplate, "\\[BaseUrl\\]", url, RegexOptions.IgnoreCase); linkTemplate = Regex.Replace(linkTemplate, "\\[BaseUrl\\]", url, RegexOptions.IgnoreCase); photoTemplate = Regex.Replace(photoTemplate, "\\[BaseUrl\\]", url, RegexOptions.IgnoreCase); fileTemplate = Regex.Replace(fileTemplate, "\\[BaseUrl\\]", url, RegexOptions.IgnoreCase); string Comment = Localization.GetString("comment", resxPath); string Comments = Localization.GetString("Comments", resxPath); IList<JournalItem> journalList; if (ProfileId > 0) { journalList = jc.GetJournalItemsByProfile(PortalSettings.PortalId, ModuleId, CurrentUser.UserID, ProfileId, currentIndex, rows); } else if (SocialGroupId > 0) { journalList = jc.GetJournalItemsByGroup(PortalSettings.PortalId, ModuleId, CurrentUser.UserID, SocialGroupId, currentIndex, rows); } else { journalList = jc.GetJournalItems(PortalSettings.PortalId, ModuleId, CurrentUser.UserID, currentIndex, rows); } string journalIds = ""; foreach(JournalItem ji in journalList){ journalIds +=ji.JournalId.ToString() + ';'; } IList<CommentInfo> comments = jc.GetCommentsByJournalIds(journalIds); foreach (JournalItem ji in journalList) { string pattern = "{CanComment}(.*?){/CanComment}"; string replacement = string.Empty; if (CurrentUser.UserID > 0 && SocialGroupId <= 0) { replacement = "$1"; } if (CurrentUser.UserID > 0 && ji.SocialGroupId > 0) { if (CurrentUser.IsInRole(ji.JournalOwner.Name)) { replacement = "$1"; } else { replacement = string.Empty; } } if (ji.JournalType == "status") { rowTemplate = statusTemplate; rowTemplate = Regex.Replace(rowTemplate, pattern, replacement, RegexOptions.IgnoreCase); } else if (ji.JournalType == "link") { rowTemplate = linkTemplate; rowTemplate = Regex.Replace(rowTemplate, pattern, replacement, RegexOptions.IgnoreCase); } else if (ji.JournalType == "photo") { rowTemplate = photoTemplate; rowTemplate = Regex.Replace(rowTemplate, pattern, replacement, RegexOptions.IgnoreCase); } else if (ji.JournalType == "file") { rowTemplate = fileTemplate; rowTemplate = Regex.Replace(rowTemplate, pattern, replacement, RegexOptions.IgnoreCase); } else { rowTemplate = GetJournalTemplate(ji.JournalType, ji); } Components.JournalControl ctl = new Components.JournalControl(); bool isLiked = false; ctl.LikeList = GetLikeListHTML(ji, ref isLiked); ctl.LikeLink = String.Empty; ctl.CommentLink = String.Empty; ctl.AuthorNameLink = "<a href=\"" + DotNetNuke.Common.Globals.NavigateURL(PortalSettings.UserTabId, string.Empty, new String[] {"userId=" + ji.JournalAuthor.Id.ToString()}) + "\">" + ji.JournalAuthor.Name + "</a>"; if (CurrentUser.UserID > 0) { ctl.CommentLink = "<a href=\"#\" id=\"cmtbtn-" + ji.JournalId + "\">" + Comment + "</a>"; if (isLiked) { ctl.LikeLink = "<a href=\"#\" id=\"like-" + ji.JournalId + "\">{resx:unlike}</a>"; } else { ctl.LikeLink = "<a href=\"#\" id=\"like-" + ji.JournalId + "\">{resx:like}</a>"; } } ctl.CommentArea = GetCommentAreaHTML(ji.JournalId, comments); ji.TimeFrame = Common.Utilities.DateUtils.CalculateDateForDisplay(ji.DateCreated); ji.DateCreated = CurrentUser.LocalTime(ji.DateCreated); if (ji.Summary != null) { ji.Summary = ji.Summary.Replace("\n", "<br />"); } if (ji.Body != null) { ji.Body = ji.Body.Replace(Environment.NewLine, "<br />"); } Components.JournalItemTokenReplace tokenReplace = new Components.JournalItemTokenReplace(ji, ctl); string tmp = tokenReplace.ReplaceJournalItemTokens(rowTemplate); tmp = tmp.Replace("<br>", "<br />"); sb.Append("<div class=\"journalrow\" id=\"jid-" + ji.JournalId + "\">"); if (isAdmin || CurrentUser.UserID == ji.UserId) { sb.Append("<div class=\"minidel\" onclick=\"journalDelete(this);\"></div>"); } sb.Append(tmp); sb.Append("</div>"); } return Utilities.LocalizeControl(sb.ToString()); }
public string GetList(int currentIndex, int rows) { if (CurrentUser.UserID > 0) { isAdmin = CurrentUser.IsInRole(PortalSettings.AdministratorRoleName); } var jc = InternalJournalController.Instance; var sb = new StringBuilder(); string statusTemplate = Services.Localization.Localization.GetString("journal_status", resxPath); string linkTemplate = Services.Localization.Localization.GetString("journal_link", resxPath); string photoTemplate = Services.Localization.Localization.GetString("journal_photo", resxPath); string fileTemplate = Services.Localization.Localization.GetString("journal_file", resxPath); string rowTemplate = string.Empty; statusTemplate = Regex.Replace(statusTemplate, "\\[BaseUrl\\]", url, RegexOptions.IgnoreCase); linkTemplate = Regex.Replace(linkTemplate, "\\[BaseUrl\\]", url, RegexOptions.IgnoreCase); photoTemplate = Regex.Replace(photoTemplate, "\\[BaseUrl\\]", url, RegexOptions.IgnoreCase); fileTemplate = Regex.Replace(fileTemplate, "\\[BaseUrl\\]", url, RegexOptions.IgnoreCase); string Comment = Localization.GetString("comment", resxPath); string Comments = Localization.GetString("Comments", resxPath); IList <JournalItem> journalList; if (ProfileId > 0) { journalList = jc.GetJournalItemsByProfile(PortalSettings.PortalId, ModuleId, CurrentUser.UserID, ProfileId, currentIndex, rows); } else if (SocialGroupId > 0) { journalList = jc.GetJournalItemsByGroup(PortalSettings.PortalId, ModuleId, CurrentUser.UserID, SocialGroupId, currentIndex, rows); } else { journalList = jc.GetJournalItems(PortalSettings.PortalId, ModuleId, CurrentUser.UserID, currentIndex, rows); } string journalIds = ""; foreach (JournalItem ji in journalList) { journalIds += ji.JournalId.ToString() + ';'; } IList <CommentInfo> comments = jc.GetCommentsByJournalIds(journalIds); foreach (JournalItem ji in journalList) { string pattern = "{CanComment}(.*?){/CanComment}"; string replacement = string.Empty; if (CurrentUser.UserID > 0 && SocialGroupId <= 0) { replacement = "$1"; } if (CurrentUser.UserID > 0 && ji.SocialGroupId > 0) { if (CurrentUser.IsInRole(ji.JournalOwner.Name)) { replacement = "$1"; } else { replacement = string.Empty; } } if (ji.JournalType == "status") { rowTemplate = statusTemplate; rowTemplate = Regex.Replace(rowTemplate, pattern, replacement, RegexOptions.IgnoreCase); } else if (ji.JournalType == "link") { rowTemplate = linkTemplate; rowTemplate = Regex.Replace(rowTemplate, pattern, replacement, RegexOptions.IgnoreCase); } else if (ji.JournalType == "photo") { rowTemplate = photoTemplate; rowTemplate = Regex.Replace(rowTemplate, pattern, replacement, RegexOptions.IgnoreCase); } else if (ji.JournalType == "file") { rowTemplate = fileTemplate; rowTemplate = Regex.Replace(rowTemplate, pattern, replacement, RegexOptions.IgnoreCase); } else { rowTemplate = GetJournalTemplate(ji.JournalType, ji); } Components.JournalControl ctl = new Components.JournalControl(); bool isLiked = false; ctl.LikeList = GetLikeListHTML(ji, ref isLiked); ctl.LikeLink = String.Empty; ctl.CommentLink = String.Empty; ctl.AuthorNameLink = "<a href=\"" + DotNetNuke.Common.Globals.NavigateURL(PortalSettings.UserTabId, string.Empty, new String[] { "userId=" + ji.JournalAuthor.Id.ToString() }) + "\">" + ji.JournalAuthor.Name + "</a>"; if (CurrentUser.UserID > 0) { ctl.CommentLink = "<a href=\"#\" id=\"cmtbtn-" + ji.JournalId + "\">" + Comment + "</a>"; if (isLiked) { ctl.LikeLink = "<a href=\"#\" id=\"like-" + ji.JournalId + "\">{resx:unlike}</a>"; } else { ctl.LikeLink = "<a href=\"#\" id=\"like-" + ji.JournalId + "\">{resx:like}</a>"; } } ctl.CommentArea = GetCommentAreaHTML(ji.JournalId, comments); ji.TimeFrame = Common.Utilities.DateUtils.CalculateDateForDisplay(ji.DateCreated); ji.DateCreated = CurrentUser.LocalTime(ji.DateCreated); if (ji.Summary != null) { ji.Summary = ji.Summary.Replace("\n", "<br />"); } if (ji.Body != null) { ji.Body = ji.Body.Replace(Environment.NewLine, "<br />"); } Components.JournalItemTokenReplace tokenReplace = new Components.JournalItemTokenReplace(ji, ctl); string tmp = tokenReplace.ReplaceJournalItemTokens(rowTemplate); tmp = tmp.Replace("<br>", "<br />"); sb.Append("<div class=\"journalrow\" id=\"jid-" + ji.JournalId + "\">"); if (isAdmin || CurrentUser.UserID == ji.UserId) { sb.Append("<div class=\"minidel\" onclick=\"journalDelete(this);\"></div>"); } sb.Append(tmp); sb.Append("</div>"); } return(Utilities.LocalizeControl(sb.ToString())); }