internal string GetCommentRow(CommentInfo comment) { var sb = new StringBuilder(); string pic = string.Format(Globals.UserProfilePicFormattedUrl(), comment.UserId, 32, 32); sb.AppendFormat("<li id=\"cmt-{0}\">", comment.CommentId); if (comment.UserId == CurrentUser.UserID || isAdmin) { sb.Append("<div class=\"miniclose\"></div>"); } sb.AppendFormat("<img src=\"{0}\" />", pic); sb.Append("<p>"); string userUrl = Globals.NavigateURL(PortalSettings.UserTabId, string.Empty, new[] { "userId=" + comment.UserId }); sb.AppendFormat("<a href=\"{1}\">{0}</a>", comment.DisplayName, userUrl); sb.Append(comment.Comment.Replace("\n", "<br />")); var timeFrame = DateUtils.CalculateDateForDisplay(comment.DateCreated); comment.DateCreated = CurrentUser.LocalTime(comment.DateCreated); sb.AppendFormat("<abbr title=\"{0}\">{1}</abbr>", comment.DateCreated, timeFrame); sb.Append("</p>"); sb.Append("</li>"); return(sb.ToString()); }
protected void GetSearchIndexStatistics(object sender, EventArgs e) { var searchStatistics = InternalSearchController.Instance.GetSearchStatistics(); pnlSearchGetMoreButton.Visible = false; pnlSearchStatistics.Visible = true; lblSearchIndexDbSize.Text = ((searchStatistics.IndexDbSize / 1024f) / 1024f).ToString("N") + " MB"; lblSearchIndexLastModifedOn.Text = DateUtils.CalculateDateForDisplay(searchStatistics.LastModifiedOn); lblSearchIndexTotalActiveDocuments.Text = searchStatistics.TotalActiveDocuments.ToString(CultureInfo.InvariantCulture); lblSearchIndexTotalDeletedDocuments.Text = searchStatistics.TotalDeletedDocuments.ToString(CultureInfo.InvariantCulture); }
internal string GetCommentRow(JournalItem journal, CommentInfo comment) { var sb = new StringBuilder(); string pic = UserController.Instance.GetUserProfilePictureUrl(comment.UserId, 32, 32); sb.AppendFormat("<li id=\"cmt-{0}\">", comment.CommentId); if (comment.UserId == this.CurrentUser.UserID || journal.UserId == this.CurrentUser.UserID || this.isAdmin) { sb.Append("<div class=\"miniclose\"></div>"); } sb.AppendFormat("<img src=\"{0}\" />", pic); sb.Append("<p>"); string userUrl = this.NavigationManager.NavigateURL(this.PortalSettings.UserTabId, string.Empty, new[] { "userId=" + comment.UserId }); sb.AppendFormat("<a href=\"{1}\">{0}</a>", comment.DisplayName, userUrl); if (comment.CommentXML != null && comment.CommentXML.SelectSingleNode("/root/comment") != null) { string text; if (CdataRegex.IsMatch(comment.CommentXML.SelectSingleNode("/root/comment").InnerText)) { var match = CdataRegex.Match(comment.CommentXML.SelectSingleNode("/root/comment").InnerText); text = match.Groups["text"].Value; } else { text = comment.CommentXML.SelectSingleNode("/root/comment").InnerText; } sb.Append(text.Replace("\n", "<br />")); } else { sb.Append(comment.Comment.Replace("\n", "<br />")); } var timeFrame = DateUtils.CalculateDateForDisplay(comment.DateCreated); comment.DateCreated = this.CurrentUser.LocalTime(comment.DateCreated); sb.AppendFormat("<abbr title=\"{0}\">{1}</abbr>", comment.DateCreated, timeFrame); sb.Append("</p>"); sb.Append("</li>"); return(sb.ToString()); }
internal string GetCommentRow(JournalItem journal, CommentInfo comment) { var sb = new StringBuilder(); string pic = string.Format(Globals.UserProfilePicFormattedUrl(), comment.UserId, 32, 32); sb.AppendFormat("<li id=\"cmt-{0}\">", comment.CommentId); if (comment.UserId == CurrentUser.UserID || journal.UserId == CurrentUser.UserID || isAdmin) { sb.Append("<div class=\"miniclose\"></div>"); } sb.AppendFormat("<img src=\"{0}\" />", pic); sb.Append("<p>"); string userUrl = Globals.NavigateURL(PortalSettings.UserTabId, string.Empty, new[] { "userId=" + comment.UserId }); sb.AppendFormat("<a href=\"{1}\">{0}</a>", comment.DisplayName, userUrl); if (comment.CommentXML != null && comment.CommentXML.SelectSingleNode("/root/comment") != null) { string text; var regex = new Regex(@"\<\!\[CDATA\[(?<text>[^\]]*)\]\]\>"); if (regex.IsMatch(comment.CommentXML.SelectSingleNode("/root/comment").InnerText)) { var match = regex.Match(comment.CommentXML.SelectSingleNode("/root/comment").InnerText); text = match.Groups["text"].Value; } else { text = comment.CommentXML.SelectSingleNode("/root/comment").InnerText; } sb.Append(text.Replace("\n", "<br />")); } else { sb.Append(comment.Comment.Replace("\n", "<br />")); } var timeFrame = DateUtils.CalculateDateForDisplay(comment.DateCreated); comment.DateCreated = CurrentUser.LocalTime(comment.DateCreated); sb.AppendFormat("<abbr title=\"{0}\">{1}</abbr>", comment.DateCreated, timeFrame); sb.Append("</p>"); sb.Append("</li>"); return(sb.ToString()); }
internal static ActionResult GetBasicSearchSettings(dynamic AvailableAnalyzers) { ActionResult actionResult = new ActionResult(); try { dynamic settings = new ExpandoObject(); settings.MinWordLength = HostController.Instance.GetInteger("Search_MinKeyWordLength", 3); settings.MaxWordLength = HostController.Instance.GetInteger("Search_MaxKeyWordLength", 255); settings.AllowLeadingWildcard = HostController.Instance.GetString("Search_AllowLeadingWildcard", "N") == "Y"; settings.SearchCustomAnalyzer = HostController.Instance.GetString("Search_CustomAnalyzer", string.Empty); settings.TitleBoost = HostController.Instance.GetInteger(SearchTitleBoostSetting, DefaultSearchTitleBoost); settings.TagBoost = HostController.Instance.GetInteger(SearchTagBoostSetting, DefaultSearchTagBoost); settings.ContentBoost = HostController.Instance.GetInteger(SearchContentBoostSetting, DefaultSearchContentBoost); settings.DescriptionBoost = HostController.Instance.GetInteger(SearchDescriptionBoostSetting, DefaultSearchDescriptionBoost); settings.AuthorBoost = HostController.Instance.GetInteger(SearchAuthorBoostSetting, DefaultSearchAuthorBoost); settings.SearchIndexPath = Path.Combine(Globals.ApplicationMapPath, HostController.Instance.GetString("SearchFolder", @"App_Data\Search")); SearchStatistics searchStatistics = GetSearchStatistics(); if (searchStatistics != null) { settings.SearchIndexDbSize = ((searchStatistics.IndexDbSize / 1024f) / 1024f).ToString("N") + " MB"; settings.SearchIndexLastModifedOn = DateUtils.CalculateDateForDisplay(searchStatistics.LastModifiedOn); settings.SearchIndexTotalActiveDocuments = searchStatistics.TotalActiveDocuments.ToString(CultureInfo.InvariantCulture); settings.SearchIndexTotalDeletedDocuments = searchStatistics.TotalDeletedDocuments.ToString(CultureInfo.InvariantCulture); } SiteSettingsController _controller = new SiteSettingsController(); var response = new { Success = true, Settings = settings, SearchCustomAnalyzers = AvailableAnalyzers }; actionResult.Data = settings; } catch (Exception exc) { actionResult.AddError("HttpStatusCode.InternalServerError", exc.Message); } return(actionResult); }
public string GetList(int currentIndex, int rows) { if (CurrentUser.UserID > 0) { isAdmin = CurrentUser.IsInRole(PortalSettings.AdministratorRoleName); } isUnverifiedUser = !CurrentUser.IsSuperUser && CurrentUser.IsInRole("Unverified Users"); var journalControllerInternal = InternalJournalController.Instance; var sb = new StringBuilder(); string statusTemplate = Localization.GetString("journal_status", ResxPath); string linkTemplate = Localization.GetString("journal_link", ResxPath); string photoTemplate = Localization.GetString("journal_photo", ResxPath); string fileTemplate = Localization.GetString("journal_file", ResxPath); 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); IList <JournalItem> journalList; if (ProfileId > 0) { journalList = journalControllerInternal.GetJournalItemsByProfile(OwnerPortalId, ModuleId, CurrentUser.UserID, ProfileId, currentIndex, rows); } else if (SocialGroupId > 0) { journalList = journalControllerInternal.GetJournalItemsByGroup(OwnerPortalId, ModuleId, CurrentUser.UserID, SocialGroupId, currentIndex, rows); } else { journalList = journalControllerInternal.GetJournalItems(OwnerPortalId, ModuleId, CurrentUser.UserID, currentIndex, rows); } var journalIds = journalList.Select(ji => ji.JournalId).ToList(); IList <CommentInfo> comments = JournalController.Instance.GetCommentsByJournalIds(journalIds); foreach (JournalItem ji in journalList) { const string pattern = "{CanComment}(.*?){/CanComment}"; string replacement = GetStringReplacement(ji); string rowTemplate; 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); } var ctl = new JournalControl(); bool isLiked = false; ctl.LikeList = GetLikeListHTML(ji, ref isLiked); ctl.LikeLink = String.Empty; ctl.CommentLink = String.Empty; ctl.AuthorNameLink = "<a href=\"" + Globals.NavigateURL(PortalSettings.UserTabId, string.Empty, new[] { "userId=" + ji.JournalAuthor.Id }) + "\">" + ji.JournalAuthor.Name + "</a>"; if (CurrentUser.UserID > 0 && !isUnverifiedUser) { if (!ji.CommentsDisabled) { 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, comments); ji.TimeFrame = 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 />"); } var tokenReplace = new 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 || (ProfileId > Null.NullInteger && CurrentUser.UserID == ProfileId)) { sb.Append("<div class=\"minidel\" onclick=\"journalDelete(this);\"></div>"); } sb.Append(tmp); sb.Append("</div>"); } return(Utilities.LocalizeControl(sb.ToString())); }