From 04027535bacf77ca83c307160556e75c5b0d50b6 Mon Sep 17 00:00:00 2001 From: Mostafa Moafi Date: Mon, 13 May 2024 11:51:01 +0330 Subject: [PATCH 1/3] Add MaximumPageSize const property for limit page size --- .../InternalServices/SearchServiceController.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/DNN Platform/DotNetNuke.Web/InternalServices/SearchServiceController.cs b/DNN Platform/DotNetNuke.Web/InternalServices/SearchServiceController.cs index 1d738dbb1a9..a38b86e8c4d 100644 --- a/DNN Platform/DotNetNuke.Web/InternalServices/SearchServiceController.cs +++ b/DNN Platform/DotNetNuke.Web/InternalServices/SearchServiceController.cs @@ -37,6 +37,7 @@ public class SearchServiceController : DnnApiController private const string ModuleTitleCacheKey = "SearchModuleTabTitle_{0}"; private const CacheItemPriority ModuleTitleCachePriority = CacheItemPriority.Normal; private const int ModuleTitleCacheTimeOut = 20; + private const int MaximumPageSize = 100; private static readonly Regex GroupedBasicViewRegex = new Regex("userid(/|\\|=)(\\d+)", RegexOptions.IgnoreCase | RegexOptions.Compiled); @@ -132,6 +133,11 @@ public HttpResponseMessage Search(string search, string culture, int pageIndex, if (portalIds.Any() && searchTypeIds.Any() && (!string.IsNullOrEmpty(cleanedKeywords) || tags.Any())) { + if (pageSize > MaximumPageSize) + { + pageSize = MaximumPageSize; + } + var query = new SearchQuery { KeyWords = cleanedKeywords, From b14ab511270575f889e513340514c59fdb68ac92 Mon Sep 17 00:00:00 2001 From: Mostafa Moafi Date: Thu, 16 May 2024 11:37:05 +0330 Subject: [PATCH 2/3] Add App_LocalResources for new field (MaxResultPerPage) --- .../App_LocalResources/SiteSettings.resx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Dnn.AdminExperience/Dnn.PersonaBar.Extensions/admin/personaBar/Dnn.SiteSettings/App_LocalResources/SiteSettings.resx b/Dnn.AdminExperience/Dnn.PersonaBar.Extensions/admin/personaBar/Dnn.SiteSettings/App_LocalResources/SiteSettings.resx index 75c8a6534c8..529b9880305 100644 --- a/Dnn.AdminExperience/Dnn.PersonaBar.Extensions/admin/personaBar/Dnn.SiteSettings/App_LocalResources/SiteSettings.resx +++ b/Dnn.AdminExperience/Dnn.PersonaBar.Extensions/admin/personaBar/Dnn.SiteSettings/App_LocalResources/SiteSettings.resx @@ -1500,4 +1500,13 @@ Show Quick Module Add Menu - + + Maximum Result Per Page + + + Maximum result per page in search service + + + Maximum result per page is required. Integer must be greater than 0. + + \ No newline at end of file From 907ff3f250bf1364fcaffcc2534de297e799f5f8 Mon Sep 17 00:00:00 2001 From: Mostafa Moafi Date: Thu, 16 May 2024 12:30:15 +0330 Subject: [PATCH 3/3] Add new field in persona bar for set maximum result per page --- .../SearchServiceController.cs | 8 +- .../components/basicSearchSettings/index.jsx | 142 ++++++++++++------ .../UpdateBasicSearchSettingsRequest.cs | 6 +- .../Services/SiteSettingsController.cs | 14 ++ 4 files changed, 119 insertions(+), 51 deletions(-) diff --git a/DNN Platform/DotNetNuke.Web/InternalServices/SearchServiceController.cs b/DNN Platform/DotNetNuke.Web/InternalServices/SearchServiceController.cs index a38b86e8c4d..f07fb81e33e 100644 --- a/DNN Platform/DotNetNuke.Web/InternalServices/SearchServiceController.cs +++ b/DNN Platform/DotNetNuke.Web/InternalServices/SearchServiceController.cs @@ -18,6 +18,7 @@ namespace DotNetNuke.Web.InternalServices using DotNetNuke.Common; using DotNetNuke.Common.Utilities; using DotNetNuke.Data; + using DotNetNuke.Entities.Controllers; using DotNetNuke.Entities.Modules; using DotNetNuke.Entities.Modules.Definitions; using DotNetNuke.Entities.Tabs; @@ -37,8 +38,6 @@ public class SearchServiceController : DnnApiController private const string ModuleTitleCacheKey = "SearchModuleTabTitle_{0}"; private const CacheItemPriority ModuleTitleCachePriority = CacheItemPriority.Normal; private const int ModuleTitleCacheTimeOut = 20; - private const int MaximumPageSize = 100; - private static readonly Regex GroupedBasicViewRegex = new Regex("userid(/|\\|=)(\\d+)", RegexOptions.IgnoreCase | RegexOptions.Compiled); private int htmlModuleDefitionId; @@ -126,6 +125,7 @@ public HttpResponseMessage Search(string search, string culture, int pageIndex, var moduleDefids = GetSearchModuleDefIds(settings, contentSources); var portalIds = this.GetSearchPortalIds(settings, -1); var userSearchTypeId = SearchHelper.Instance.GetSearchTypeByName("user").SearchTypeId; + var maximumPageSize = HostController.Instance.GetInteger("Search_MaxResultPerPage", 100); var more = false; var totalHits = 0; @@ -133,9 +133,9 @@ public HttpResponseMessage Search(string search, string culture, int pageIndex, if (portalIds.Any() && searchTypeIds.Any() && (!string.IsNullOrEmpty(cleanedKeywords) || tags.Any())) { - if (pageSize > MaximumPageSize) + if (pageSize > maximumPageSize) { - pageSize = MaximumPageSize; + pageSize = maximumPageSize; } var query = new SearchQuery diff --git a/Dnn.AdminExperience/ClientSide/SiteSettings.Web/src/components/basicSearchSettings/index.jsx b/Dnn.AdminExperience/ClientSide/SiteSettings.Web/src/components/basicSearchSettings/index.jsx index 46b711a329e..796c26cfc2f 100644 --- a/Dnn.AdminExperience/ClientSide/SiteSettings.Web/src/components/basicSearchSettings/index.jsx +++ b/Dnn.AdminExperience/ClientSide/SiteSettings.Web/src/components/basicSearchSettings/index.jsx @@ -21,7 +21,8 @@ class BasicSearchSettingsPanelBody extends Component { basicSearchSettings: undefined, error: { minlength: false, - maxlength: false + maxlength: false, + maxresult: false }, triedToSubmit: false }; @@ -72,6 +73,13 @@ class BasicSearchSettingsPanelBody extends Component { error["minlength"] = false; } + if (!re.test(basicSearchSettings[key]) && key === "MaxResultPerPage") { + error["maxresult"] = true; + } + else if (re.test(basicSearchSettings[key]) && key === "MaxResultPerPage") { + error["maxresult"] = false; + } + if (key === "MaxWordLength" && (!re.test(basicSearchSettings[key]) || parseInt(basicSearchSettings["MinWordLength"]) >= parseInt(basicSearchSettings["MaxWordLength"]))) { error["maxlength"] = true; @@ -153,50 +161,94 @@ class BasicSearchSettingsPanelBody extends Component { const {state} = this; if (this.isHost()) { if (state.basicSearchSettings) { - const columnOne =
- - - - -
; + const columnOne = ( +
+ + + + + + +
+ ); const columnTwo =