From 654a9e18841cac8854c64b954f33b087b260e44b Mon Sep 17 00:00:00 2001 From: Lombiq Date: Fri, 27 Jan 2017 03:29:31 +0100 Subject: [PATCH 01/18] Framework: Fixing that a non-zero MaxPageSize site setting was not applied when the page size is 0, #7541 --- src/Orchard/UI/Navigation/Pager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Orchard/UI/Navigation/Pager.cs b/src/Orchard/UI/Navigation/Pager.cs index defcc539c..9fff3da35 100644 --- a/src/Orchard/UI/Navigation/Pager.cs +++ b/src/Orchard/UI/Navigation/Pager.cs @@ -23,10 +23,10 @@ namespace Orchard.UI.Navigation { /// The page parameter. /// The page size parameter. public Pager(ISite site, int? page, int? pageSize) { - Page = (int) (page != null ? (page > 0 ? page : PageDefault) : PageDefault); - PageSize = pageSize ?? site.PageSize; + Page = page == null || page == 0 ? PageDefault : page.Value; - if (site.MaxPageSize > 0 && PageSize > site.MaxPageSize) { + PageSize = pageSize ?? site.PageSize; + if (site.MaxPageSize > 0 && (PageSize == 0 || PageSize > site.MaxPageSize)) { PageSize = site.MaxPageSize; } } From 2c26c65f63d7d1341df967d448f966604a4cbf7a Mon Sep 17 00:00:00 2001 From: Carl Woodhouse Date: Thu, 2 Feb 2017 20:22:00 +0000 Subject: [PATCH 02/18] [Fixes #7479] Unwrapping of TargetInvocationException causes partial stacktrace loss (#7550) Fixes #7479 --- .../ShapeAttributeStrategy/ShapeAttributeBindingStrategy.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Orchard/DisplayManagement/Descriptors/ShapeAttributeStrategy/ShapeAttributeBindingStrategy.cs b/src/Orchard/DisplayManagement/Descriptors/ShapeAttributeStrategy/ShapeAttributeBindingStrategy.cs index 3dbe111e8..a98639fa3 100644 --- a/src/Orchard/DisplayManagement/Descriptors/ShapeAttributeStrategy/ShapeAttributeBindingStrategy.cs +++ b/src/Orchard/DisplayManagement/Descriptors/ShapeAttributeStrategy/ShapeAttributeBindingStrategy.cs @@ -70,7 +70,7 @@ namespace Orchard.DisplayManagement.Descriptors.ShapeAttributeStrategy { catch(TargetInvocationException e) { // Throwing a TIE here will probably kill the web process // in Azure. For unknown reasons. - throw e.InnerException; + throw new Exception(string.Concat("TargetInvocationException ", methodInfo.Name), e.InnerException); } } From 5a0fe4e105be7031845f64338385fc0d0a233d8b Mon Sep 17 00:00:00 2001 From: Carl Woodhouse Date: Thu, 2 Feb 2017 20:23:07 +0000 Subject: [PATCH 03/18] [Fixes #5596] blueprint harvesting caching (#7549) Fixes #5596 --- .../Framework/Harvesters/HarvestElementsContext.cs | 1 + .../Providers/BlueprintElementHarvester.cs | 10 +++------- .../Services/DescribeElementsContext.cs | 1 + .../Modules/Orchard.Layouts/Services/ElementManager.cs | 3 ++- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Framework/Harvesters/HarvestElementsContext.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Framework/Harvesters/HarvestElementsContext.cs index c8cc7c230..a30249306 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Framework/Harvesters/HarvestElementsContext.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Framework/Harvesters/HarvestElementsContext.cs @@ -3,5 +3,6 @@ namespace Orchard.Layouts.Framework.Harvesters { public class HarvestElementsContext { public IContent Content { get; set; } + public bool IsHarvesting { get; set; } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Providers/BlueprintElementHarvester.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Providers/BlueprintElementHarvester.cs index 3ca89574b..9d76467cf 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Providers/BlueprintElementHarvester.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Providers/BlueprintElementHarvester.cs @@ -13,7 +13,6 @@ namespace Orchard.Layouts.Providers { public class BlueprintElementHarvester : Component, IElementHarvester { private readonly Work _elementBlueprintService; private readonly Work _elementManager; - private bool _isHarvesting; public BlueprintElementHarvester(Work elementBlueprintService, Work elementManager) { _elementBlueprintService = elementBlueprintService; @@ -21,15 +20,14 @@ namespace Orchard.Layouts.Providers { } public IEnumerable HarvestElements(HarvestElementsContext context) { - if (_isHarvesting) + if (context.IsHarvesting) return Enumerable.Empty(); - _isHarvesting = true; var blueprints = _elementBlueprintService.Value.GetBlueprints().ToArray(); var query = from blueprint in blueprints - let describeContext = new DescribeElementsContext {Content = context.Content, CacheVaryParam = "Blueprints"} + let describeContext = new DescribeElementsContext {Content = context.Content, CacheVaryParam = "Blueprints", IsHarvesting = true } let baseElementDescriptor = _elementManager.Value.GetElementDescriptorByTypeName(describeContext, blueprint.BaseElementTypeName) let baseElement = _elementManager.Value.ActivateElement(baseElementDescriptor) select new ElementDescriptor( @@ -48,9 +46,7 @@ namespace Orchard.Layouts.Providers { } }; - var descriptors = query.ToArray(); - _isHarvesting = false; - return descriptors; + return query.ToArray(); } private static string GetCategory(ElementBlueprint blueprint) { diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Services/DescribeElementsContext.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Services/DescribeElementsContext.cs index 3a7f18f7a..42cb6fadf 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Services/DescribeElementsContext.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Services/DescribeElementsContext.cs @@ -4,6 +4,7 @@ namespace Orchard.Layouts.Services { public class DescribeElementsContext { public IContent Content { get; set; } public string CacheVaryParam { get; set; } + public bool IsHarvesting { get; set; } public static readonly DescribeElementsContext Empty = new DescribeElementsContext(); } diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Services/ElementManager.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Services/ElementManager.cs index 1281f5d85..5e0146250 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Services/ElementManager.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Services/ElementManager.cs @@ -40,7 +40,8 @@ namespace Orchard.Layouts.Services { var cacheKey = String.Format("LayoutElementTypes-{0}-{1}", contentType ?? "AnyType", context.CacheVaryParam); return _cacheManager.Get(cacheKey, true, acquireContext => { var harvesterContext = new HarvestElementsContext { - Content = context.Content + Content = context.Content, + IsHarvesting = context.IsHarvesting }; var query = from harvester in _elementHarvesters.Value From 8c1ffe2564f04d9f6ee8578131cf1f4075781885 Mon Sep 17 00:00:00 2001 From: Hannan Azam Khan Date: Fri, 3 Feb 2017 01:24:13 +0500 Subject: [PATCH 04/18] [Fixes #7486] Possibility of exporting individual Form Submissions (#7495) --- .../Orchard.DynamicForms.csproj | 5 ++ .../Recipes/Builders/FormSubmissionsStep.cs | 55 +++++++++++++------ .../Styles/recipebuilderstep-forms.css | 9 +++ .../ViewModels/FormExportEntry.cs | 6 ++ .../BuilderSteps/FormSubmissions.cshtml | 35 ++++++++++++ 5 files changed, 92 insertions(+), 18 deletions(-) create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Styles/recipebuilderstep-forms.css create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/ViewModels/FormExportEntry.cs create mode 100644 src/Orchard.Web/Modules/Orchard.DynamicForms/Views/EditorTemplates/BuilderSteps/FormSubmissions.cshtml diff --git a/src/Orchard.Web/Modules/Orchard.DynamicForms/Orchard.DynamicForms.csproj b/src/Orchard.Web/Modules/Orchard.DynamicForms/Orchard.DynamicForms.csproj index e3133ef21..6b2829aaa 100644 --- a/src/Orchard.Web/Modules/Orchard.DynamicForms/Orchard.DynamicForms.csproj +++ b/src/Orchard.Web/Modules/Orchard.DynamicForms/Orchard.DynamicForms.csproj @@ -118,6 +118,7 @@ + @@ -304,6 +305,7 @@ + @@ -549,6 +551,9 @@ + + + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) diff --git a/src/Orchard.Web/Modules/Orchard.DynamicForms/Recipes/Builders/FormSubmissionsStep.cs b/src/Orchard.Web/Modules/Orchard.DynamicForms/Recipes/Builders/FormSubmissionsStep.cs index 8a820dc05..206c15cf9 100644 --- a/src/Orchard.Web/Modules/Orchard.DynamicForms/Recipes/Builders/FormSubmissionsStep.cs +++ b/src/Orchard.Web/Modules/Orchard.DynamicForms/Recipes/Builders/FormSubmissionsStep.cs @@ -3,12 +3,17 @@ using System.Xml.Linq; using Orchard.DynamicForms.Services; using Orchard.Localization; using Orchard.Recipes.Services; +using System.Collections.Generic; +using Orchard.ContentManagement; +using Orchard.DynamicForms.ViewModels; namespace Orchard.DynamicForms.Recipes.Builders { public class FormSubmissionsStep : RecipeBuilderStep { private readonly IFormService _formService; + public FormSubmissionsStep(IFormService formService) { _formService = formService; + SelectedForms = new List(); } public override string Name { @@ -23,29 +28,43 @@ namespace Orchard.DynamicForms.Recipes.Builders { get { return T("Exports submitted forms."); } } + public IList SelectedForms { get; set; } + public override dynamic BuildEditor(dynamic shapeFactory) { - // TODO: Implement an editor that enables the user to select which forms to export. - return null; + return UpdateEditor(shapeFactory, null); + } + + public override dynamic UpdateEditor(dynamic shapeFactory, IUpdateModel updater) { + List forms = new List(); + + if (updater != null && updater.TryUpdateModel(forms, Prefix, null, null)) { + SelectedForms = forms.Where(x => x.Export).Select(x => x.FormName).ToList(); + } + else { + forms = _formService.GetSubmissions().OrderBy(x => x.FormName).GroupBy(y => y.FormName) + .Select(x => new FormExportEntry { FormName = x.FirstOrDefault().FormName }) + .ToList(); + } + + return shapeFactory.EditorTemplate(TemplateName: "BuilderSteps/FormSubmissions", Model: forms, Prefix: Prefix); } public override void Build(BuildContext context) { - var submissions = _formService.GetSubmissions().ToArray(); + if (SelectedForms.Count() > 0) { + var root = new XElement("Forms"); + context.RecipeDocument.Element("Orchard").Add(root); - if (!submissions.Any()) { - return; - } - - var forms = submissions.GroupBy(x => x.FormName); - var root = new XElement("Forms"); - context.RecipeDocument.Element("Orchard").Add(root); - - foreach (var form in forms) { - root.Add(new XElement("Form", - new XAttribute("Name", form.Key), - new XElement("Submissions", form.Select(submission => - new XElement("Submission", - new XAttribute("CreatedUtc", submission.CreatedUtc), - new XCData(submission.FormData)))))); + foreach (var form in SelectedForms) { + var submissions = _formService.GetSubmissions(form); + if (submissions.Count() > 0) { + root.Add(new XElement("Form", + new XAttribute("Name", form), + new XElement("Submissions", submissions.Select(submission => + new XElement("Submission", + new XAttribute("CreatedUtc", submission.CreatedUtc), + new XCData(submission.FormData)))))); + } + } } } } diff --git a/src/Orchard.Web/Modules/Orchard.DynamicForms/Styles/recipebuilderstep-forms.css b/src/Orchard.Web/Modules/Orchard.DynamicForms/Styles/recipebuilderstep-forms.css new file mode 100644 index 000000000..660a1b012 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.DynamicForms/Styles/recipebuilderstep-forms.css @@ -0,0 +1,9 @@ +fieldset.recipe-builder-step-form-submissions table.items { + width: 500px; + margin: 0; +} + +fieldset.recipe-builder-step-form-submissions table.items td, +fieldset.recipe-builder-step-form-submissions table.items thead tr.sub th { + padding: 0 12px; +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.DynamicForms/ViewModels/FormExportEntry.cs b/src/Orchard.Web/Modules/Orchard.DynamicForms/ViewModels/FormExportEntry.cs new file mode 100644 index 000000000..d3d1860d2 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.DynamicForms/ViewModels/FormExportEntry.cs @@ -0,0 +1,6 @@ +namespace Orchard.DynamicForms.ViewModels { + public class FormExportEntry { + public string FormName { get; set; } + public bool Export { get; set; } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.DynamicForms/Views/EditorTemplates/BuilderSteps/FormSubmissions.cshtml b/src/Orchard.Web/Modules/Orchard.DynamicForms/Views/EditorTemplates/BuilderSteps/FormSubmissions.cshtml new file mode 100644 index 000000000..bfcb2c065 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.DynamicForms/Views/EditorTemplates/BuilderSteps/FormSubmissions.cshtml @@ -0,0 +1,35 @@ +@model List +@using Orchard.DynamicForms.ViewModels; + +@{ + Style.Include("recipebuilderstep-forms.css"); +} + +
+ + + + + + + + + + @for (int index = 0; index < Model.Count(); index++) { + var entry = Model.ElementAt(index); + + + + + + } + +
@T("Form") + + @T("Select All") +
@entry.FormName + + +
+ @Html.Hint(T("Choose the forms to include in the export file")) +
From f28da9894a7c201ecbacbdf3ecb0b05511bbce1b Mon Sep 17 00:00:00 2001 From: Lombiq Date: Fri, 3 Feb 2017 17:16:18 +0100 Subject: [PATCH 05/18] Fixing redirect on tenants with a URL prefix, fixes #4605 --- .../Mvc/Extensions/ControllerExtensions.cs | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/Orchard/Mvc/Extensions/ControllerExtensions.cs b/src/Orchard/Mvc/Extensions/ControllerExtensions.cs index 904aae4d5..ddec70712 100644 --- a/src/Orchard/Mvc/Extensions/ControllerExtensions.cs +++ b/src/Orchard/Mvc/Extensions/ControllerExtensions.cs @@ -2,13 +2,15 @@ using System.Web; using System.Web.Mvc; using Orchard.Utility.Extensions; +using Orchard.Environment.Configuration; namespace Orchard.Mvc.Extensions { public static class ControllerExtensions { public static ActionResult RedirectLocal(this Controller controller, string redirectUrl, Func invalidUrlBehavior) { if (!string.IsNullOrWhiteSpace(redirectUrl) && controller.Request.IsLocalUrl(redirectUrl)) { - return new RedirectResult(redirectUrl); + return RedirectWithTenantPrefix(redirectUrl, controller); } + return invalidUrlBehavior != null ? invalidUrlBehavior() : null; } @@ -18,10 +20,25 @@ namespace Orchard.Mvc.Extensions { public static ActionResult RedirectLocal(this Controller controller, string redirectUrl, string defaultUrl) { if (controller.Request.IsLocalUrl(redirectUrl)) { - return new RedirectResult(redirectUrl); + return RedirectWithTenantPrefix(redirectUrl, controller); } - return new RedirectResult(defaultUrl ?? "~/"); + return RedirectWithTenantPrefix(defaultUrl ?? "~/", controller); + } + + private static ActionResult RedirectWithTenantPrefix(string redirectUrl, Controller controller) { + if (redirectUrl.StartsWith("~/")) { + ShellSettings settings; + var context = controller.ControllerContext.GetWorkContext(); + + if (context != null && + context.TryResolve(out settings) && + !string.IsNullOrWhiteSpace(settings.RequestUrlPrefix)) { + redirectUrl = VirtualPathUtility.ToAbsolute(redirectUrl, controller.Request.ApplicationPath.TrimEnd('/') + "/" + settings.RequestUrlPrefix); + } + } + + return new RedirectResult(redirectUrl); } } } From 8dde994bdece3b23d366e195dc34cfd4849883da Mon Sep 17 00:00:00 2001 From: Lombiq Date: Sat, 4 Feb 2017 15:49:19 +0100 Subject: [PATCH 06/18] MediaLibrary: Fixing that removing TitlePart from a type with MediaPart causes the type to be unusable due to an implicit dependency, fixes #6047 --- .../Handlers/MediaPartHandler.cs | 27 ++++++++++++++----- .../Orchard.MediaLibrary/Models/MediaPart.cs | 6 ++++- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.MediaLibrary/Handlers/MediaPartHandler.cs b/src/Orchard.Web/Modules/Orchard.MediaLibrary/Handlers/MediaPartHandler.cs index 0376feca3..2e73d8209 100644 --- a/src/Orchard.Web/Modules/Orchard.MediaLibrary/Handlers/MediaPartHandler.cs +++ b/src/Orchard.Web/Modules/Orchard.MediaLibrary/Handlers/MediaPartHandler.cs @@ -1,25 +1,40 @@ using System; -using Orchard.ContentManagement.Handlers; -using Orchard.Data; -using Orchard.MediaLibrary.Services; -using Orchard.MediaLibrary.Models; using System.IO; -using Orchard.FileSystems.Media; +using System.Linq; using Orchard.ContentManagement; +using Orchard.ContentManagement.Handlers; +using Orchard.ContentManagement.MetaData; +using Orchard.Core.Title.Models; +using Orchard.Data; +using Orchard.FileSystems.Media; +using Orchard.MediaLibrary.Models; +using Orchard.MediaLibrary.Services; namespace Orchard.MediaLibrary.Handlers { public class MediaPartHandler : ContentHandler { private readonly IMediaLibraryService _mediaLibraryService; private readonly IStorageProvider _storageProvider; + private readonly IContentDefinitionManager _contentDefinitionManager; public MediaPartHandler( IStorageProvider storageProvider, IMediaLibraryService mediaLibraryService, - IRepository repository) { + IRepository repository, + IContentDefinitionManager contentDefinitionManager) { _storageProvider = storageProvider; _mediaLibraryService = mediaLibraryService; + _contentDefinitionManager = contentDefinitionManager; Filters.Add(StorageFilter.For(repository)); + Filters.Add(new ActivatingFilter(contentType => { + var typeDefinition = _contentDefinitionManager.GetTypeDefinition(contentType); + // To avoid NRE when the handler runs for ad-hoc content types, e.g. MediaLibraryExplorer. + return typeDefinition == null ? + false : + typeDefinition.Parts.Any(contentTypePartDefinition => + contentTypePartDefinition.PartDefinition.Name == typeof(MediaPart).Name); + })); + OnRemoving((context, part) => RemoveMedia(part)); OnLoaded((context, part) => { if (!String.IsNullOrEmpty(part.FileName)) { diff --git a/src/Orchard.Web/Modules/Orchard.MediaLibrary/Models/MediaPart.cs b/src/Orchard.Web/Modules/Orchard.MediaLibrary/Models/MediaPart.cs index 38647a55c..b8cef2b4a 100644 --- a/src/Orchard.Web/Modules/Orchard.MediaLibrary/Models/MediaPart.cs +++ b/src/Orchard.Web/Modules/Orchard.MediaLibrary/Models/MediaPart.cs @@ -1,8 +1,10 @@ using System; using Orchard.ContentManagement; using Orchard.ContentManagement.FieldStorage.InfosetStorage; +using Orchard.ContentManagement.Handlers; using Orchard.ContentManagement.Utilities; using Orchard.Core.Title.Models; +using Orchard.MediaLibrary.Handlers; namespace Orchard.MediaLibrary.Models { public class MediaPart : ContentPart { @@ -11,6 +13,8 @@ namespace Orchard.MediaLibrary.Models { /// /// Gets or sets the title of the media. + /// This adds an implicit dependency on which will be resolved by an + /// in the . /// public string Title { get { return ContentItem.As().Title; } @@ -63,7 +67,7 @@ namespace Orchard.MediaLibrary.Models { /// Gets the public Url of the media if stored locally. /// public string MediaUrl { - get { return _publicUrl.Value; } + get { return _publicUrl.Value; } } /// From ac978b665b81b1e0d70594af53b94d6d699a7955 Mon Sep 17 00:00:00 2001 From: Hannan Azam Khan Date: Thu, 9 Feb 2017 18:00:18 +0500 Subject: [PATCH 07/18] Fixes #7493 TextFieldDriver doesn't export its tag if content is empty (#7510) * TextFieldDriver doesn't export its tag if content is empty * Null check implemented , string.Empty returned * TextFieldDriver doesn't export its tag if content is empty #7493 * TextFieldDriver doesn't export its tag if content is empty #7493 --- src/Orchard.Web/Core/Common/Drivers/TextFieldDriver.cs | 3 +-- .../Modules/Orchard.Fields/Drivers/BooleanFieldDriver.cs | 3 +-- .../Modules/Orchard.Fields/Drivers/DateTimeFieldDriver.cs | 4 +--- .../Orchard.Fields/Drivers/EnumerationFieldDriver.cs | 3 +-- .../Modules/Orchard.Fields/Drivers/InputFieldDriver.cs | 3 +-- .../Modules/Orchard.Fields/Drivers/LinkFieldDriver.cs | 8 +++----- .../Modules/Orchard.Fields/Drivers/NumericFieldDriver.cs | 3 +-- .../Orchard.Taxonomies/Drivers/TaxonomyFieldDriver.cs | 7 ++----- 8 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/Orchard.Web/Core/Common/Drivers/TextFieldDriver.cs b/src/Orchard.Web/Core/Common/Drivers/TextFieldDriver.cs index 868b1c8ca..a4e57942a 100644 --- a/src/Orchard.Web/Core/Common/Drivers/TextFieldDriver.cs +++ b/src/Orchard.Web/Core/Common/Drivers/TextFieldDriver.cs @@ -84,8 +84,7 @@ namespace Orchard.Core.Common.Drivers { } protected override void Exporting(ContentPart part, TextField field, ExportContentContext context) { - if (!String.IsNullOrEmpty(field.Value)) - context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Text", field.Value); + context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Text", field.Value); } protected override void Describe(DescribeMembersContext context) { diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Drivers/BooleanFieldDriver.cs b/src/Orchard.Web/Modules/Orchard.Fields/Drivers/BooleanFieldDriver.cs index 116c3a013..09dcda02f 100644 --- a/src/Orchard.Web/Modules/Orchard.Fields/Drivers/BooleanFieldDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Fields/Drivers/BooleanFieldDriver.cs @@ -62,8 +62,7 @@ namespace Orchard.Fields.Drivers { } protected override void Exporting(ContentPart part, BooleanField field, ExportContentContext context) { - if (field.Value.HasValue) - context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Value", field.Value); + context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Value", field.Value); } protected override void Describe(DescribeMembersContext context) { diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Drivers/DateTimeFieldDriver.cs b/src/Orchard.Web/Modules/Orchard.Fields/Drivers/DateTimeFieldDriver.cs index 8fac42140..b698a972d 100644 --- a/src/Orchard.Web/Modules/Orchard.Fields/Drivers/DateTimeFieldDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Fields/Drivers/DateTimeFieldDriver.cs @@ -165,9 +165,7 @@ namespace Orchard.Fields.Drivers { } protected override void Exporting(ContentPart part, DateTimeField field, ExportContentContext context) { - var value = field.Storage.Get(null); - if (value != DateTime.MinValue) - context.Element(GetPrefix(field, part)).SetAttributeValue("Value", XmlConvert.ToString(value, XmlDateTimeSerializationMode.Utc)); + context.Element(GetPrefix(field, part)).SetAttributeValue("Value", XmlConvert.ToString(field.Storage.Get(null), XmlDateTimeSerializationMode.Utc)); } protected override void Describe(DescribeMembersContext context) { diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Drivers/EnumerationFieldDriver.cs b/src/Orchard.Web/Modules/Orchard.Fields/Drivers/EnumerationFieldDriver.cs index d452fd673..fb9e64649 100644 --- a/src/Orchard.Web/Modules/Orchard.Fields/Drivers/EnumerationFieldDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Fields/Drivers/EnumerationFieldDriver.cs @@ -63,8 +63,7 @@ namespace Orchard.Fields.Drivers { } protected override void Exporting(ContentPart part, EnumerationField field, ExportContentContext context) { - if (!String.IsNullOrEmpty(field.Value)) - context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Value", field.Value); + context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Value", field.Value); } protected override void Describe(DescribeMembersContext context) { diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Drivers/InputFieldDriver.cs b/src/Orchard.Web/Modules/Orchard.Fields/Drivers/InputFieldDriver.cs index d835b43fe..babe5debf 100644 --- a/src/Orchard.Web/Modules/Orchard.Fields/Drivers/InputFieldDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Fields/Drivers/InputFieldDriver.cs @@ -61,8 +61,7 @@ namespace Orchard.Fields.Drivers { } protected override void Exporting(ContentPart part, InputField field, ExportContentContext context) { - if (!String.IsNullOrEmpty(field.Value)) - context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Value", field.Value); + context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Value", field.Value); } protected override void Describe(DescribeMembersContext context) { diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Drivers/LinkFieldDriver.cs b/src/Orchard.Web/Modules/Orchard.Fields/Drivers/LinkFieldDriver.cs index 8b1a86d2e..3f314311c 100644 --- a/src/Orchard.Web/Modules/Orchard.Fields/Drivers/LinkFieldDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Fields/Drivers/LinkFieldDriver.cs @@ -75,11 +75,9 @@ namespace Orchard.Fields.Drivers { } protected override void Exporting(ContentPart part, LinkField field, ExportContentContext context) { - if (!String.IsNullOrEmpty(field.Text) || !String.IsNullOrEmpty(field.Value) || !String.IsNullOrEmpty(field.Target)) { - context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Text", field.Text); - context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Url", field.Value); - context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Target", field.Target); - } + context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Text", field.Text); + context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Url", field.Value); + context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Target", field.Target); } protected override void Describe(DescribeMembersContext context) { diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Drivers/NumericFieldDriver.cs b/src/Orchard.Web/Modules/Orchard.Fields/Drivers/NumericFieldDriver.cs index a1dfd46bc..493b40d97 100644 --- a/src/Orchard.Web/Modules/Orchard.Fields/Drivers/NumericFieldDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Fields/Drivers/NumericFieldDriver.cs @@ -106,8 +106,7 @@ namespace Orchard.Fields.Drivers { } protected override void Exporting(ContentPart part, NumericField field, ExportContentContext context) { - if (field.Value.HasValue) - context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Value", field.Value.Value.ToString(CultureInfo.InvariantCulture)); + context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Value", !field.Value.HasValue ? String.Empty : field.Value.Value.ToString(CultureInfo.InvariantCulture)); } protected override void Describe(DescribeMembersContext context) { diff --git a/src/Orchard.Web/Modules/Orchard.Taxonomies/Drivers/TaxonomyFieldDriver.cs b/src/Orchard.Web/Modules/Orchard.Taxonomies/Drivers/TaxonomyFieldDriver.cs index b498d6431..4bb4940d5 100644 --- a/src/Orchard.Web/Modules/Orchard.Taxonomies/Drivers/TaxonomyFieldDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Taxonomies/Drivers/TaxonomyFieldDriver.cs @@ -117,13 +117,10 @@ namespace Orchard.Taxonomies.Drivers { } protected override void Exporting(ContentPart part, TaxonomyField field, ExportContentContext context) { - var appliedTerms = _taxonomyService.GetTermsForContentItem(part.ContentItem.Id, field.Name); - + var appliedTerms = _taxonomyService.GetTermsForContentItem(part.ContentItem.Id, field.Name); // stores all content items associated to this field var termIdentities = appliedTerms.Select(x => Services.ContentManager.GetItemMetadata(x).Identity.ToString()).ToArray(); - - if (termIdentities.Any()) - context.Element(XmlConvert.EncodeLocalName(field.FieldDefinition.Name + "." + field.Name)).SetAttributeValue("Terms", String.Join(",", termIdentities)); + context.Element(XmlConvert.EncodeLocalName(field.FieldDefinition.Name + "." + field.Name)).SetAttributeValue("Terms", String.Join(",", termIdentities)); } protected override void Importing(ContentPart part, TaxonomyField field, ImportContentContext context) { From 33bdfd05516c7c01aeae500f1e341991211942c7 Mon Sep 17 00:00:00 2001 From: GiuseppeMusso-Laser Date: Thu, 9 Feb 2017 21:43:19 +0100 Subject: [PATCH 08/18] Feature to remove a Publish Later task (#7438) --- .../Drivers/PublishLaterPartDriver.cs | 9 ++++++++- .../Views/EditorTemplates/Parts/PublishLater.cshtml | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Orchard.Web/Modules/Orchard.PublishLater/Drivers/PublishLaterPartDriver.cs b/src/Orchard.Web/Modules/Orchard.PublishLater/Drivers/PublishLaterPartDriver.cs index 8edefd9d5..bef714637 100644 --- a/src/Orchard.Web/Modules/Orchard.PublishLater/Drivers/PublishLaterPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.PublishLater/Drivers/PublishLaterPartDriver.cs @@ -11,6 +11,7 @@ using Orchard.PublishLater.Models; using Orchard.PublishLater.Services; using Orchard.PublishLater.ViewModels; using Orchard.Services; +using Orchard.Tasks.Scheduling; namespace Orchard.PublishLater.Drivers { public class PublishLaterPartDriver : ContentPartDriver { @@ -19,19 +20,22 @@ namespace Orchard.PublishLater.Drivers { private readonly IPublishLaterService _publishLaterService; private readonly IClock _clock; private readonly IDateLocalizationServices _dateLocalizationServices; + private readonly IPublishingTaskManager _publishingTaskManager; public PublishLaterPartDriver( IOrchardServices services, IHttpContextAccessor httpContextAccessor, IPublishLaterService publishLaterService, IClock clock, - IDateLocalizationServices dateLocalizationServices) { + IDateLocalizationServices dateLocalizationServices, + IPublishingTaskManager publishingTaskManager) { _httpContextAccessor = httpContextAccessor; _publishLaterService = publishLaterService; _clock = clock; _dateLocalizationServices = dateLocalizationServices; T = NullLocalizer.Instance; Services = services; + _publishingTaskManager = publishingTaskManager; } public Localizer T { @@ -105,6 +109,9 @@ namespace Orchard.PublishLater.Drivers { } } + if (httpContext.Request.Form["submit.Save"] == "submit.CancelPublishLaterTasks") { + _publishingTaskManager.DeleteTasks(model.ContentItem); + } return ContentShape("Parts_PublishLater_Edit", () => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix)); } diff --git a/src/Orchard.Web/Modules/Orchard.PublishLater/Views/EditorTemplates/Parts/PublishLater.cshtml b/src/Orchard.Web/Modules/Orchard.PublishLater/Views/EditorTemplates/Parts/PublishLater.cshtml index 8f0aa281c..5dc5b49a1 100644 --- a/src/Orchard.Web/Modules/Orchard.PublishLater/Views/EditorTemplates/Parts/PublishLater.cshtml +++ b/src/Orchard.Web/Modules/Orchard.PublishLater/Views/EditorTemplates/Parts/PublishLater.cshtml @@ -41,6 +41,9 @@ @Html.HiddenFor(m => m.Editor.ShowTime) @Html.EditorFor(m => m.Editor) + @if (!string.IsNullOrEmpty(Model.Editor.Date)) { + + } using (Script.Foot()) { From 234d5214ddc727a300ecf178c1f70b9db943bf26 Mon Sep 17 00:00:00 2001 From: Daniel Stolt Date: Tue, 14 Feb 2017 06:44:36 +0200 Subject: [PATCH 09/18] Added missing SnippetDescriptor property to Snippet element shape. --- .../Modules/Orchard.Layouts/Providers/SnippetElementHarvester.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Providers/SnippetElementHarvester.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Providers/SnippetElementHarvester.cs index cca37506f..9ab4cd7ad 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Providers/SnippetElementHarvester.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Providers/SnippetElementHarvester.cs @@ -125,6 +125,7 @@ namespace Orchard.Layouts.Providers { var shape = (dynamic)_shapeFactory.Value.Create(shapeType); shape.Element = context.Element; + shape.SnippetDescriptor = snippetDescriptor; if (snippetDescriptor != null) { foreach (var fieldDescriptor in snippetDescriptor.Fields) { From 9f98d3151b3f81eb00983f428f53b5080cd1a35d Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Tue, 28 Feb 2017 14:37:39 +0100 Subject: [PATCH 10/18] Updated GroupInfo name for AuditTrail settings. #Fixes 7583 --- .../Orchard.AuditTrail/Drivers/AuditTrailSettingsPartDriver.cs | 2 +- .../Handlers/AuditTrailSettingsPartHandler.cs | 2 +- .../Handlers/AuditTrailTrimmingSettingsPartHandler.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.AuditTrail/Drivers/AuditTrailSettingsPartDriver.cs b/src/Orchard.Web/Modules/Orchard.AuditTrail/Drivers/AuditTrailSettingsPartDriver.cs index ce9127e9a..f78925d88 100644 --- a/src/Orchard.Web/Modules/Orchard.AuditTrail/Drivers/AuditTrailSettingsPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.AuditTrail/Drivers/AuditTrailSettingsPartDriver.cs @@ -70,7 +70,7 @@ namespace Orchard.AuditTrail.Drivers { } return shapeHelper.EditorTemplate(TemplateName: "Parts.AuditTrailSettings", Model: viewModel, Prefix: Prefix); - }).OnGroup("Audit Trail"); + }).OnGroup("AuditTrail"); } /// diff --git a/src/Orchard.Web/Modules/Orchard.AuditTrail/Handlers/AuditTrailSettingsPartHandler.cs b/src/Orchard.Web/Modules/Orchard.AuditTrail/Handlers/AuditTrailSettingsPartHandler.cs index 2c659e92e..d65a00894 100644 --- a/src/Orchard.Web/Modules/Orchard.AuditTrail/Handlers/AuditTrailSettingsPartHandler.cs +++ b/src/Orchard.Web/Modules/Orchard.AuditTrail/Handlers/AuditTrailSettingsPartHandler.cs @@ -29,7 +29,7 @@ namespace Orchard.AuditTrail.Handlers { public Localizer T { get; set; } private void GetMetadata(GetContentItemMetadataContext context, AuditTrailSettingsPart part) { - context.Metadata.EditorGroupInfo.Add(new GroupInfo(T("Audit Trail"))); + context.Metadata.EditorGroupInfo.Add(new GroupInfo(T("AuditTrail"))); } private void SetupLazyFields(ActivatedContentContext context, AuditTrailSettingsPart part) { diff --git a/src/Orchard.Web/Modules/Orchard.AuditTrail/Handlers/AuditTrailTrimmingSettingsPartHandler.cs b/src/Orchard.Web/Modules/Orchard.AuditTrail/Handlers/AuditTrailTrimmingSettingsPartHandler.cs index 7d3870bca..14407053a 100644 --- a/src/Orchard.Web/Modules/Orchard.AuditTrail/Handlers/AuditTrailTrimmingSettingsPartHandler.cs +++ b/src/Orchard.Web/Modules/Orchard.AuditTrail/Handlers/AuditTrailTrimmingSettingsPartHandler.cs @@ -28,7 +28,7 @@ namespace Orchard.AuditTrail.Handlers { public Localizer T { get; set; } private void GetMetadata(GetContentItemMetadataContext context, AuditTrailTrimmingSettingsPart part) { - context.Metadata.EditorGroupInfo.Add(new GroupInfo(T("Audit Trail"))); + context.Metadata.EditorGroupInfo.Add(new GroupInfo(T("AuditTrail"))); } private void BeginUpdateEvent(UpdateContentContext context, AuditTrailTrimmingSettingsPart part) { From 097119466aae91a39d7c8e2735b4062db50abf6a Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Tue, 28 Feb 2017 21:17:48 +0100 Subject: [PATCH 11/18] Revert "Updated GroupInfo name for AuditTrail settings." This reverts commit 9f98d3151b3f81eb00983f428f53b5080cd1a35d. --- .../Orchard.AuditTrail/Drivers/AuditTrailSettingsPartDriver.cs | 2 +- .../Handlers/AuditTrailSettingsPartHandler.cs | 2 +- .../Handlers/AuditTrailTrimmingSettingsPartHandler.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.AuditTrail/Drivers/AuditTrailSettingsPartDriver.cs b/src/Orchard.Web/Modules/Orchard.AuditTrail/Drivers/AuditTrailSettingsPartDriver.cs index f78925d88..ce9127e9a 100644 --- a/src/Orchard.Web/Modules/Orchard.AuditTrail/Drivers/AuditTrailSettingsPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.AuditTrail/Drivers/AuditTrailSettingsPartDriver.cs @@ -70,7 +70,7 @@ namespace Orchard.AuditTrail.Drivers { } return shapeHelper.EditorTemplate(TemplateName: "Parts.AuditTrailSettings", Model: viewModel, Prefix: Prefix); - }).OnGroup("AuditTrail"); + }).OnGroup("Audit Trail"); } /// diff --git a/src/Orchard.Web/Modules/Orchard.AuditTrail/Handlers/AuditTrailSettingsPartHandler.cs b/src/Orchard.Web/Modules/Orchard.AuditTrail/Handlers/AuditTrailSettingsPartHandler.cs index d65a00894..2c659e92e 100644 --- a/src/Orchard.Web/Modules/Orchard.AuditTrail/Handlers/AuditTrailSettingsPartHandler.cs +++ b/src/Orchard.Web/Modules/Orchard.AuditTrail/Handlers/AuditTrailSettingsPartHandler.cs @@ -29,7 +29,7 @@ namespace Orchard.AuditTrail.Handlers { public Localizer T { get; set; } private void GetMetadata(GetContentItemMetadataContext context, AuditTrailSettingsPart part) { - context.Metadata.EditorGroupInfo.Add(new GroupInfo(T("AuditTrail"))); + context.Metadata.EditorGroupInfo.Add(new GroupInfo(T("Audit Trail"))); } private void SetupLazyFields(ActivatedContentContext context, AuditTrailSettingsPart part) { diff --git a/src/Orchard.Web/Modules/Orchard.AuditTrail/Handlers/AuditTrailTrimmingSettingsPartHandler.cs b/src/Orchard.Web/Modules/Orchard.AuditTrail/Handlers/AuditTrailTrimmingSettingsPartHandler.cs index 14407053a..7d3870bca 100644 --- a/src/Orchard.Web/Modules/Orchard.AuditTrail/Handlers/AuditTrailTrimmingSettingsPartHandler.cs +++ b/src/Orchard.Web/Modules/Orchard.AuditTrail/Handlers/AuditTrailTrimmingSettingsPartHandler.cs @@ -28,7 +28,7 @@ namespace Orchard.AuditTrail.Handlers { public Localizer T { get; set; } private void GetMetadata(GetContentItemMetadataContext context, AuditTrailTrimmingSettingsPart part) { - context.Metadata.EditorGroupInfo.Add(new GroupInfo(T("AuditTrail"))); + context.Metadata.EditorGroupInfo.Add(new GroupInfo(T("Audit Trail"))); } private void BeginUpdateEvent(UpdateContentContext context, AuditTrailTrimmingSettingsPart part) { From 9ec312a1c3ae18f37fda548c424eef57fa831816 Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 2 Mar 2017 16:03:27 -0500 Subject: [PATCH 12/18] Use Compose to make code stronger and consistent (#7582) --- .../Core/Settings/Metadata/ContentDefinitionManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Orchard.Web/Core/Settings/Metadata/ContentDefinitionManager.cs b/src/Orchard.Web/Core/Settings/Metadata/ContentDefinitionManager.cs index 283d138b3..915a6bdb4 100644 --- a/src/Orchard.Web/Core/Settings/Metadata/ContentDefinitionManager.cs +++ b/src/Orchard.Web/Core/Settings/Metadata/ContentDefinitionManager.cs @@ -189,7 +189,7 @@ namespace Orchard.Core.Settings.Metadata { private void Apply(ContentTypeDefinition model, ContentTypeDefinitionRecord record) { record.DisplayName = model.DisplayName; - record.Settings = _settingsFormatter.Map(model.Settings).ToString(); + record.Settings = Compose(_settingsFormatter.Map(model.Settings)); var toRemove = record.ContentTypePartDefinitionRecords .Where(partDefinitionRecord => model.Parts.All(part => partDefinitionRecord.ContentPartDefinitionRecord.Name != part.PartDefinition.Name)) @@ -215,7 +215,7 @@ namespace Orchard.Core.Settings.Metadata { } private void Apply(ContentPartDefinition model, ContentPartDefinitionRecord record) { - record.Settings = _settingsFormatter.Map(model.Settings).ToString(); + record.Settings = Compose(_settingsFormatter.Map(model.Settings)); var toRemove = record.ContentPartFieldDefinitionRecords .Where(partFieldDefinitionRecord => model.Fields.All(partField => partFieldDefinitionRecord.Name != partField.Name)) From 134bac44c32e16d911cab1915d14f4e2e6912e6a Mon Sep 17 00:00:00 2001 From: GiuseppeMusso-Laser Date: Thu, 9 Mar 2017 21:14:28 +0100 Subject: [PATCH 13/18] Tags: added index on ContentTagRecord table. (#7591) --- src/Orchard.Web/Modules/Orchard.Tags/Migrations.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Orchard.Web/Modules/Orchard.Tags/Migrations.cs b/src/Orchard.Web/Modules/Orchard.Tags/Migrations.cs index a14a0fd54..a4b64cc3c 100644 --- a/src/Orchard.Web/Modules/Orchard.Tags/Migrations.cs +++ b/src/Orchard.Web/Modules/Orchard.Tags/Migrations.cs @@ -36,6 +36,13 @@ namespace Orchard.Tags { return 2; } + + public int UpdateFrom2() { + SchemaBuilder.AlterTable("ContentTagRecord", table => table + .CreateIndex("IDX_TagsPartRecord_Id", "TagsPartRecord_Id") + ); + return 3; + } } [OrchardFeature("Orchard.Tags.TagCloud")] From d2889e46e30f4a37e4a2d8505bb3456b35a0138e Mon Sep 17 00:00:00 2001 From: LorenzoFrediani-Laser Date: Thu, 16 Mar 2017 20:03:41 +0100 Subject: [PATCH 14/18] Changed UpgradeFrom1 to UpdateFrom1 on Migration (#7612) Fixes #7611 --- src/Orchard.Web/Modules/Orchard.ContentTypes/Migrations.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Orchard.Web/Modules/Orchard.ContentTypes/Migrations.cs b/src/Orchard.Web/Modules/Orchard.ContentTypes/Migrations.cs index 6d5592a70..7b345b49f 100644 --- a/src/Orchard.Web/Modules/Orchard.ContentTypes/Migrations.cs +++ b/src/Orchard.Web/Modules/Orchard.ContentTypes/Migrations.cs @@ -22,7 +22,7 @@ namespace Orchard.ContentTypes { return 1; } - public int UpgradeFrom1() { + public int UpdateFrom1() { foreach (var typeDefinition in _contentDefinitionManager.ListTypeDefinitions()) { if (typeDefinition.Settings.ContainsKey("ContentTypeSettings.Creatable") && Convert.ToBoolean(typeDefinition.Settings["ContentTypeSettings.Creatable"], CultureInfo.InvariantCulture)) { typeDefinition.Settings["ContentTypeSettings.Securable"] = "True"; From 87bdf9c413318eee6c95122199d11aa8c7ca7b0e Mon Sep 17 00:00:00 2001 From: siyamandayubi Date: Thu, 16 Mar 2017 20:04:52 +0100 Subject: [PATCH 15/18] Fix MySQL support (#7607) Fixes #7602 --- .../DefaultDataMigrationInterpreter.cs | 4 +- .../Interpreters/MySqlCommandInterpreter.cs | 61 ++++++++++++++----- 2 files changed, 49 insertions(+), 16 deletions(-) diff --git a/src/Orchard/Data/Migration/Interpreters/DefaultDataMigrationInterpreter.cs b/src/Orchard/Data/Migration/Interpreters/DefaultDataMigrationInterpreter.cs index f3fcab8b8..b940ed089 100644 --- a/src/Orchard/Data/Migration/Interpreters/DefaultDataMigrationInterpreter.cs +++ b/src/Orchard/Data/Migration/Interpreters/DefaultDataMigrationInterpreter.cs @@ -405,7 +405,7 @@ namespace Orchard.Data.Migration.Interpreters { if ( value == null ) { return "null"; } - + TypeCode typeCode = Type.GetTypeCode(value.GetType()); switch (typeCode) { case TypeCode.Empty: @@ -428,7 +428,7 @@ namespace Orchard.Data.Migration.Interpreters { case TypeCode.Decimal: return Convert.ToString(value, CultureInfo.InvariantCulture); case TypeCode.DateTime: - return String.Concat("'", Convert.ToString(value, CultureInfo.InvariantCulture), "'"); + return String.Concat("'", ((DateTime)value).ToString("yyyy-MM-dd hh:mm:ss", CultureInfo.InvariantCulture), "'"); } return "null"; diff --git a/src/Orchard/Data/Migration/Interpreters/MySqlCommandInterpreter.cs b/src/Orchard/Data/Migration/Interpreters/MySqlCommandInterpreter.cs index 6ae15d78f..562fd46d7 100644 --- a/src/Orchard/Data/Migration/Interpreters/MySqlCommandInterpreter.cs +++ b/src/Orchard/Data/Migration/Interpreters/MySqlCommandInterpreter.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Data; +using System.Linq; using System.Text; using NHibernate.Dialect; using Orchard.Data.Migration.Schema; @@ -8,12 +9,14 @@ using Orchard.Environment.Configuration; using Orchard.Localization; namespace Orchard.Data.Migration.Interpreters { - public class MySqlCommandInterpreter : ICommandInterpreter { + public class MySqlCommandInterpreter : ICommandInterpreter, ICommandInterpreter { private readonly Lazy _dialectLazy; private readonly ShellSettings _shellSettings; + private readonly ITransactionManager _transactionManager; private readonly DefaultDataMigrationInterpreter _dataMigrationInterpreter; - public MySqlCommandInterpreter(DefaultDataMigrationInterpreter dataMigrationInterpreter) { + public MySqlCommandInterpreter(DefaultDataMigrationInterpreter dataMigrationInterpreter, ITransactionManager transactionManager) { + _transactionManager = transactionManager; _dataMigrationInterpreter = dataMigrationInterpreter; T = NullLocalizer.Instance; } @@ -26,14 +29,16 @@ namespace Orchard.Data.Migration.Interpreters { public MySqlCommandInterpreter( ShellSettings shellSettings, - ISessionFactoryHolder sessionFactoryHolder) { - _shellSettings = shellSettings; - _dialectLazy = new Lazy(() => Dialect.GetDialect(sessionFactoryHolder.GetConfiguration().Properties)); + ISessionFactoryHolder sessionFactoryHolder, + ITransactionManager transactionManager) { + _shellSettings = shellSettings; + _transactionManager = transactionManager; + _dialectLazy = new Lazy(() => Dialect.GetDialect(sessionFactoryHolder.GetConfiguration().Properties)); } public string[] CreateStatements(AlterColumnCommand command) { var builder = new StringBuilder(); - + builder.AppendFormat("alter table {0} modify column {1} ", _dialectLazy.Value.QuoteForTableName(PrefixTableName(command.TableName)), _dialectLazy.Value.QuoteForColumnName(command.ColumnName)); @@ -42,8 +47,7 @@ namespace Orchard.Data.Migration.Interpreters { // type if (command.DbType != DbType.Object) { builder.Append(DefaultDataMigrationInterpreter.GetTypeName(_dialectLazy.Value, command.DbType, command.Length, command.Precision, command.Scale)); - } - else { + } else { if (command.Length > 0 || command.Precision > 0 || command.Scale > 0) { throw new OrchardException(T("Error while executing data migration: you need to specify the field's type in order to change its properties")); } @@ -56,7 +60,7 @@ namespace Orchard.Data.Migration.Interpreters { _dialectLazy.Value.QuoteForTableName(PrefixTableName(command.TableName)), _dialectLazy.Value.QuoteForColumnName(command.ColumnName)); var initLength2 = builder2.Length; - + if (command.Default != null) { builder2.Append(" set default ").Append(_dataMigrationInterpreter.ConvertToSqlValue(command.Default)).Append(" "); } @@ -64,13 +68,11 @@ namespace Orchard.Data.Migration.Interpreters { // result var result = new List(); - if (builder.Length > initLength) - { + if (builder.Length > initLength) { result.Add(builder.ToString()); } - if (builder2.Length > initLength2) - { + if (builder2.Length > initLength2) { result.Add(builder2.ToString()); } @@ -82,5 +84,36 @@ namespace Orchard.Data.Migration.Interpreters { return tableName; return _shellSettings.DataTablePrefix + "_" + tableName; } + + public string[] CreateStatements(AddIndexCommand command) { + var session = _transactionManager.GetSession(); + + using (var sqlCommand = session.Connection.CreateCommand()) { + var columnNames = String.Join(", ", command.ColumnNames.Select(c => string.Format("'{0}'", c))); + var tableName = PrefixTableName(command.TableName); + // check whether the index contains big nvarchar columns or text fields + string sql = @"SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS + WHERE table_name = '{1}' AND COLUMN_NAME in ({0}) AND TABLE_SCHEMA = '{2}' AND + ((Data_type = 'varchar' and CHARACTER_MAXIMUM_LENGTH > 767) OR data_type= 'text');"; + + sql = string.Format(sql, columnNames, tableName, session.Connection.Database); + sqlCommand.CommandText = sql; + + var columnList = command.ColumnNames.ToList(); + using (var reader = sqlCommand.ExecuteReader()) { + // Provide prefix for string columns with length longer than 767 + while (reader.Read()) { + var columnName = reader.GetString(0); + columnList[columnList.IndexOf(columnName)] = string.Format("{0}(767)", columnName); + } + } + + return new[] {string.Format("create index {1} on {0} ({2}) ", + _dialectLazy.Value.QuoteForTableName(tableName), + _dialectLazy.Value.QuoteForTableName(PrefixTableName(command.IndexName)), + String.Join(", ", columnList))}; + + } + } } -} +} \ No newline at end of file From a709e37ddcabb1ea8f3d3a0f8ea8698c11f458d1 Mon Sep 17 00:00:00 2001 From: Lombiq Date: Thu, 16 Mar 2017 22:02:56 +0100 Subject: [PATCH 16/18] Fixing that Taxonomy Fields attached to the User content type didn't work in the User editor (#4479) --- .../Views/Items/Content-User.Edit.cshtml | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Users/Views/Items/Content-User.Edit.cshtml b/src/Orchard.Web/Modules/Orchard.Users/Views/Items/Content-User.Edit.cshtml index 11cb50133..17fb09279 100644 --- a/src/Orchard.Web/Modules/Orchard.Users/Views/Items/Content-User.Edit.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Users/Views/Items/Content-User.Edit.cshtml @@ -1,11 +1,19 @@ -
-
- @Display(Model.Content) +
+
+ @if (Model.Content != null) { +
+ @Display(Model.Content) +
+ }
-
- @Display(Model.Sidebar) +
+ @if (Model.Sidebar != null) { +
+ @Display(Model.Sidebar) +
+ }
@if (!String.IsNullOrWhiteSpace(Request.QueryString["returnUrl"])) { @Html.Hidden("returnUrl", Request.QueryString["returnUrl"]) -} +} \ No newline at end of file From d85954fa6d33ad88bbe87655c82f9b66a30fc425 Mon Sep 17 00:00:00 2001 From: Lombiq Date: Thu, 23 Mar 2017 00:45:57 +0100 Subject: [PATCH 17/18] Implementing user-configurable Lucene indexing analyzer selection, resolves #3887 --- .../Indexing/IndexingTaskExecutorTests.cs | 2 +- .../Indexing/LuceneIndexProviderTests.cs | 2 + .../Indexing/LuceneSearchBuilderTests.cs | 2 + .../Drivers/LuceneSettingsPartDriver.cs | 69 +++++++++++++++++++ .../Handlers/LuceneSettingsPartHandler.cs | 39 +++++++++++ src/Orchard.Web/Modules/Lucene/Lucene.csproj | 12 ++++ .../Models/LuceneAnalyzerSelectorMapping.cs | 6 ++ .../Lucene/Models/LuceneSettingsPart.cs | 21 ++++++ src/Orchard.Web/Modules/Lucene/Placement.info | 5 ++ .../Services/DefaultLuceneAnalyzerProvider.cs | 36 ++++++---- .../Services/DefaultLuceneAnalyzerSelector.cs | 2 + .../Services/ILuceneAnalyzerSelector.cs | 7 +- .../LuceneSettingsPartEditViewModel.cs | 14 ++++ .../Parts.LuceneSettings.cshtml | 26 +++++++ 14 files changed, 225 insertions(+), 18 deletions(-) create mode 100644 src/Orchard.Web/Modules/Lucene/Drivers/LuceneSettingsPartDriver.cs create mode 100644 src/Orchard.Web/Modules/Lucene/Handlers/LuceneSettingsPartHandler.cs create mode 100644 src/Orchard.Web/Modules/Lucene/Models/LuceneAnalyzerSelectorMapping.cs create mode 100644 src/Orchard.Web/Modules/Lucene/Models/LuceneSettingsPart.cs create mode 100644 src/Orchard.Web/Modules/Lucene/Placement.info create mode 100644 src/Orchard.Web/Modules/Lucene/ViewModels/LuceneSettingsPartEditViewModel.cs create mode 100644 src/Orchard.Web/Modules/Lucene/Views/EditorTemplates/Parts.LuceneSettings.cshtml diff --git a/src/Orchard.Tests.Modules/Indexing/IndexingTaskExecutorTests.cs b/src/Orchard.Tests.Modules/Indexing/IndexingTaskExecutorTests.cs index 1e84ecfbf..92368a560 100644 --- a/src/Orchard.Tests.Modules/Indexing/IndexingTaskExecutorTests.cs +++ b/src/Orchard.Tests.Modules/Indexing/IndexingTaskExecutorTests.cs @@ -14,7 +14,6 @@ using Orchard.ContentManagement.MetaData.Builders; using Orchard.ContentManagement.Records; using Orchard.Core.Common.Handlers; using Orchard.Core.Common.Models; -using Orchard.Data; using Orchard.Environment; using Orchard.Environment.Configuration; using Orchard.Environment.Extensions; @@ -69,6 +68,7 @@ namespace Orchard.Tests.Modules.Indexing { builder.RegisterType().As(); builder.RegisterType().As(); builder.RegisterType().As(); + builder.RegisterType().As(); builder.RegisterType().As(); builder.RegisterType().As(); builder.RegisterInstance(_contentDefinitionManager.Object); diff --git a/src/Orchard.Tests.Modules/Indexing/LuceneIndexProviderTests.cs b/src/Orchard.Tests.Modules/Indexing/LuceneIndexProviderTests.cs index 7ba30aa66..a3b329639 100644 --- a/src/Orchard.Tests.Modules/Indexing/LuceneIndexProviderTests.cs +++ b/src/Orchard.Tests.Modules/Indexing/LuceneIndexProviderTests.cs @@ -9,6 +9,7 @@ using Orchard.Environment.Configuration; using Orchard.FileSystems.AppData; using Orchard.Indexing; using Orchard.Tests.FileSystems.AppData; +using Orchard.Tests.Stubs; namespace Orchard.Tests.Modules.Indexing { public class LuceneIndexProviderTests { @@ -35,6 +36,7 @@ namespace Orchard.Tests.Modules.Indexing { _appDataFolder = AppDataFolderTests.CreateAppDataFolder(_basePath); var builder = new ContainerBuilder(); + builder.RegisterType().As(); builder.RegisterType().As(); builder.RegisterType().As(); builder.RegisterType().As(); diff --git a/src/Orchard.Tests.Modules/Indexing/LuceneSearchBuilderTests.cs b/src/Orchard.Tests.Modules/Indexing/LuceneSearchBuilderTests.cs index bf7504281..762c1694d 100644 --- a/src/Orchard.Tests.Modules/Indexing/LuceneSearchBuilderTests.cs +++ b/src/Orchard.Tests.Modules/Indexing/LuceneSearchBuilderTests.cs @@ -8,6 +8,7 @@ using Orchard.Environment.Configuration; using Orchard.FileSystems.AppData; using Orchard.Indexing; using Orchard.Tests.FileSystems.AppData; +using Orchard.Tests.Stubs; namespace Orchard.Tests.Modules.Indexing { public class LuceneSearchBuilderTests { @@ -34,6 +35,7 @@ namespace Orchard.Tests.Modules.Indexing { _appDataFolder = AppDataFolderTests.CreateAppDataFolder(_basePath); var builder = new ContainerBuilder(); + builder.RegisterType().As(); builder.RegisterType().As(); builder.RegisterType().As(); builder.RegisterType().As(); diff --git a/src/Orchard.Web/Modules/Lucene/Drivers/LuceneSettingsPartDriver.cs b/src/Orchard.Web/Modules/Lucene/Drivers/LuceneSettingsPartDriver.cs new file mode 100644 index 000000000..cd311ab38 --- /dev/null +++ b/src/Orchard.Web/Modules/Lucene/Drivers/LuceneSettingsPartDriver.cs @@ -0,0 +1,69 @@ +using Lucene.Models; +using Lucene.Services; +using Lucene.ViewModels; +using Orchard.ContentManagement; +using Orchard.ContentManagement.Drivers; +using Orchard.Indexing; +using Orchard.Localization; +using Orchard.UI.Notify; +using System.Collections.Generic; +using System.Linq; +using System.Web.Mvc; + +namespace Lucene.Drivers { + public class LuceneSettingsPartDriver : ContentPartDriver { + private readonly IIndexManager _indexManager; + private readonly IEnumerable _analyzerSelectors; + private readonly INotifier _notifier; + + public Localizer T { get; set; } + + public LuceneSettingsPartDriver(IIndexManager indexManager, IEnumerable analyzerSelectors, INotifier notifier) { + _indexManager = indexManager; + _analyzerSelectors = analyzerSelectors; + _notifier = notifier; + T = NullLocalizer.Instance; + } + + protected override DriverResult Editor(LuceneSettingsPart part, dynamic shapeHelper) { + return ContentShape("Parts_LuceneSettings_Edit", () => { + MaintainMappings(part); + return shapeHelper.EditorTemplate( + TemplateName: "Parts.LuceneSettings", + Model: new LuceneSettingsPartEditViewModel { + LuceneAnalyzerSelectorMappings = part.LuceneAnalyzerSelectorMappings.ToArray(), + LuceneAnalyzerSelectors = _analyzerSelectors.Select(analyzerSelector => + new SelectListItem { Text = T(analyzerSelector.Name).Text, Value = analyzerSelector.Name }) + }, + Prefix: Prefix); + }); + } + + protected override DriverResult Editor(LuceneSettingsPart part, IUpdateModel updater, dynamic shapeHelper) { + var viewModel = new LuceneSettingsPartEditViewModel(); + if (updater.TryUpdateModel(viewModel, Prefix, null, null)) { + _notifier.Warning(T("Don't forget to rebuild your index in case you have changed its analyzer.")); + part.LuceneAnalyzerSelectorMappings = viewModel.LuceneAnalyzerSelectorMappings; + MaintainMappings(part); + } + + return Editor(part, shapeHelper); + } + + private void MaintainMappings(LuceneSettingsPart part) { + var analyzerProviderNames = _analyzerSelectors.Select(analyzerProvider => analyzerProvider.Name); + var indexNames = _indexManager.GetSearchIndexProvider().List(); + var maintainedMappings = part.LuceneAnalyzerSelectorMappings.ToList(); + // Removing mappings which contain a removed/invalid index or analyzer provider. + maintainedMappings.RemoveAll(mapping => !indexNames.Contains(mapping.IndexName) || !analyzerProviderNames.Contains(mapping.AnalyzerName)); + // Adding new mappings for the new indexes. + foreach (var indexName in indexNames) { + if (!maintainedMappings.Any(mapping => mapping.IndexName == indexName)) { + maintainedMappings.Add(new LuceneAnalyzerSelectorMapping { IndexName = indexName, AnalyzerName = "Default" }); + } + } + + part.LuceneAnalyzerSelectorMappings = maintainedMappings; + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Lucene/Handlers/LuceneSettingsPartHandler.cs b/src/Orchard.Web/Modules/Lucene/Handlers/LuceneSettingsPartHandler.cs new file mode 100644 index 000000000..85c8e8a0b --- /dev/null +++ b/src/Orchard.Web/Modules/Lucene/Handlers/LuceneSettingsPartHandler.cs @@ -0,0 +1,39 @@ +using Lucene.Models; +using Orchard.ContentManagement; +using Orchard.ContentManagement.Handlers; +using Orchard.Localization; +using Orchard.Services; +using System.Collections.Generic; + +namespace Lucene.Handlers { + public class LuceneSettingsPartHandler : ContentHandler { + public Localizer T { get; set; } + + public LuceneSettingsPartHandler(IJsonConverter jsonConverter) { + T = NullLocalizer.Instance; + + Filters.Add(new ActivatingFilter("Site")); + + OnActivated((context, part) => { + part.LuceneAnalyzerSelectorMappingsField.Loader(() => { + return string.IsNullOrEmpty(part.LuceneAnalyzerSelectorMappingsSerialized) + ? new List() + : jsonConverter.Deserialize>(part.LuceneAnalyzerSelectorMappingsSerialized); + }); + + part.LuceneAnalyzerSelectorMappingsField.Setter((value) => { + part.LuceneAnalyzerSelectorMappingsSerialized = value == null ? "[]" : jsonConverter.Serialize(value); + return value; + }); + }); + } + + protected override void GetItemMetadata(GetContentItemMetadataContext context) { + if (context.ContentItem.ContentType != "Site") return; + + base.GetItemMetadata(context); + + context.Metadata.EditorGroupInfo.Add(new GroupInfo(T("Lucene Settings")) { Id = "LuceneSettings" }); + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Lucene/Lucene.csproj b/src/Orchard.Web/Modules/Lucene/Lucene.csproj index 5f855dd9d..afed44902 100644 --- a/src/Orchard.Web/Modules/Lucene/Lucene.csproj +++ b/src/Orchard.Web/Modules/Lucene/Lucene.csproj @@ -97,8 +97,12 @@ + + + + @@ -108,6 +112,7 @@ + @@ -127,6 +132,13 @@ + + + + + + + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) diff --git a/src/Orchard.Web/Modules/Lucene/Models/LuceneAnalyzerSelectorMapping.cs b/src/Orchard.Web/Modules/Lucene/Models/LuceneAnalyzerSelectorMapping.cs new file mode 100644 index 000000000..998004a16 --- /dev/null +++ b/src/Orchard.Web/Modules/Lucene/Models/LuceneAnalyzerSelectorMapping.cs @@ -0,0 +1,6 @@ +namespace Lucene.Models { + public class LuceneAnalyzerSelectorMapping { + public string IndexName { get; set; } + public string AnalyzerName { get; set; } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Lucene/Models/LuceneSettingsPart.cs b/src/Orchard.Web/Modules/Lucene/Models/LuceneSettingsPart.cs new file mode 100644 index 000000000..1bbbbacdb --- /dev/null +++ b/src/Orchard.Web/Modules/Lucene/Models/LuceneSettingsPart.cs @@ -0,0 +1,21 @@ +using Lucene.Models; +using Orchard.ContentManagement; +using Orchard.ContentManagement.Utilities; +using System.Collections.Generic; + +namespace Lucene.Models { + public class LuceneSettingsPart : ContentPart { + public string LuceneAnalyzerSelectorMappingsSerialized { + get { return this.Retrieve(x => x.LuceneAnalyzerSelectorMappingsSerialized); } + set { this.Store(x => x.LuceneAnalyzerSelectorMappingsSerialized, value); } + } + + private readonly LazyField> _luceneAnalyzerSelectorMappings = new LazyField>(); + internal LazyField> LuceneAnalyzerSelectorMappingsField { get { return _luceneAnalyzerSelectorMappings; } + } + public IEnumerable LuceneAnalyzerSelectorMappings { + get { return _luceneAnalyzerSelectorMappings.Value; } + set { _luceneAnalyzerSelectorMappings.Value = value; } + } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Lucene/Placement.info b/src/Orchard.Web/Modules/Lucene/Placement.info new file mode 100644 index 000000000..e901b27c4 --- /dev/null +++ b/src/Orchard.Web/Modules/Lucene/Placement.info @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Lucene/Services/DefaultLuceneAnalyzerProvider.cs b/src/Orchard.Web/Modules/Lucene/Services/DefaultLuceneAnalyzerProvider.cs index 8f7905727..081fb3284 100644 --- a/src/Orchard.Web/Modules/Lucene/Services/DefaultLuceneAnalyzerProvider.cs +++ b/src/Orchard.Web/Modules/Lucene/Services/DefaultLuceneAnalyzerProvider.cs @@ -1,34 +1,46 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using Lucene.Models; using Lucene.Net.Analysis; using Lucene.Net.Analysis.Standard; using Orchard; +using Orchard.ContentManagement; +using System.Collections.Generic; +using System.Linq; namespace Lucene.Services { public class DefaultLuceneAnalyzerProvider : ILuceneAnalyzerProvider { - + private readonly IWorkContextAccessor _wca; private IEnumerable _analyzerSelectors; - public DefaultLuceneAnalyzerProvider(IEnumerable analyzerSelectors) { + public DefaultLuceneAnalyzerProvider(IEnumerable analyzerSelectors, IWorkContextAccessor wca) { _analyzerSelectors = analyzerSelectors; + _wca = wca; } public Analyzer GetAnalyzer(string indexName) { + var luceneSettingsPart = _wca + .GetContext() + .CurrentSite + .As(); + if (luceneSettingsPart == null) { + return new StandardAnalyzer(LuceneIndexProvider.LuceneVersion); + } + + var currentIndexMapping = luceneSettingsPart + .LuceneAnalyzerSelectorMappings + .FirstOrDefault(mapping => mapping.IndexName == indexName); + if (currentIndexMapping == null) { + return new StandardAnalyzer(LuceneIndexProvider.LuceneVersion); + } + var analyzer = _analyzerSelectors + .Where(x => x.Name == currentIndexMapping.AnalyzerName) .Select(x => x.GetLuceneAnalyzer(indexName)) .Where(x => x != null) .OrderByDescending(x => x.Priority) .Select(x => x.Analyzer) .FirstOrDefault(); - if (analyzer != null) { - return analyzer; - } - - return new StandardAnalyzer(LuceneIndexProvider.LuceneVersion); + return analyzer != null ? analyzer : new StandardAnalyzer(LuceneIndexProvider.LuceneVersion); } } } diff --git a/src/Orchard.Web/Modules/Lucene/Services/DefaultLuceneAnalyzerSelector.cs b/src/Orchard.Web/Modules/Lucene/Services/DefaultLuceneAnalyzerSelector.cs index 9202aedc0..d58d430e9 100644 --- a/src/Orchard.Web/Modules/Lucene/Services/DefaultLuceneAnalyzerSelector.cs +++ b/src/Orchard.Web/Modules/Lucene/Services/DefaultLuceneAnalyzerSelector.cs @@ -12,5 +12,7 @@ namespace Lucene.Services { Analyzer = new StandardAnalyzer(LuceneIndexProvider.LuceneVersion) }; } + + public string Name { get { return "Default"; } } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Lucene/Services/ILuceneAnalyzerSelector.cs b/src/Orchard.Web/Modules/Lucene/Services/ILuceneAnalyzerSelector.cs index 9a9c2319f..366983fd5 100644 --- a/src/Orchard.Web/Modules/Lucene/Services/ILuceneAnalyzerSelector.cs +++ b/src/Orchard.Web/Modules/Lucene/Services/ILuceneAnalyzerSelector.cs @@ -1,11 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using Orchard; +using Orchard; namespace Lucene.Services { public interface ILuceneAnalyzerSelector : IDependency { LuceneAnalyzerSelectorResult GetLuceneAnalyzer(string indexName); + string Name { get; } } } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Lucene/ViewModels/LuceneSettingsPartEditViewModel.cs b/src/Orchard.Web/Modules/Lucene/ViewModels/LuceneSettingsPartEditViewModel.cs new file mode 100644 index 000000000..1937a1791 --- /dev/null +++ b/src/Orchard.Web/Modules/Lucene/ViewModels/LuceneSettingsPartEditViewModel.cs @@ -0,0 +1,14 @@ +using Lucene.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; + +namespace Lucene.ViewModels { + public class LuceneSettingsPartEditViewModel { + public LuceneAnalyzerSelectorMapping[] LuceneAnalyzerSelectorMappings { get; set; } + + public IEnumerable LuceneAnalyzerSelectors { get; set; } + } +} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Lucene/Views/EditorTemplates/Parts.LuceneSettings.cshtml b/src/Orchard.Web/Modules/Lucene/Views/EditorTemplates/Parts.LuceneSettings.cshtml new file mode 100644 index 000000000..0eee23452 --- /dev/null +++ b/src/Orchard.Web/Modules/Lucene/Views/EditorTemplates/Parts.LuceneSettings.cshtml @@ -0,0 +1,26 @@ +@model Lucene.ViewModels.LuceneSettingsPartEditViewModel + +@using System.Linq + +
+ @T("Lucene Settings") + @if (!Model.LuceneAnalyzerSelectorMappings.Any()) { + @T("There is currently no mapping. Create an index first.") + } + else { +
    + @for (int i = 0; i < Model.LuceneAnalyzerSelectorMappings.Length; i++) { +
  • + @Html.HiddenFor(m => Model.LuceneAnalyzerSelectorMappings[i].IndexName) + @Html.LabelFor(m => Model.LuceneAnalyzerSelectorMappings[i].AnalyzerName, T("Analyzer name for the \"{0}\" index", Model.LuceneAnalyzerSelectorMappings[i].IndexName)) + @Html.DropDownListFor(m => Model.LuceneAnalyzerSelectorMappings[i].AnalyzerName, new SelectList( + Model.LuceneAnalyzerSelectors, + "Text", + "Value", + Model.LuceneAnalyzerSelectorMappings[i].AnalyzerName + )) +
  • + } +
+ } +
\ No newline at end of file From e41e9079d311f07444d67d2411dbc697b3267d62 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Mon, 27 Mar 2017 13:21:35 -0700 Subject: [PATCH 18/18] Fixing content file marker for tests --- src/Orchard.Web/Modules/Lucene/Lucene.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Orchard.Web/Modules/Lucene/Lucene.csproj b/src/Orchard.Web/Modules/Lucene/Lucene.csproj index afed44902..8fb7fbcfe 100644 --- a/src/Orchard.Web/Modules/Lucene/Lucene.csproj +++ b/src/Orchard.Web/Modules/Lucene/Lucene.csproj @@ -136,7 +136,7 @@
- +