diff --git a/src/Orchard.Core.Tests/App.config b/src/Orchard.Core.Tests/App.config index 2927415cd..17bd79582 100644 --- a/src/Orchard.Core.Tests/App.config +++ b/src/Orchard.Core.Tests/App.config @@ -26,6 +26,22 @@ + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Specs/App.Config b/src/Orchard.Specs/App.Config index 2805ca3df..f12c4cd71 100644 --- a/src/Orchard.Specs/App.Config +++ b/src/Orchard.Specs/App.Config @@ -39,16 +39,28 @@ - - + + + + + + - + - - + + + + + + + + + + diff --git a/src/Orchard.Tests.Modules/App.config b/src/Orchard.Tests.Modules/App.config index 5b5fb8eb1..e61f1c359 100644 --- a/src/Orchard.Tests.Modules/App.config +++ b/src/Orchard.Tests.Modules/App.config @@ -42,6 +42,22 @@ + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web.Tests/app.config b/src/Orchard.Web.Tests/app.config index 6b5c5dcfb..b072f5c42 100644 --- a/src/Orchard.Web.Tests/app.config +++ b/src/Orchard.Web.Tests/app.config @@ -31,16 +31,28 @@ - - + + + + + + - + - - + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/Markdown/Markdown.csproj b/src/Orchard.Web/Modules/Markdown/Markdown.csproj index 21462fb86..d5a4305cc 100644 --- a/src/Orchard.Web/Modules/Markdown/Markdown.csproj +++ b/src/Orchard.Web/Modules/Markdown/Markdown.csproj @@ -62,20 +62,20 @@ ..\..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll - - ..\..\..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + ..\..\..\packages\System.Buffers.4.6.0\lib\net462\System.Buffers.dll - - ..\..\..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll + + ..\..\..\packages\System.Memory.4.6.0\lib\net462\System.Memory.dll - - ..\..\..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + ..\..\..\packages\System.Numerics.Vectors.4.6.0\lib\net462\System.Numerics.Vectors.dll - - ..\..\..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + ..\..\..\packages\System.Runtime.CompilerServices.Unsafe.6.1.0\lib\net462\System.Runtime.CompilerServices.Unsafe.dll @@ -231,4 +231,4 @@ - + \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Markdown/Web.config b/src/Orchard.Web/Modules/Markdown/Web.config index 021881754..76431a965 100644 --- a/src/Orchard.Web/Modules/Markdown/Web.config +++ b/src/Orchard.Web/Modules/Markdown/Web.config @@ -68,6 +68,22 @@ + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/Markdown/packages.config b/src/Orchard.Web/Modules/Markdown/packages.config index e11111c39..1c515e289 100644 --- a/src/Orchard.Web/Modules/Markdown/packages.config +++ b/src/Orchard.Web/Modules/Markdown/packages.config @@ -6,8 +6,8 @@ - - - - - + + + + + \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Blogs/Web.config b/src/Orchard.Web/Modules/Orchard.Blogs/Web.config index 9cdad18dd..c44f787fe 100644 --- a/src/Orchard.Web/Modules/Orchard.Blogs/Web.config +++ b/src/Orchard.Web/Modules/Orchard.Blogs/Web.config @@ -68,6 +68,22 @@ + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/Orchard.Dashboards/Web.config b/src/Orchard.Web/Modules/Orchard.Dashboards/Web.config index 7eeb910d7..896fae396 100644 --- a/src/Orchard.Web/Modules/Orchard.Dashboards/Web.config +++ b/src/Orchard.Web/Modules/Orchard.Dashboards/Web.config @@ -69,6 +69,22 @@ + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/Orchard.DesignerTools/Web.config b/src/Orchard.Web/Modules/Orchard.DesignerTools/Web.config index 24e0acd0f..64414d751 100644 --- a/src/Orchard.Web/Modules/Orchard.DesignerTools/Web.config +++ b/src/Orchard.Web/Modules/Orchard.DesignerTools/Web.config @@ -69,6 +69,22 @@ + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/Orchard.DynamicForms/Web.config b/src/Orchard.Web/Modules/Orchard.DynamicForms/Web.config index 9760b6016..f92a5f57d 100644 --- a/src/Orchard.Web/Modules/Orchard.DynamicForms/Web.config +++ b/src/Orchard.Web/Modules/Orchard.DynamicForms/Web.config @@ -71,6 +71,22 @@ + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/Orchard.Email/Orchard.Email.csproj b/src/Orchard.Web/Modules/Orchard.Email/Orchard.Email.csproj index 5b4f92e9f..2a3ccd5ad 100644 --- a/src/Orchard.Web/Modules/Orchard.Email/Orchard.Email.csproj +++ b/src/Orchard.Web/Modules/Orchard.Email/Orchard.Email.csproj @@ -55,8 +55,11 @@ ..\..\..\packages\Portable.BouncyCastle.1.9.0\lib\net40\BouncyCastle.Crypto.dll - - ..\..\..\packages\MailKit.3.1.1\lib\net48\MailKit.dll + + ..\..\..\packages\BouncyCastle.Cryptography.2.5.0\lib\net461\BouncyCastle.Cryptography.dll + + + ..\..\..\packages\MailKit.4.9.0\lib\net48\MailKit.dll ..\..\..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.4.1.0\lib\net472\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll @@ -65,23 +68,42 @@ ..\..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll - - ..\..\..\packages\MimeKit.3.1.1\lib\net48\MimeKit.dll + + ..\..\..\packages\MimeKit.4.9.0\lib\net48\MimeKit.dll ..\..\..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll - - ..\..\..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + ..\..\..\packages\System.Buffers.4.6.0\lib\net462\System.Buffers.dll False + + ..\..\..\packages\System.Formats.Asn1.8.0.1\lib\net462\System.Formats.Asn1.dll + + + ..\..\..\packages\System.Memory.4.6.0\lib\net462\System.Memory.dll + + + + ..\..\..\packages\System.Numerics.Vectors.4.6.0\lib\net462\System.Numerics.Vectors.dll + + + ..\..\..\packages\System.Runtime.CompilerServices.Unsafe.6.1.0\lib\net462\System.Runtime.CompilerServices.Unsafe.dll + + + ..\..\..\packages\System.Threading.Tasks.Extensions.4.6.0\lib\net462\System.Threading.Tasks.Extensions.dll + + + ..\..\..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll + diff --git a/src/Orchard.Web/Modules/Orchard.Email/Web.config b/src/Orchard.Web/Modules/Orchard.Email/Web.config index dea324b0a..54cac3cec 100644 --- a/src/Orchard.Web/Modules/Orchard.Email/Web.config +++ b/src/Orchard.Web/Modules/Orchard.Email/Web.config @@ -69,6 +69,18 @@ + + + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/Orchard.Email/packages.config b/src/Orchard.Web/Modules/Orchard.Email/packages.config index 58191e638..0589304a6 100644 --- a/src/Orchard.Web/Modules/Orchard.Email/packages.config +++ b/src/Orchard.Web/Modules/Orchard.Email/packages.config @@ -1,13 +1,20 @@  - + + - + - + + + + + + + \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Web.config b/src/Orchard.Web/Modules/Orchard.Layouts/Web.config index ee7f9fc2c..98f1bfd3e 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Web.config +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Web.config @@ -81,6 +81,22 @@ + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/Orchard.Projections/Controllers/AdminController.cs b/src/Orchard.Web/Modules/Orchard.Projections/Controllers/AdminController.cs index e5dfb543e..1487d76f8 100644 --- a/src/Orchard.Web/Modules/Orchard.Projections/Controllers/AdminController.cs +++ b/src/Orchard.Web/Modules/Orchard.Projections/Controllers/AdminController.cs @@ -1,9 +1,13 @@ +using System; using System.Collections.Generic; using System.Linq; using System.Web.Mvc; using System.Web.Routing; +using Orchard.ContentManagement; using Orchard.Core.Title.Models; +using Orchard.DisplayManagement; using Orchard.Forms.Services; +using Orchard.Localization; using Orchard.Mvc; using Orchard.Projections.Descriptors.Filter; using Orchard.Projections.Descriptors.Layout; @@ -11,13 +15,9 @@ using Orchard.Projections.Descriptors.SortCriterion; using Orchard.Projections.Models; using Orchard.Projections.Services; using Orchard.Projections.ViewModels; -using Orchard.ContentManagement; -using Orchard.DisplayManagement; -using Orchard.Localization; -using Orchard.UI.Notify; -using System; using Orchard.Settings; using Orchard.UI.Navigation; +using Orchard.UI.Notify; namespace Orchard.Projections.Controllers { [ValidateInput(false)] @@ -84,7 +84,7 @@ namespace Orchard.Projections.Controllers { var model = new AdminIndexViewModel { Queries = results.Select(x => new QueryEntry { - Query = x.As().Record, + Query = x.As().Record, QueryId = x.Id, Name = x.As().Name }).ToList(), @@ -158,16 +158,21 @@ namespace Orchard.Projections.Controllers { Category = f.Category, Type = f.Type, FilterRecordId = filter.Id, - DisplayText = String.IsNullOrWhiteSpace(filter.Description) ? f.Display(new FilterContext {State = FormParametersHelper.ToDynamic(filter.State)}).Text : filter.Description + DisplayText = String.IsNullOrWhiteSpace(filter.Description) ? f.Display(new FilterContext { State = FormParametersHelper.ToDynamic(filter.State) }).Text : filter.Description }); } } - filterGroupEntries.Add( new FilterGroupEntry { Id = group.Id, Filters = filterEntries } ); + filterGroupEntries.Add(new FilterGroupEntry { Id = group.Id, Filters = filterEntries }); } viewModel.FilterGroups = filterGroupEntries; + if (viewModel.FilterGroups.Any(group => group.Filters.Count() == 0)) { + _services.Notifier.Warning( + T("This Query has at least one empty filter group, which will cause all content items to be returned, unless the Projection using this Query limits the number of content items displayed.")); + } + #endregion #region Load Sort criterias @@ -185,7 +190,7 @@ namespace Orchard.Projections.Controllers { Category = f.Category, Type = f.Type, SortCriterionRecordId = sortCriterion.Id, - DisplayText = String.IsNullOrWhiteSpace(sortCriterion.Description) ? f.Display(new SortCriterionContext { State = FormParametersHelper.ToDynamic(sortCriterion.State) }).Text : sortCriterion.Description + DisplayText = String.IsNullOrWhiteSpace(sortCriterion.Description) ? f.Display(new SortCriterionContext { State = FormParametersHelper.ToDynamic(sortCriterion.State) }).Text : sortCriterion.Description }); } } diff --git a/src/Orchard.Web/Modules/Orchard.Projections/Drivers/ProjectionPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Projections/Drivers/ProjectionPartDriver.cs index e23f08f22..4aa01fb7d 100644 --- a/src/Orchard.Web/Modules/Orchard.Projections/Drivers/ProjectionPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Projections/Drivers/ProjectionPartDriver.cs @@ -20,10 +20,12 @@ using Orchard.Projections.Settings; using Orchard.Projections.ViewModels; using Orchard.Tokens; using Orchard.UI.Navigation; +using Orchard.UI.Notify; using Orchard.Utility.Extensions; namespace Orchard.Projections.Drivers { public class ProjectionPartDriver : ContentPartDriver { + private readonly IOrchardServices _orchardServices; private readonly IRepository _queryRepository; private readonly IProjectionManager _projectionManager; private readonly IFeedManager _feedManager; @@ -33,25 +35,25 @@ namespace Orchard.Projections.Drivers { private const string TemplateName = "Parts/ProjectionPart"; public ProjectionPartDriver( - IOrchardServices services, + IOrchardServices orchardServices, IRepository queryRepository, IProjectionManager projectionManager, IFeedManager feedManager, ITokenizer tokenizer, IDisplayHelperFactory displayHelperFactory, IWorkContextAccessor workContextAccessor) { + _orchardServices = orchardServices; _queryRepository = queryRepository; _projectionManager = projectionManager; _feedManager = feedManager; _tokenizer = tokenizer; _displayHelperFactory = displayHelperFactory; _workContextAccessor = workContextAccessor; + T = NullLocalizer.Instance; - Services = services; } public Localizer T { get; set; } - public IOrchardServices Services { get; set; } protected override string Prefix { get { return "ProjectionPart"; } } @@ -59,7 +61,7 @@ namespace Orchard.Projections.Drivers { var query = part.Record.QueryPartRecord; // retrieving paging parameters - var queryString = Services.WorkContext.HttpContext.Request.QueryString; + var queryString = _orchardServices.WorkContext.HttpContext.Request.QueryString; var pageKey = String.IsNullOrWhiteSpace(part.Record.PagerSuffix) ? "page" : "page-" + part.Record.PagerSuffix; var page = 0; @@ -81,16 +83,14 @@ namespace Orchard.Projections.Drivers { var pageSizeKey = "pageSize" + part.Record.PagerSuffix; if (queryString.AllKeys.Contains(pageSizeKey)) { - int qsPageSize; - - if (Int32.TryParse(queryString[pageSizeKey], out qsPageSize)) { + if (Int32.TryParse(queryString[pageSizeKey], out int qsPageSize)) { if (part.Record.MaxItems == 0 || qsPageSize <= part.Record.MaxItems) { pageSize = qsPageSize; } } } - var pager = new Pager(Services.WorkContext.CurrentSite, page, pageSize); + var pager = new Pager(_orchardServices.WorkContext.CurrentSite, page, pageSize); var pagerShape = shapeHelper.Pager(pager) .ContentPart(part) @@ -107,7 +107,7 @@ namespace Orchard.Projections.Drivers { ContentShape("Parts_ProjectionPart_List", shape => { // generates a link to the RSS feed for this term - var metaData = Services.ContentManager.GetItemMetadata(part.ContentItem); + var metaData = _orchardServices.ContentManager.GetItemMetadata(part.ContentItem); _feedManager.Register(metaData.DisplayText, "rss", new RouteValueDictionary { { "projection", part.Id } }); // execute the query @@ -130,8 +130,8 @@ namespace Orchard.Projections.Drivers { // renders in a standard List shape if no specific layout could be found if (layoutDescriptor == null) { - var list = Services.New.List(); - var contentShapes = contentItems.Select(item => Services.ContentManager.BuildDisplay(item, "Summary")); + var list = _orchardServices.New.List(); + var contentShapes = contentItems.Select(item => _orchardServices.ContentManager.BuildDisplay(item, "Summary")); list.AddRange(contentShapes); return list; @@ -143,7 +143,7 @@ namespace Orchard.Projections.Drivers { var layoutComponents = contentItems.Select( contentItem => { - var contentItemMetadata = Services.ContentManager.GetItemMetadata(contentItem); + var contentItemMetadata = _orchardServices.ContentManager.GetItemMetadata(contentItem); var propertyDescriptors = fieldDescriptors.Select( d => { @@ -156,9 +156,9 @@ namespace Orchard.Projections.Drivers { }); // apply all settings to the field content, wrapping it in a FieldWrapper shape - var properties = Services.New.Properties( + var properties = _orchardServices.New.Properties( Items: propertyDescriptors.Select( - pd => Services.New.PropertyWrapper( + pd => _orchardServices.New.PropertyWrapper( Item: pd.Shape, Property: pd.Property, ContentItem: contentItem, @@ -199,14 +199,14 @@ namespace Orchard.Projections.Drivers { return key; }).Select(x => new { Key = x.Key, Components = x }); - var list = Services.New.List(); + var list = _orchardServices.New.List(); foreach (var group in groups) { var localResult = layoutDescriptor.Render(renderLayoutContext, group.Components); // add the Context to the shape localResult.Context(renderLayoutContext); - list.Add(Services.New.LayoutGroup(Key: new MvcHtmlString(group.Key), List: localResult)); + list.Add(_orchardServices.New.LayoutGroup(Key: new MvcHtmlString(group.Key), List: localResult)); } return list; @@ -223,81 +223,80 @@ namespace Orchard.Projections.Drivers { } protected override DriverResult Editor(ProjectionPart part, dynamic shapeHelper) { - return ContentShape("Parts_ProjectionPart_Edit", - () => { - var model = new ProjectionPartEditViewModel(); + return ContentShape("Parts_ProjectionPart_Edit", () => { + var model = new ProjectionPartEditViewModel(); - // for create read the setting values - var settings = part.TypePartDefinition.Settings.GetModel(); - if (part.Id == 0) { - model = new ProjectionPartEditViewModel { - DisplayPager = settings.DisplayPager, - Items = settings.Items, - Skip = settings.Skip, - PagerSuffix = settings.PagerSuffix, - MaxItems = settings.MaxItems, - QueryLayoutRecordId = settings.QueryLayoutRecordId - }; - } - else { - model = new ProjectionPartEditViewModel { - DisplayPager = part.Record.DisplayPager, - Items = part.Record.Items, - ItemsPerPage = part.Record.ItemsPerPage, - Skip = part.Record.Skip, - PagerSuffix = part.Record.PagerSuffix, - MaxItems = part.Record.MaxItems, - QueryLayoutRecordId = "-1" - }; - // concatenated Query and Layout ids for the view - if (part.Record.QueryPartRecord != null) { - model.QueryLayoutRecordId = part.Record.QueryPartRecord.Id + ";"; - } + // for create read the setting values + var settings = part.TypePartDefinition.Settings.GetModel(); + if (part.Id == 0) { + model = new ProjectionPartEditViewModel { + DisplayPager = settings.DisplayPager, + Items = settings.Items, + Skip = settings.Skip, + PagerSuffix = settings.PagerSuffix, + MaxItems = settings.MaxItems, + QueryLayoutRecordId = settings.QueryLayoutRecordId + }; + } + else { + model = new ProjectionPartEditViewModel { + DisplayPager = part.Record.DisplayPager, + Items = part.Record.Items, + ItemsPerPage = part.Record.ItemsPerPage, + Skip = part.Record.Skip, + PagerSuffix = part.Record.PagerSuffix, + MaxItems = part.Record.MaxItems, + QueryLayoutRecordId = "-1" + }; + // concatenated Query and Layout ids for the view + if (part.Record.QueryPartRecord != null) { + model.QueryLayoutRecordId = part.Record.QueryPartRecord.Id + ";"; + } - if (part.Record.LayoutRecord != null) { - model.QueryLayoutRecordId += part.Record.LayoutRecord.Id.ToString(); - } - else { - model.QueryLayoutRecordId += "-1"; - } - } + if (part.Record.LayoutRecord != null) { + model.QueryLayoutRecordId += part.Record.LayoutRecord.Id.ToString(); + } + else { + model.QueryLayoutRecordId += "-1"; + } + } - model.PartId = part.Id; + model.PartId = part.Id; - // lock fields - model.LockEditingItems = settings.LockEditingItems; - model.LockEditingSkip = settings.LockEditingSkip; - model.LockEditingMaxItems = settings.LockEditingMaxItems; - model.LockEditingPagerSuffix = settings.LockEditingPagerSuffix; - model.LockEditingDisplayPager = settings.LockEditingDisplayPager; + // lock fields + model.LockEditingItems = settings.LockEditingItems; + model.LockEditingSkip = settings.LockEditingSkip; + model.LockEditingMaxItems = settings.LockEditingMaxItems; + model.LockEditingPagerSuffix = settings.LockEditingPagerSuffix; + model.LockEditingDisplayPager = settings.LockEditingDisplayPager; - // populating the list of queries and layouts - var layouts = _projectionManager.DescribeLayouts().SelectMany(x => x.Descriptors).ToList(); - model.QueryRecordEntries = Services.ContentManager.Query().Join().OrderBy(x => x.Title).List() - .Select(x => new QueryRecordEntry { - Id = x.Id, - Name = x.Name, - LayoutRecordEntries = x.Layouts.Select(l => new LayoutRecordEntry { - Id = l.Id, - Description = GetLayoutDescription(layouts, l) - }) - }); + // populating the list of queries and layouts + var layouts = _projectionManager.DescribeLayouts().SelectMany(x => x.Descriptors).ToList(); + model.QueryRecordEntries = _orchardServices.ContentManager.Query().Join().OrderBy(x => x.Title).List() + .Select(x => new QueryRecordEntry { + Id = x.Id, + Name = x.Name, + LayoutRecordEntries = x.Layouts.Select(l => new LayoutRecordEntry { + Id = l.Id, + Description = GetLayoutDescription(layouts, l) + }) + }); - // if any values, use default list of the settings - if (!string.IsNullOrWhiteSpace(settings.FilterQueryRecordId)) { - var filterQueryRecordId = settings.FilterQueryRecordId.Split('&'); - model.QueryRecordIdFilterEntries = filterQueryRecordId - .Select(x => new QueryRecordFilterEntry { - Id = x.Split(';')[0], - LayoutId = x.Split(';')[1] - }); - } - else { - model.QueryRecordIdFilterEntries = new List(); - } + // if any values, use default list of the settings + if (!string.IsNullOrWhiteSpace(settings.FilterQueryRecordId)) { + var filterQueryRecordId = settings.FilterQueryRecordId.Split('&'); + model.QueryRecordIdFilterEntries = filterQueryRecordId + .Select(x => new QueryRecordFilterEntry { + Id = x.Split(';')[0], + LayoutId = x.Split(';')[1] + }); + } + else { + model.QueryRecordIdFilterEntries = new List(); + } - return shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix); - }); + return shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix); + }); } private static string GetLayoutDescription(IEnumerable layouts, LayoutRecord l) { @@ -313,7 +312,7 @@ namespace Orchard.Projections.Drivers { updater.TryUpdateModel(model, Prefix, null, null); model.PartId = part.Id; - + // check the setting, if it is unlocked, assign the setting value if (settings.LockEditingDisplayPager) { part.Record.DisplayPager = settings.DisplayPager; @@ -356,6 +355,12 @@ namespace Orchard.Projections.Drivers { updater.AddModelError("PagerSuffix", T("Suffix should not contain special characters.")); } + if (model.Items == 0 + && (part.Record.QueryPartRecord?.FilterGroups.Any(group => group.Filters.Count == 0) ?? false)) { + _orchardServices.Notifier.Warning( + T("The selected Query has at least one empty filter group, which causes all content items to be returned. It is recommended to limit the number of content items queried by setting the 'Items to display' field to a non-zero value.")); + } + return Editor(part, shapeHelper); } @@ -376,12 +381,11 @@ namespace Orchard.Projections.Drivers { protected override void ImportCompleted(ProjectionPart part, ImportContentContext context) { // Assign the query only when everything is imported. var query = context.Attribute(part.PartDefinition.Name, "Query"); - if (query != null && context.GetItemFromSession(query).As()!=null) { + if (query != null && context.GetItemFromSession(query).As() != null) { part.Record.QueryPartRecord = context.GetItemFromSession(query).As().Record; var layoutIndex = context.Attribute(part.PartDefinition.Name, "LayoutIndex"); - int layoutIndexValue; if (layoutIndex != null - && Int32.TryParse(layoutIndex, out layoutIndexValue) + && Int32.TryParse(layoutIndex, out int layoutIndexValue) && layoutIndexValue >= 0 && part.Record.QueryPartRecord.Layouts.Count > layoutIndexValue) { part.Record.LayoutRecord = part.Record.QueryPartRecord.Layouts[Int32.Parse(layoutIndex)]; @@ -398,9 +402,9 @@ namespace Orchard.Projections.Drivers { context.Element(part.PartDefinition.Name).SetAttributeValue("DisplayPager", part.Record.DisplayPager); if (part.Record.QueryPartRecord != null) { - var queryPart = Services.ContentManager.Query("Query").Where(x => x.Id == part.Record.QueryPartRecord.Id).List().FirstOrDefault(); + var queryPart = _orchardServices.ContentManager.Query("Query").Where(x => x.Id == part.Record.QueryPartRecord.Id).List().FirstOrDefault(); if (queryPart != null) { - var queryIdentity = Services.ContentManager.GetItemMetadata(queryPart).Identity; + var queryIdentity = _orchardServices.ContentManager.GetItemMetadata(queryPart).Identity; context.Element(part.PartDefinition.Name).SetAttributeValue("Query", queryIdentity.ToString()); context.Element(part.PartDefinition.Name).SetAttributeValue("LayoutIndex", part.Record.QueryPartRecord.Layouts.IndexOf(part.Record.LayoutRecord)); } diff --git a/src/Orchard.Web/Modules/Orchard.Projections/Drivers/QueryPartDriver.cs b/src/Orchard.Web/Modules/Orchard.Projections/Drivers/QueryPartDriver.cs index 907ea083c..fa38c9d79 100644 --- a/src/Orchard.Web/Modules/Orchard.Projections/Drivers/QueryPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Projections/Drivers/QueryPartDriver.cs @@ -19,14 +19,16 @@ namespace Orchard.Projections.Drivers { _projectionManager = projectionManager; _formManager = formManager; } + protected override string Prefix { get { return "Query_Part"; } } - protected override DriverResult Editor(QueryPart part, dynamic shapeHelper) { - return Editor(part, null, shapeHelper); - } + + protected override DriverResult Editor(QueryPart part, dynamic shapeHelper) => + Editor(part, null, shapeHelper); + protected override DriverResult Editor(QueryPart part, IUpdateModel updater, dynamic shapeHelper) { var model = new QueryViewModel { VersionScope = part.VersionScope }; if (updater != null) { @@ -34,10 +36,10 @@ namespace Orchard.Projections.Drivers { part.VersionScope = model.VersionScope; } } - return ContentShape("Parts_QueryPart_Edit", - () => { - return shapeHelper.EditorTemplate(TemplateName: "Parts/QueryPart_Edit", Model: model, Prefix: Prefix); - }); + + return ContentShape("Parts_QueryPart_Edit", () => { + return shapeHelper.EditorTemplate(TemplateName: "Parts/QueryPart_Edit", Model: model, Prefix: Prefix); + }); } protected override void Exporting(QueryPart part, ExportContentContext context) { @@ -60,12 +62,12 @@ namespace Orchard.Projections.Drivers { } return new XElement("Filter", - new XAttribute("Category", filter.Category ?? ""), - new XAttribute("Description", filter.Description ?? ""), - new XAttribute("Position", filter.Position), - new XAttribute("State", state ?? ""), - new XAttribute("Type", filter.Type ?? "") - ); + new XAttribute("Category", filter.Category ?? ""), + new XAttribute("Description", filter.Description ?? ""), + new XAttribute("Position", filter.Position), + new XAttribute("State", state ?? ""), + new XAttribute("Type", filter.Type ?? "") + ); }) ) ) diff --git a/src/Orchard.Web/Modules/Orchard.Projections/Services/ProjectionManager.cs b/src/Orchard.Web/Modules/Orchard.Projections/Services/ProjectionManager.cs index f579c3e44..09b34e16d 100644 --- a/src/Orchard.Web/Modules/Orchard.Projections/Services/ProjectionManager.cs +++ b/src/Orchard.Web/Modules/Orchard.Projections/Services/ProjectionManager.cs @@ -108,13 +108,9 @@ namespace Orchard.Projections.Services { } public int GetCount(int queryId, ContentPart part) { - var queryRecord = _queryRepository.Get(queryId); + var queryRecord = _queryRepository.Get(queryId) ?? throw new ArgumentException("queryId"); - if (queryRecord == null) { - throw new ArgumentException("queryId"); - } - - // prepares tokens + // Prepare tokens. Dictionary tokens = new Dictionary(); if (part != null) { tokens.Add("Content", part.ContentItem); @@ -122,6 +118,7 @@ namespace Orchard.Projections.Services { var contentQueries = GetContentQueries(queryRecord, Enumerable.Empty(), tokens); + // Aggregate the result of each filter group. return queryRecord.FilterGroups.Count > 1 ? contentQueries.SelectMany(contentQuery => contentQuery.ListIds()).Distinct().Count() : contentQueries.Sum(contentQuery => contentQuery.Count()); @@ -142,13 +139,13 @@ namespace Orchard.Projections.Services { var contentItems = new List(); - // prepares tokens + // Prepare tokens. Dictionary tokens = new Dictionary(); if (part != null) { tokens.Add("Content", part.ContentItem); } - // aggregate the result for each group query + // Aggregate the result of each filter group. foreach (var contentQuery in GetContentQueries(queryRecord, queryRecord.SortCriteria.OrderBy(sc => sc.Position), tokens)) { contentItems.AddRange(contentQuery.Slice(skip, count)); } @@ -157,7 +154,7 @@ namespace Orchard.Projections.Services { return contentItems; } - // re-executing the sorting with the cumulated groups + // Re-executing the sorting on the aggregated results. var ids = contentItems.Select(c => c.Id).ToArray(); if (ids.Length == 0) { @@ -166,7 +163,7 @@ namespace Orchard.Projections.Services { var groupQuery = _contentManager.HqlQuery().Where(alias => alias.Named("ci"), x => x.InG("Id", ids)); - // iterate over each sort criteria to apply the alterations to the query object + // Iterate over each sort criteria to apply the alterations to the query object. foreach (var sortCriterion in queryRecord.SortCriteria.OrderBy(s => s.Position)) { var tokenizedState = _tokenizer.Replace(sortCriterion.State, tokens); var sortCriterionContext = new SortCriterionContext { @@ -179,15 +176,17 @@ namespace Orchard.Projections.Services { string category = sortCriterion.Category; string type = sortCriterion.Type; - // look for the specific filter component - var descriptor = availableSortCriteria.SelectMany(x => x.Descriptors).FirstOrDefault(x => x.Category == category && x.Type == type); + // Find specific sort criterion. + var descriptor = availableSortCriteria + .SelectMany(x => x.Descriptors) + .FirstOrDefault(x => x.Category == category && x.Type == type); - // ignore unfound descriptors + // Skip if not found. if (descriptor == null) { continue; } - // apply alteration + // Apply alteration. descriptor.Sort(sortCriterionContext); groupQuery = sortCriterionContext.Query; @@ -196,7 +195,10 @@ namespace Orchard.Projections.Services { return groupQuery.Slice(0, count); } - public IEnumerable GetContentQueries(QueryPartRecord queryRecord, IEnumerable sortCriteria, Dictionary tokens) { + public IEnumerable GetContentQueries( + QueryPartRecord queryRecord, + IEnumerable sortCriteria, + Dictionary tokens) { var availableFilters = DescribeFilters().ToList(); var availableSortCriteria = DescribeSortCriteria().ToList(); @@ -206,11 +208,11 @@ namespace Orchard.Projections.Services { var version = queryRecord.VersionScope.ToVersionOptions(); - // pre-executing all groups + // Iterate over each filter group and evaluate the filters. foreach (var group in queryRecord.FilterGroups) { var contentQuery = _contentManager.HqlQuery().ForVersion(version); - // iterate over each filter to apply the alterations to the query object + // Iterate over each filter to apply the alterations to the query object. foreach (var filter in group.Filters) { var tokenizedState = _tokenizer.Replace(filter.State, tokens); var filterContext = new FilterContext { @@ -223,23 +225,23 @@ namespace Orchard.Projections.Services { string category = filter.Category; string type = filter.Type; - // look for the specific filter component + // Find specific filter. var descriptor = availableFilters .SelectMany(x => x.Descriptors) .FirstOrDefault(x => x.Category == category && x.Type == type); - // ignore unfound descriptors + // Skip if not found. if (descriptor == null) { continue; } - // apply alteration + // Apply alteration. descriptor.Filter(filterContext); contentQuery = filterContext.Query; } - // iterate over each sort criteria to apply the alterations to the query object + // Iterate over each sort criteria to apply the alterations to the query object. foreach (var sortCriterion in sortCriteria.OrderBy(s => s.Position)) { var tokenizedState = _tokenizer.Replace(sortCriterion.State, tokens); var sortCriterionContext = new SortCriterionContext { @@ -252,23 +254,22 @@ namespace Orchard.Projections.Services { string category = sortCriterion.Category; string type = sortCriterion.Type; - // look for the specific filter component + // Find specific sort criterion. var descriptor = availableSortCriteria .SelectMany(x => x.Descriptors) .FirstOrDefault(x => x.Category == category && x.Type == type); - // ignore unfound descriptors + // Skip if not found. if (descriptor == null) { continue; } - // apply alteration + // Apply alteration. descriptor.Sort(sortCriterionContext); contentQuery = sortCriterionContext.Query; } - yield return contentQuery; } } diff --git a/src/Orchard.Web/Modules/Orchard.Search/Web.config b/src/Orchard.Web/Modules/Orchard.Search/Web.config index 9cdad18dd..c44f787fe 100644 --- a/src/Orchard.Web/Modules/Orchard.Search/Web.config +++ b/src/Orchard.Web/Modules/Orchard.Search/Web.config @@ -68,6 +68,22 @@ + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/Orchard.Tags/Web.config b/src/Orchard.Web/Modules/Orchard.Tags/Web.config index 9cdad18dd..c44f787fe 100644 --- a/src/Orchard.Web/Modules/Orchard.Tags/Web.config +++ b/src/Orchard.Web/Modules/Orchard.Tags/Web.config @@ -68,6 +68,22 @@ + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Web.config b/src/Orchard.Web/Modules/Orchard.Widgets/Web.config index 9cdad18dd..c44f787fe 100644 --- a/src/Orchard.Web/Modules/Orchard.Widgets/Web.config +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Web.config @@ -68,6 +68,22 @@ + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/Modules/Upgrade/Web.config b/src/Orchard.Web/Modules/Upgrade/Web.config index 4e0ef49bf..b011e842c 100644 --- a/src/Orchard.Web/Modules/Upgrade/Web.config +++ b/src/Orchard.Web/Modules/Upgrade/Web.config @@ -86,6 +86,18 @@ + + + + + + + + + + + + diff --git a/src/Orchard.Web/Orchard.Web.csproj b/src/Orchard.Web/Orchard.Web.csproj index 2a0328d58..cb9c19d22 100644 --- a/src/Orchard.Web/Orchard.Web.csproj +++ b/src/Orchard.Web/Orchard.Web.csproj @@ -95,8 +95,8 @@ ..\packages\Owin.1.0\lib\net40\Owin.dll - - ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + ..\packages\System.Buffers.4.6.0\lib\net462\System.Buffers.dll @@ -107,19 +107,19 @@ ..\..\lib\sqlce\System.Data.SqlServerCe.dll True - - ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll + + ..\packages\System.Memory.4.6.0\lib\net462\System.Memory.dll - - ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + ..\packages\System.Numerics.Vectors.4.6.0\lib\net462\System.Numerics.Vectors.dll - - ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + ..\packages\System.Runtime.CompilerServices.Unsafe.6.1.0\lib\net462\System.Runtime.CompilerServices.Unsafe.dll - - ..\packages\System.Threading.Tasks.Extensions.4.5.2\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll + + ..\packages\System.Threading.Tasks.Extensions.4.6.0\lib\net462\System.Threading.Tasks.Extensions.dll ..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll diff --git a/src/Orchard.Web/Themes/Web.config b/src/Orchard.Web/Themes/Web.config index 04606345a..3f4cd21fa 100644 --- a/src/Orchard.Web/Themes/Web.config +++ b/src/Orchard.Web/Themes/Web.config @@ -91,6 +91,22 @@ + + + + + + + + + + + + + + + + diff --git a/src/Orchard.Web/Web.config b/src/Orchard.Web/Web.config index 2a9fe8447..cd5d633df 100644 --- a/src/Orchard.Web/Web.config +++ b/src/Orchard.Web/Web.config @@ -266,13 +266,25 @@ - - + + - + + + + + + + + + + + + + diff --git a/src/Orchard.Web/packages.config b/src/Orchard.Web/packages.config index 115a00a16..6e7be5faf 100644 --- a/src/Orchard.Web/packages.config +++ b/src/Orchard.Web/packages.config @@ -17,10 +17,10 @@ - - - - - + + + + + \ No newline at end of file