From ae18e0b8175f4c735c8c0c56fb639f52a8b24296 Mon Sep 17 00:00:00 2001 From: jtkech Date: Thu, 7 May 2015 21:37:04 +0200 Subject: [PATCH 01/24] #5235: Awaiting activities not cleared on saving --- .../Modules/Orchard.Workflows/Controllers/AdminController.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Orchard.Web/Modules/Orchard.Workflows/Controllers/AdminController.cs b/src/Orchard.Web/Modules/Orchard.Workflows/Controllers/AdminController.cs index 51bb9a98e..add367c84 100644 --- a/src/Orchard.Web/Modules/Orchard.Workflows/Controllers/AdminController.cs +++ b/src/Orchard.Web/Modules/Orchard.Workflows/Controllers/AdminController.cs @@ -265,6 +265,7 @@ namespace Orchard.Workflows.Controllers { var activitiesIndex = new Dictionary(); workflowDefinitionRecord.ActivityRecords.Clear(); + workflowDefinitionRecord.WorkflowRecords.Clear(); foreach (var activity in state.Activities) { ActivityRecord activityRecord; From 7cdb984f4fd0cb8cdfcc59d0b4c1394e9fb346dd Mon Sep 17 00:00:00 2001 From: Xeevis Date: Wed, 13 May 2015 15:24:46 +0200 Subject: [PATCH 02/24] #5224: Fix for missing charset in response header for cached output --- .../Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs b/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs index f93e4c855..a92736ae1 100644 --- a/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs +++ b/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs @@ -447,6 +447,9 @@ namespace Orchard.OutputCache.Filters { private void ServeCachedItem(ActionExecutingContext filterContext, CacheItem cacheItem) { var response = filterContext.HttpContext.Response; + // Fix for missing charset in response headers + response.Charset = response.Charset; + // Adds some caching information to the output if requested. if (CacheSettings.DebugMode) { response.AddHeader("X-Cached-On", cacheItem.CachedOnUtc.ToString("r")); From 2339bdc9663cdc27efb17ae5b020f9c29ebaf985 Mon Sep 17 00:00:00 2001 From: mvarblow Date: Wed, 13 May 2015 16:45:55 -0400 Subject: [PATCH 03/24] Update SslSettingsPartDriver.cs Fixed issue 5274 --- .../Drivers/SslSettingsPartDriver.cs | 21 ++----------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.SecureSocketsLayer/Drivers/SslSettingsPartDriver.cs b/src/Orchard.Web/Modules/Orchard.SecureSocketsLayer/Drivers/SslSettingsPartDriver.cs index fa259a1cf..89dd0cd63 100644 --- a/src/Orchard.Web/Modules/Orchard.SecureSocketsLayer/Drivers/SslSettingsPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.SecureSocketsLayer/Drivers/SslSettingsPartDriver.cs @@ -36,25 +36,8 @@ namespace Orchard.SecureSocketsLayer.Drivers { } protected override void Importing(SslSettingsPart part, ImportContentContext context) { - var elementName = part.PartDefinition.Name; - part.Enabled = bool.Parse(context.Attribute(elementName, "Enabled") ?? "false"); - part.SecureEverything = bool.Parse(context.Attribute(elementName, "SecureEverything") ?? "true"); - part.CustomEnabled = bool.Parse(context.Attribute(elementName, "CustomEnabled") ?? "false"); - part.Urls = context.Attribute(elementName, "Urls") ?? ""; - part.InsecureHostName = context.Attribute(elementName, "InsecureHostName") ?? ""; - part.SecureHostName = context.Attribute(elementName, "SecureHostName") ?? ""; - + base.Importing(part, context); _signals.Trigger(SslSettingsPart.CacheKey); } - - protected override void Exporting(SslSettingsPart part, ExportContentContext context) { - var el = context.Element(part.PartDefinition.Name); - el.SetAttributeValue("Enabled", part.Enabled); - el.SetAttributeValue("SecureEverything", part.SecureEverything); - el.SetAttributeValue("CustomEnabled", part.CustomEnabled); - el.SetAttributeValue("Urls", part.Urls); - el.SetAttributeValue("InsecureHostName", part.InsecureHostName); - el.SetAttributeValue("SecureHostName", part.SecureHostName); - } } -} \ No newline at end of file +} From f5862bd62885f154c2b9c0d06379a0cf25071b86 Mon Sep 17 00:00:00 2001 From: mvarblow Date: Wed, 13 May 2015 16:54:23 -0400 Subject: [PATCH 04/24] Update MediaController.cs Fix for issue https://github.com/OrchardCMS/Orchard/issues/5275. The fix is to return the FolderPath element in the response to the media search request so that the folderPath check in the javascript code succeeds. --- .../Modules/Orchard.Search/Controllers/MediaController.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Search/Controllers/MediaController.cs b/src/Orchard.Web/Modules/Orchard.Search/Controllers/MediaController.cs index e7e029c19..0acb1c2ed 100644 --- a/src/Orchard.Web/Modules/Orchard.Search/Controllers/MediaController.cs +++ b/src/Orchard.Web/Modules/Orchard.Search/Controllers/MediaController.cs @@ -59,10 +59,11 @@ namespace Orchard.Search.Controllers { var viewModel = new MediaManagerMediaItemsViewModel { MediaItems = mediaItems, - MediaItemsCount = mediaPartsCount + MediaItemsCount = mediaPartsCount, + FolderPath = folderPath }; return View(viewModel); } } -} \ No newline at end of file +} From fa7bf025b973b1296f7806494caefa97ee8fd18d Mon Sep 17 00:00:00 2001 From: mvarblow Date: Wed, 13 May 2015 16:57:10 -0400 Subject: [PATCH 05/24] Update MediaItems.cshtml --- .../Modules/Orchard.Search/Views/Media/MediaItems.cshtml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Search/Views/Media/MediaItems.cshtml b/src/Orchard.Web/Modules/Orchard.Search/Views/Media/MediaItems.cshtml index 5263d9707..3dad0b9ef 100644 --- a/src/Orchard.Web/Modules/Orchard.Search/Views/Media/MediaItems.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Search/Views/Media/MediaItems.cshtml @@ -17,8 +17,9 @@ mimeTypeClass = x.MediaPart.MimeType.HtmlClassify(), thumbnail = Display(x.Shape).ToString(), editLink = Url.ItemEditUrl(x.MediaPart) - }).ToArray() + }).ToArray(), + folderPath = Model.FolderPath })) } - \ No newline at end of file + From 4d242e83df4f61e0f20adea963cbfadd35efc120 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Thu, 21 May 2015 17:24:45 +0200 Subject: [PATCH 06/24] #5306: Injecting HttpContextBase directly. This will ensure that an actual HttpContext object will be available in case of background task operations thanks to the way HttpContextBase is registered (providing a placeholder object in case of background operations). --- .../Services/CurrentControllerAccessor.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Services/CurrentControllerAccessor.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Services/CurrentControllerAccessor.cs index 9ae1abeaa..5cd9eeb0a 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Services/CurrentControllerAccessor.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Services/CurrentControllerAccessor.cs @@ -1,16 +1,19 @@ +using System.Web; using System.Web.Mvc; using Orchard.Layouts.Filters; -using Orchard.Mvc; namespace Orchard.Layouts.Services { public class CurrentControllerAccessor : ICurrentControllerAccessor { - private readonly IHttpContextAccessor _httpContextAccessor; - public CurrentControllerAccessor(IHttpContextAccessor httpContextAccessor) { - _httpContextAccessor = httpContextAccessor; + private readonly IWorkContextAccessor _wca; + private readonly HttpContextBase _httpContext; + + public CurrentControllerAccessor(IWorkContextAccessor wca, HttpContextBase httpContext) { + _wca = wca; + _httpContext = httpContext; } public Controller CurrentController { - get { return (Controller) _httpContextAccessor.Current().Items[ControllerAccessorFilter.CurrentControllerKey]; } + get { return (Controller) _httpContext.Items[ControllerAccessorFilter.CurrentControllerKey]; } } } } \ No newline at end of file From ce36e115d0d42397abd45ec7c587a99734972823 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Thu, 21 May 2015 17:25:50 +0200 Subject: [PATCH 07/24] Removed unnecessary field. --- .../Orchard.Layouts/Services/CurrentControllerAccessor.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Services/CurrentControllerAccessor.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Services/CurrentControllerAccessor.cs index 5cd9eeb0a..546a3f8df 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Services/CurrentControllerAccessor.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Services/CurrentControllerAccessor.cs @@ -4,11 +4,9 @@ using Orchard.Layouts.Filters; namespace Orchard.Layouts.Services { public class CurrentControllerAccessor : ICurrentControllerAccessor { - private readonly IWorkContextAccessor _wca; private readonly HttpContextBase _httpContext; - public CurrentControllerAccessor(IWorkContextAccessor wca, HttpContextBase httpContext) { - _wca = wca; + public CurrentControllerAccessor(HttpContextBase httpContext) { _httpContext = httpContext; } From 6eb9e0d457c303c407a07e5c94c3566386715555 Mon Sep 17 00:00:00 2001 From: Skrypt Date: Thu, 21 May 2015 16:10:09 -0400 Subject: [PATCH 08/24] Fixing #5281 --- src/Orchard.Web/Core/Navigation/Views/Admin/Index.cshtml | 2 +- .../Views/EditorTemplates/Parts.MenuWidget.Edit.cshtml | 2 +- .../EditorTemplates/Parts.Navigation.Menu.Edit.cshtml | 2 +- .../Views/EditorTemplates/Parts.Navigation.Edit.cshtml | 2 +- src/Orchard/Mvc/Html/ContentItemExtensions.cs | 8 ++++++-- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Orchard.Web/Core/Navigation/Views/Admin/Index.cshtml b/src/Orchard.Web/Core/Navigation/Views/Admin/Index.cshtml index bb81da637..8a2c7a776 100644 --- a/src/Orchard.Web/Core/Navigation/Views/Admin/Index.cshtml +++ b/src/Orchard.Web/Core/Navigation/Views/Admin/Index.cshtml @@ -22,7 +22,7 @@ @if (hasPermission) { diff --git a/src/Orchard.Web/Core/Navigation/Views/EditorTemplates/Parts.MenuWidget.Edit.cshtml b/src/Orchard.Web/Core/Navigation/Views/EditorTemplates/Parts.MenuWidget.Edit.cshtml index c505a208b..cb568e8ff 100644 --- a/src/Orchard.Web/Core/Navigation/Views/EditorTemplates/Parts.MenuWidget.Edit.cshtml +++ b/src/Orchard.Web/Core/Navigation/Views/EditorTemplates/Parts.MenuWidget.Edit.cshtml @@ -6,7 +6,7 @@ @Html.LabelFor(m => m.CurrentMenuId, T("For Menu")) @T("Select which menu you want to display") diff --git a/src/Orchard.Web/Core/Navigation/Views/EditorTemplates/Parts.Navigation.Menu.Edit.cshtml b/src/Orchard.Web/Core/Navigation/Views/EditorTemplates/Parts.Navigation.Menu.Edit.cshtml index c81dd1ede..a51394ccc 100644 --- a/src/Orchard.Web/Core/Navigation/Views/EditorTemplates/Parts.Navigation.Menu.Edit.cshtml +++ b/src/Orchard.Web/Core/Navigation/Views/EditorTemplates/Parts.Navigation.Menu.Edit.cshtml @@ -11,7 +11,7 @@
@T("Select which menu you want the content item to be displayed on.") diff --git a/src/Orchard.Web/Modules/Orchard.ContentPicker/Views/EditorTemplates/Parts.Navigation.Edit.cshtml b/src/Orchard.Web/Modules/Orchard.ContentPicker/Views/EditorTemplates/Parts.Navigation.Edit.cshtml index 8234426e4..972007790 100644 --- a/src/Orchard.Web/Modules/Orchard.ContentPicker/Views/EditorTemplates/Parts.Navigation.Edit.cshtml +++ b/src/Orchard.Web/Modules/Orchard.ContentPicker/Views/EditorTemplates/Parts.Navigation.Edit.cshtml @@ -29,7 +29,7 @@
@T("Select which menu you want the content item to be added on.") diff --git a/src/Orchard/Mvc/Html/ContentItemExtensions.cs b/src/Orchard/Mvc/Html/ContentItemExtensions.cs index 4f30ea2a9..a6fc28281 100644 --- a/src/Orchard/Mvc/Html/ContentItemExtensions.cs +++ b/src/Orchard/Mvc/Html/ContentItemExtensions.cs @@ -7,11 +7,15 @@ using Orchard.Utility.Extensions; namespace Orchard.Mvc.Html { public static class ContentItemExtensions { - public static MvcHtmlString ItemDisplayText(this HtmlHelper html, IContent content) { + public static MvcHtmlString ItemDisplayText(this HtmlHelper html, IContent content, bool encode = true) { var metadata = content.ContentItem.ContentManager.GetItemMetadata(content); if (metadata.DisplayText == null) return null; - return MvcHtmlString.Create(html.Encode(metadata.DisplayText)); + if (encode) { + return MvcHtmlString.Create(html.Encode(metadata.DisplayText)); + } else { + return MvcHtmlString.Create(metadata.DisplayText); + } } public static MvcHtmlString ItemDisplayLink(this HtmlHelper html, IContent content) { From 754114c8e6edae63ce69886e9d5a3df4571cadbb Mon Sep 17 00:00:00 2001 From: Skrypt Date: Thu, 21 May 2015 16:23:27 -0400 Subject: [PATCH 09/24] Rebase on 1.9.x since this is a bug fix Fixing #4963 --- .../Navigation/Scripts/navigation-admin.js | 2 +- .../Core/Navigation/Views/Admin/Index.cshtml | 6 +- .../Orchard.Modules/Scripts/features.admin.js | 2 +- .../Scripts/features.admin.min.js | 5 +- .../Views/Admin/Features.cshtml | 57 +++++++++---------- 5 files changed, 34 insertions(+), 38 deletions(-) diff --git a/src/Orchard.Web/Core/Navigation/Scripts/navigation-admin.js b/src/Orchard.Web/Core/Navigation/Scripts/navigation-admin.js index 347854cd5..08dc685de 100644 --- a/src/Orchard.Web/Core/Navigation/Scripts/navigation-admin.js +++ b/src/Orchard.Web/Core/Navigation/Scripts/navigation-admin.js @@ -42,7 +42,7 @@ // display a message on leave if changes have been made window.onbeforeunload = function (e) { - return leaveConfirmation; + return $("
").html(leaveConfirmation).text(); }; // cancel leaving message on save diff --git a/src/Orchard.Web/Core/Navigation/Views/Admin/Index.cshtml b/src/Orchard.Web/Core/Navigation/Views/Admin/Index.cshtml index bb81da637..9388e2ae4 100644 --- a/src/Orchard.Web/Core/Navigation/Views/Admin/Index.cshtml +++ b/src/Orchard.Web/Core/Navigation/Views/Admin/Index.cshtml @@ -134,12 +134,12 @@ @using (Script.Foot()) { } \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Modules/Scripts/features.admin.js b/src/Orchard.Web/Modules/Orchard.Modules/Scripts/features.admin.js index ad88615d8..7fd4e0ae9 100644 --- a/src/Orchard.Web/Modules/Orchard.Modules/Scripts/features.admin.js +++ b/src/Orchard.Web/Modules/Orchard.Modules/Scripts/features.admin.js @@ -43,7 +43,7 @@ var force = actionLink.data("feature-force"); var dependants = actionLink.data("feature-dependants"); - if (!dependants || /^\s*$/.test(dependants) || confirm(confirmDisableMessage + "\n\n" + dependants)) { + if (!dependants || /^\s*$/.test(dependants) || confirm($("
").html(confirmDisableMessage + "\n\n" + dependants).text())) { $("[name='submit.BulkExecute']").val("yes"); $("[name='featureIds']").val(featureId); diff --git a/src/Orchard.Web/Modules/Orchard.Modules/Scripts/features.admin.min.js b/src/Orchard.Web/Modules/Orchard.Modules/Scripts/features.admin.min.js index dc6081236..1b85a1176 100644 --- a/src/Orchard.Web/Modules/Orchard.Modules/Scripts/features.admin.min.js +++ b/src/Orchard.Web/Modules/Orchard.Modules/Scripts/features.admin.min.js @@ -1,4 +1 @@ -$(function(){var n=function(){var n=$(".bulk-actions-wrapper").addClass("visible"),t=$(".switch-for-switchable");t.prepend(n);$("#search-box").focus().keyup(function(){var n=$(this).val(),t;if(n==""){$("li.category").show();$("li.feature:hidden").show();return}$("li.feature").each(function(){var t=$(this),i=t.find("h3:first").text();i.toLowerCase().indexOf(n.toLowerCase())>=0?t.show():t.hide()});$("li.category:hidden").show();t=$("li.category:not(:has(li.feature:visible))").hide()})},t=function(){$("li.feature h3").on("change","input[type='checkbox']",function(){var n=$(this).is(":checked"),t=$(this).parents("li.feature:first");t.toggleClass("selected",n)})},i=function(){$("li.feature .actions").on("click","a[data-feature-action]",function(n){var t=$(this),r=t.data("feature-id"),u=t.data("feature-action"),f=t.data("feature-force"),i=t.data("feature-dependants");(!i||/^\s*$/.test(i)||confirm(confirmDisableMessage+"\n\n"+i))&&($("[name='submit.BulkExecute']").val("yes"),$("[name='featureIds']").val(r),$("[name='bulkAction']").val(u),$("[name='force']").val(f),t.parents("form:first").submit());n.preventDefault()})};n();t();i()}); -/* -//# sourceMappingURL=features.admin.min.js.map -*/ \ No newline at end of file +$(function(){var n=function(){var n=$(".bulk-actions-wrapper").addClass("visible"),t=$(".switch-for-switchable");t.prepend(n);$("#search-box").keyup(function(){var n=$(this).val(),t;if(n==""){$("li.category").show();$("li.feature:hidden").show();return}$("li.feature").each(function(){var t=$(this),i=t.find("h3:first").text();i.toLowerCase().indexOf(n.toLowerCase())>=0?t.show():t.hide()});$("li.category:hidden").show();t=$("li.category:not(:has(li.feature:visible))").hide()})},t=function(){$("li.feature h3").on("change","input[type='checkbox']",function(){var n=$(this).is(":checked"),t=$(this).parents("li.feature:first");t.toggleClass("selected",n)})},i=function(){$("li.feature .actions").on("click","a[data-feature-action]",function(n){var t=$(this),r=t.data("feature-id"),u=t.data("feature-action"),f=t.data("feature-force"),i=t.data("feature-dependants");(!i||/^\s*$/.test(i)||confirm($("
").html(confirmDisableMessage+"\n\n"+i).text()))&&($("[name='submit.BulkExecute']").val("yes"),$("[name='featureIds']").val(r),$("[name='bulkAction']").val(u),$("[name='force']").val(f),t.parents("form:first").submit());n.preventDefault()})};n();t();i()}); \ No newline at end of file diff --git a/src/Orchard.Web/Modules/Orchard.Modules/Views/Admin/Features.cshtml b/src/Orchard.Web/Modules/Orchard.Modules/Views/Admin/Features.cshtml index 36295b52f..ec6da75a3 100644 --- a/src/Orchard.Web/Modules/Orchard.Modules/Views/Admin/Features.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Modules/Views/Admin/Features.cshtml @@ -16,29 +16,29 @@ @if (Model.Features.Any()) { using (Html.BeginFormAntiForgeryPost()) { - @Html.Hidden("submit.BulkExecute") - @Html.Hidden("force", true) - @Html.Hidden("featureIds") -
-
- - -
-
- - - -
-
+ @Html.Hidden("submit.BulkExecute") + @Html.Hidden("force", true) + @Html.Hidden("featureIds") +
+
+ + +
+
+ + + +
+
-
    - @{ +
      + @{ var featureGroups = Model.Features.OrderBy(f => f.Descriptor.Category, new DoghouseComparer("Core")).GroupBy(f => f.Descriptor.Category).ToList(); foreach (var featureGroup in featureGroups) { if (!featureGroup.Any(x => Model.IsAllowed(x.Descriptor.Extension))) { @@ -98,8 +98,7 @@ @featureName - } - else { + } else { @featureName } @@ -138,14 +137,14 @@ }
    } - } -
} + } + } using (Script.Foot()) { } } \ No newline at end of file From ef2abe14cbb35b3f42c8a1b6f9c606b1c299071d Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Fri, 22 May 2015 15:37:51 +0200 Subject: [PATCH 10/24] #5306: Implemented a background HttpContext factory. This change instantiates an actual HttpContext object during background sweeps so that Razor templates using Html Helpers (that require HttpContext.Current to be not-null) won't fai lwhen being rendered. --- src/Orchard/BackgroundHttpContext.cs | 38 ++++++++++++++++++++++++ src/Orchard/Mvc/HttpContextAccessor.cs | 39 +++++++++++++++++++++++++ src/Orchard/Mvc/IHttpContextAccessor.cs | 33 +-------------------- src/Orchard/Mvc/MvcModule.cs | 2 +- src/Orchard/Orchard.Framework.csproj | 2 ++ src/Orchard/Tasks/BackgroundService.cs | 10 +++++-- 6 files changed, 88 insertions(+), 36 deletions(-) create mode 100644 src/Orchard/BackgroundHttpContext.cs create mode 100644 src/Orchard/Mvc/HttpContextAccessor.cs diff --git a/src/Orchard/BackgroundHttpContext.cs b/src/Orchard/BackgroundHttpContext.cs new file mode 100644 index 000000000..1b4f68f3b --- /dev/null +++ b/src/Orchard/BackgroundHttpContext.cs @@ -0,0 +1,38 @@ +using System.IO; +using System.Web; +using Orchard.Settings; + +namespace Orchard { + /// + /// A factory class that creates an HttpContext instance and initializes the HttpContext.Current property with that instance. + /// This is useful when rendering views from a background thread, as some Html Helpers access HttpContext.Current directly, thus preventing a NullReferenceException. + /// + public class BackgroundHttpContextFactory : IBackgroundHttpContextFactory { + public const string IsBackgroundHttpContextKey = "IsBackgroundHttpContext"; + private readonly ISiteService _siteService; + public BackgroundHttpContextFactory(ISiteService siteService) { + _siteService = siteService; + } + + public HttpContext CreateHttpContext() { + var url = _siteService.GetSiteSettings().BaseUrl; + var httpContext = new HttpContext(new HttpRequest("", url, ""), new HttpResponse(new StringWriter())); + + httpContext.Items[IsBackgroundHttpContextKey] = true; + + return httpContext; + } + + public void InitializeHttpContext() { + if (HttpContext.Current != null) + return; + + HttpContext.Current = CreateHttpContext(); + } + } + + public interface IBackgroundHttpContextFactory : IDependency { + HttpContext CreateHttpContext(); + void InitializeHttpContext(); + } +} diff --git a/src/Orchard/Mvc/HttpContextAccessor.cs b/src/Orchard/Mvc/HttpContextAccessor.cs new file mode 100644 index 000000000..615d527df --- /dev/null +++ b/src/Orchard/Mvc/HttpContextAccessor.cs @@ -0,0 +1,39 @@ +using System; +using System.Web; + +namespace Orchard.Mvc { + public class HttpContextAccessor : IHttpContextAccessor { + private HttpContextBase _httpContext; + + public HttpContextBase Current() { + var httpContext = GetStaticProperty(); + return !IsBackgroundHttpContext(httpContext) ? new HttpContextWrapper(httpContext) : _httpContext; + } + + public void Set(HttpContextBase httpContext) { + _httpContext = httpContext; + } + + private static bool IsBackgroundHttpContext(HttpContext httpContext) { + return httpContext == null || httpContext.Items.Contains(BackgroundHttpContextFactory.IsBackgroundHttpContextKey); + } + + private static HttpContext GetStaticProperty() { + var httpContext = HttpContext.Current; + if (httpContext == null) { + return null; + } + + try { + // The "Request" property throws at application startup on IIS integrated pipeline mode. + if (httpContext.Request == null) { + return null; + } + } + catch (Exception) { + return null; + } + return httpContext; + } + } +} \ No newline at end of file diff --git a/src/Orchard/Mvc/IHttpContextAccessor.cs b/src/Orchard/Mvc/IHttpContextAccessor.cs index 91208d314..462887fee 100644 --- a/src/Orchard/Mvc/IHttpContextAccessor.cs +++ b/src/Orchard/Mvc/IHttpContextAccessor.cs @@ -1,39 +1,8 @@ -using System; -using System.Web; +using System.Web; namespace Orchard.Mvc { public interface IHttpContextAccessor { HttpContextBase Current(); void Set(HttpContextBase httpContext); } - - public class HttpContextAccessor : IHttpContextAccessor { - private HttpContextBase _httpContext; - - public HttpContextBase Current() { - var httpContext = GetStaticProperty(); - return httpContext != null ? new HttpContextWrapper(httpContext) : _httpContext; - } - - public void Set(HttpContextBase httpContext) { - _httpContext = httpContext; - } - - private HttpContext GetStaticProperty() { - var httpContext = HttpContext.Current; - if (httpContext == null) { - return null; - } - - try { - if (httpContext.Request == null) { - return null; - } - } - catch (Exception) { - return null; - } - return httpContext; - } - } } diff --git a/src/Orchard/Mvc/MvcModule.cs b/src/Orchard/Mvc/MvcModule.cs index 1e0c49ce6..e1e8c19eb 100644 --- a/src/Orchard/Mvc/MvcModule.cs +++ b/src/Orchard/Mvc/MvcModule.cs @@ -28,7 +28,7 @@ namespace Orchard.Mvc { return false; try { - // The "Request" property throws at application startup on IIS integrated pipeline mode + // The "Request" property throws at application startup on IIS integrated pipeline mode. var req = HttpContext.Current.Request; } catch (Exception) { diff --git a/src/Orchard/Orchard.Framework.csproj b/src/Orchard/Orchard.Framework.csproj index a7093e72b..65099a4cc 100644 --- a/src/Orchard/Orchard.Framework.csproj +++ b/src/Orchard/Orchard.Framework.csproj @@ -317,6 +317,7 @@ + @@ -644,6 +645,7 @@ + diff --git a/src/Orchard/Tasks/BackgroundService.cs b/src/Orchard/Tasks/BackgroundService.cs index 8956595bd..b952a6a26 100644 --- a/src/Orchard/Tasks/BackgroundService.cs +++ b/src/Orchard/Tasks/BackgroundService.cs @@ -16,24 +16,28 @@ namespace Orchard.Tasks { public class BackgroundService : IBackgroundService { private readonly IEnumerable _tasks; private readonly ITransactionManager _transactionManager; + private readonly IBackgroundHttpContextFactory _backgroundHttpContextFactory; private readonly string _shellName; - private readonly IContentManager _contentManager; public BackgroundService( IEnumerable tasks, ITransactionManager transactionManager, ShellSettings shellSettings, - IContentManager contentManager) { + IContentManager contentManager, + IBackgroundHttpContextFactory backgroundHttpContextFactory) { + _tasks = tasks; _transactionManager = transactionManager; + _backgroundHttpContextFactory = backgroundHttpContextFactory; _shellName = shellSettings.Name; - _contentManager = contentManager; Logger = NullLogger.Instance; } public ILogger Logger { get; set; } public void Sweep() { + _backgroundHttpContextFactory.InitializeHttpContext(); + foreach(var task in _tasks) { var taskName = task.GetType().FullName; From 3b5de0679f4464a1c8f49deddccc5fd3ea575331 Mon Sep 17 00:00:00 2001 From: Xeevis Date: Mon, 25 May 2015 01:08:59 +0200 Subject: [PATCH 11/24] #5109: Email field shouldn't specify email type in design mode When email type is specified on an input it triggers browser validation on that field which prevents administrator from inserting tokens like {User.Email}. --- .../Views/Elements/EmailField.Design.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Elements/EmailField.Design.cshtml b/src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Elements/EmailField.Design.cshtml index b0bae7455..f16f885b1 100644 --- a/src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Elements/EmailField.Design.cshtml +++ b/src/Orchard.Web/Modules/Orchard.DynamicForms/Views/Elements/EmailField.Design.cshtml @@ -5,7 +5,7 @@ var tagBuilder = TagBuilderExtensions.CreateElementTagBuilder(Model, "input"); tagBuilder.AddCssClass("text design"); - tagBuilder.Attributes["type"] = "email"; + tagBuilder.Attributes["type"] = "text"; tagBuilder.Attributes["value"] = element.Value; tagBuilder.Attributes["name"] = element.Name; } From 1c81a773028cedf5a74e71f3ca5c260b9ef98bee Mon Sep 17 00:00:00 2001 From: jtkech Date: Mon, 25 May 2015 21:37:37 +0200 Subject: [PATCH 12/24] Update AdminController.cs --- .../Orchard.Workflows/Controllers/AdminController.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Orchard.Web/Modules/Orchard.Workflows/Controllers/AdminController.cs b/src/Orchard.Web/Modules/Orchard.Workflows/Controllers/AdminController.cs index add367c84..69d2d2641 100644 --- a/src/Orchard.Web/Modules/Orchard.Workflows/Controllers/AdminController.cs +++ b/src/Orchard.Web/Modules/Orchard.Workflows/Controllers/AdminController.cs @@ -159,6 +159,12 @@ namespace Orchard.Workflows.Controllers { return RedirectToAction("Edit", new { workflowDefinitionRecord.Id }); } + public JsonResult State(int? id) { + var workflowDefinitionRecord = id.HasValue ? _workflowDefinitionRecords.Get(id.Value) : null; + var isRunning = workflowDefinitionRecord != null ? workflowDefinitionRecord.WorkflowRecords.Any() : false; + return Json(new { isRunning = isRunning }, JsonRequestBehavior.AllowGet); + } + public ActionResult Edit(int id, string localId, int? workflowId) { if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to edit workflows"))) return new HttpUnauthorizedResult(); From ff9d7aca517a908e830fcda7f2e3d21ea94ece3b Mon Sep 17 00:00:00 2001 From: jtkech Date: Mon, 25 May 2015 21:42:00 +0200 Subject: [PATCH 13/24] Update Edit.cshtml --- .../Orchard.Workflows/Views/Admin/Edit.cshtml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Orchard.Web/Modules/Orchard.Workflows/Views/Admin/Edit.cshtml b/src/Orchard.Web/Modules/Orchard.Workflows/Views/Admin/Edit.cshtml index fdaf466b8..c1acd41b5 100644 --- a/src/Orchard.Web/Modules/Orchard.Workflows/Views/Admin/Edit.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Workflows/Views/Admin/Edit.cshtml @@ -42,6 +42,7 @@ // @@ -82,6 +84,16 @@ var workflow = loadWorkflow(localId); var data = JSON.stringify(workflow); $("[name='data']").val(data); + + $.ajax({ + url: stateUrl + "/" + $("#id").val(), + async: false, + success: function(state) { + if(state.isRunning && !confirm($("#confirm-delete-instances").val())) { + e.preventDefault(); + } + } + }); }); //]]> @@ -100,4 +112,4 @@ @using (Capture(Layout.Messages)) { -} \ No newline at end of file +} From 53e58f60fe2f588e76fcad3e26442eded8cc60f3 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Wed, 27 May 2015 16:36:51 +0200 Subject: [PATCH 14/24] #5306: Minor refactoring of background http context factory. --- ...oundHttpContext.cs => BackgroundHttpContextFactory.cs} | 7 +------ src/Orchard/IBackgroundHttpContextFactory.cs | 8 ++++++++ src/Orchard/Orchard.Framework.csproj | 3 ++- 3 files changed, 11 insertions(+), 7 deletions(-) rename src/Orchard/{BackgroundHttpContext.cs => BackgroundHttpContextFactory.cs} (89%) create mode 100644 src/Orchard/IBackgroundHttpContextFactory.cs diff --git a/src/Orchard/BackgroundHttpContext.cs b/src/Orchard/BackgroundHttpContextFactory.cs similarity index 89% rename from src/Orchard/BackgroundHttpContext.cs rename to src/Orchard/BackgroundHttpContextFactory.cs index 1b4f68f3b..9935e7dfc 100644 --- a/src/Orchard/BackgroundHttpContext.cs +++ b/src/Orchard/BackgroundHttpContextFactory.cs @@ -30,9 +30,4 @@ namespace Orchard { HttpContext.Current = CreateHttpContext(); } } - - public interface IBackgroundHttpContextFactory : IDependency { - HttpContext CreateHttpContext(); - void InitializeHttpContext(); - } -} +} \ No newline at end of file diff --git a/src/Orchard/IBackgroundHttpContextFactory.cs b/src/Orchard/IBackgroundHttpContextFactory.cs new file mode 100644 index 000000000..1437518f8 --- /dev/null +++ b/src/Orchard/IBackgroundHttpContextFactory.cs @@ -0,0 +1,8 @@ +using System.Web; + +namespace Orchard { + public interface IBackgroundHttpContextFactory : IDependency { + HttpContext CreateHttpContext(); + void InitializeHttpContext(); + } +} diff --git a/src/Orchard/Orchard.Framework.csproj b/src/Orchard/Orchard.Framework.csproj index 65099a4cc..c4cd91d8f 100644 --- a/src/Orchard/Orchard.Framework.csproj +++ b/src/Orchard/Orchard.Framework.csproj @@ -148,6 +148,7 @@ + @@ -645,7 +646,7 @@ - + From c2d18f216ac13dbd09760241afb7ceb3617346d0 Mon Sep 17 00:00:00 2001 From: jtkech Date: Thu, 28 May 2015 21:33:08 +0200 Subject: [PATCH 15/24] Update AdminController.cs --- .../Orchard.Workflows/Controllers/AdminController.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Orchard.Web/Modules/Orchard.Workflows/Controllers/AdminController.cs b/src/Orchard.Web/Modules/Orchard.Workflows/Controllers/AdminController.cs index 69d2d2641..30809e85d 100644 --- a/src/Orchard.Web/Modules/Orchard.Workflows/Controllers/AdminController.cs +++ b/src/Orchard.Web/Modules/Orchard.Workflows/Controllers/AdminController.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; +using System.Security.Authentication; using System.Security.Cryptography.X509Certificates; using System.Web; using System.Web.Mvc; @@ -160,8 +161,11 @@ namespace Orchard.Workflows.Controllers { } public JsonResult State(int? id) { + if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to edit workflows"))) + throw new AuthenticationException(""); + var workflowDefinitionRecord = id.HasValue ? _workflowDefinitionRecords.Get(id.Value) : null; - var isRunning = workflowDefinitionRecord != null ? workflowDefinitionRecord.WorkflowRecords.Any() : false; + var isRunning = workflowDefinitionRecord != null && workflowDefinitionRecord.WorkflowRecords.Any(); return Json(new { isRunning = isRunning }, JsonRequestBehavior.AllowGet); } From 3d25ca42c93e7418480dba361520c103c2fb0847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Ros?= Date: Thu, 28 May 2015 12:50:07 -0700 Subject: [PATCH 16/24] #5327: Fixing Orchard.Roles web.config file --- src/Orchard.Web/Modules/Orchard.Roles/Styles/Web.config | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Roles/Styles/Web.config b/src/Orchard.Web/Modules/Orchard.Roles/Styles/Web.config index 6e8ebec36..817198995 100644 --- a/src/Orchard.Web/Modules/Orchard.Roles/Styles/Web.config +++ b/src/Orchard.Web/Modules/Orchard.Roles/Styles/Web.config @@ -1,14 +1,5 @@ - - - - - - - - - From ee0bd03c0441c91a57b168966d12c1a86986f2b3 Mon Sep 17 00:00:00 2001 From: Lombiq Date: Sat, 30 May 2015 01:37:31 +0200 Subject: [PATCH 17/24] Fixing that Output Cache storage providers could fail with an ObjectDisposedException due to a deferred delegate execution causing the usage of dependencies from a disposed lifetime scope. --- .../Filters/OutputCacheFilter.cs | 51 +++++++++++-------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs b/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs index a92736ae1..0bc2d4337 100644 --- a/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs +++ b/src/Orchard.Web/Modules/Orchard.OutputCache/Filters/OutputCacheFilter.cs @@ -213,30 +213,39 @@ namespace Orchard.OutputCache.Filters { response.Filter = captureStream; captureStream.Captured += (output) => { try { - var cacheItem = new CacheItem() { - CachedOnUtc = _now, - Duration = cacheDuration, - GraceTime = cacheGraceTime, - Output = output, - ContentType = response.ContentType, - QueryString = filterContext.HttpContext.Request.Url.Query, - CacheKey = _cacheKey, - InvariantCacheKey = _invariantCacheKey, - Url = filterContext.HttpContext.Request.Url.AbsolutePath, - Tenant = _shellSettings.Name, - StatusCode = response.StatusCode, - Tags = new[] { _invariantCacheKey }.Union(contentItemIds).ToArray() - }; + // Since this is a callback any call to injected dependencies can result in an Autofac exception: "Instances + // cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it has already been disposed." + // To prevent access to the original lifetime scope a new work context scope should be created here and dependencies + // should be resolved from it. - // Write the rendered item to the cache. - _cacheStorageProvider.Remove(_cacheKey); - _cacheStorageProvider.Set(_cacheKey, cacheItem); + using (var scope = _workContextAccessor.CreateWorkContextScope()) { + var cacheItem = new CacheItem() { + CachedOnUtc = _now, + Duration = cacheDuration, + GraceTime = cacheGraceTime, + Output = output, + ContentType = response.ContentType, + QueryString = filterContext.HttpContext.Request.Url.Query, + CacheKey = _cacheKey, + InvariantCacheKey = _invariantCacheKey, + Url = filterContext.HttpContext.Request.Url.AbsolutePath, + Tenant = scope.Resolve().Name, + StatusCode = response.StatusCode, + Tags = new[] { _invariantCacheKey }.Union(contentItemIds).ToArray() + }; - Logger.Debug("Item '{0}' was written to cache.", _cacheKey); + // Write the rendered item to the cache. + var cacheStorageProvider = scope.Resolve(); + cacheStorageProvider.Remove(_cacheKey); + cacheStorageProvider.Set(_cacheKey, cacheItem); - // Also add the item tags to the tag cache. - foreach (var tag in cacheItem.Tags) { - _tagCache.Tag(tag, _cacheKey); + Logger.Debug("Item '{0}' was written to cache.", _cacheKey); + + // Also add the item tags to the tag cache. + var tagCache = scope.Resolve(); + foreach (var tag in cacheItem.Tags) { + tagCache.Tag(tag, _cacheKey); + } } } finally { From 917fd8425f7dde5aa15c2e5dce890754eff0a9bf Mon Sep 17 00:00:00 2001 From: Lombiq Date: Sun, 31 May 2015 18:15:29 +0200 Subject: [PATCH 18/24] Fixing ComponentNotRegisteredException during setup, fixes #4159 Added fix by jtkech. --- src/Orchard.Web/Modules/Orchard.Setup/SetupMode.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Orchard.Web/Modules/Orchard.Setup/SetupMode.cs b/src/Orchard.Web/Modules/Orchard.Setup/SetupMode.cs index 397536b20..a40f66d9e 100644 --- a/src/Orchard.Web/Modules/Orchard.Setup/SetupMode.cs +++ b/src/Orchard.Web/Modules/Orchard.Setup/SetupMode.cs @@ -67,6 +67,7 @@ namespace Orchard.Setup { builder.RegisterType().As().InstancePerLifetimeScope(); builder.RegisterType().As().InstancePerMatchingLifetimeScope("shell"); builder.RegisterType().As().SingleInstance(); + builder.RegisterType().As().InstancePerLifetimeScope(); // setup mode specific implementations of needed service interfaces builder.RegisterType().As().InstancePerLifetimeScope(); @@ -101,6 +102,12 @@ namespace Orchard.Setup { } + internal class SetupBackgroundService : IBackgroundService { + public void Sweep() { + // Don't run any background service in setup mode. + } + } + [UsedImplicitly] class SafeModeText : IText { public LocalizedString Get(string textHint, params object[] args) { From 6e94264df235803669774d096a03de95f83c0297 Mon Sep 17 00:00:00 2001 From: qt1 Date: Mon, 1 Jun 2015 02:07:42 +0300 Subject: [PATCH 19/24] Provide full table name prefix for migrations --- .../Utilities/NullInterpreter.cs | 5 +++++ .../DefaultDataMigrationInterpreter.cs | 20 ++++++++++++++++++- .../Interpreters/IDataMigrationInterpreter.cs | 1 + .../Data/Migration/Schema/SchemaBuilder.cs | 7 +++++++ 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/Orchard.Tests/DataMigration/Utilities/NullInterpreter.cs b/src/Orchard.Tests/DataMigration/Utilities/NullInterpreter.cs index a89772b80..025970a55 100644 --- a/src/Orchard.Tests/DataMigration/Utilities/NullInterpreter.cs +++ b/src/Orchard.Tests/DataMigration/Utilities/NullInterpreter.cs @@ -24,5 +24,10 @@ namespace Orchard.Tests.DataMigration.Utilities { public void Visit(DropForeignKeyCommand command) { } + + public string PrefixTableName(string tableName) { + return tableName; + } + } } \ No newline at end of file diff --git a/src/Orchard/Data/Migration/Interpreters/DefaultDataMigrationInterpreter.cs b/src/Orchard/Data/Migration/Interpreters/DefaultDataMigrationInterpreter.cs index 72f634421..566ef04a8 100644 --- a/src/Orchard/Data/Migration/Interpreters/DefaultDataMigrationInterpreter.cs +++ b/src/Orchard/Data/Migration/Interpreters/DefaultDataMigrationInterpreter.cs @@ -91,7 +91,7 @@ namespace Orchard.Data.Migration.Interpreters { RunPendingStatements(); } - private string PrefixTableName(string tableName) { + public string PrefixTableName(string tableName) { if (string.IsNullOrEmpty(_shellSettings.DataTablePrefix)) return tableName; return _shellSettings.DataTablePrefix + "_" + tableName; @@ -285,6 +285,8 @@ namespace Orchard.Data.Migration.Interpreters { } private void Visit(StringBuilder builder, CreateColumnCommand command) { + bool emitNull = true; + if (ExecuteCustomInterpreter(command)) { return; } @@ -297,8 +299,14 @@ namespace Orchard.Data.Migration.Interpreters { } // append identity if handled +<<<<<<< HEAD if (command.IsIdentity && _dialectLazy.Value.SupportsIdentityColumns) { builder.Append(Space).Append(_dialectLazy.Value.IdentityColumnString); +======= + if (command.IsIdentity && _dialect.SupportsIdentityColumns) { + builder.Append(Space).Append(_dialect.IdentityColumnString); + emitNull = !_dialect.IdentityColumnString.ToLower().Contains("null"); // already defined by identity string +>>>>>>> orchard4ibn/IBN-Labs/SchemaBuilder.TableDbName } // [default value] @@ -307,11 +315,21 @@ namespace Orchard.Data.Migration.Interpreters { } // nullable +<<<<<<< HEAD builder.Append(command.IsNotNull ? " not null" : !command.IsPrimaryKey && !command.IsUnique ? _dialectLazy.Value.NullColumnString : string.Empty); +======= + if (emitNull) { + builder.Append(command.IsNotNull + ? " not null" + : !command.IsPrimaryKey && !command.IsUnique + ? _dialect.NullColumnString + : string.Empty); + } +>>>>>>> orchard4ibn/IBN-Labs/SchemaBuilder.TableDbName // append unique if handled, otherwise at the end of the satement if (command.IsUnique && _dialectLazy.Value.SupportsUnique) { diff --git a/src/Orchard/Data/Migration/Interpreters/IDataMigrationInterpreter.cs b/src/Orchard/Data/Migration/Interpreters/IDataMigrationInterpreter.cs index a2225b12f..81ed48590 100644 --- a/src/Orchard/Data/Migration/Interpreters/IDataMigrationInterpreter.cs +++ b/src/Orchard/Data/Migration/Interpreters/IDataMigrationInterpreter.cs @@ -9,5 +9,6 @@ namespace Orchard.Data.Migration.Interpreters { void Visit(SqlStatementCommand command); void Visit(CreateForeignKeyCommand command); void Visit(DropForeignKeyCommand command); + string PrefixTableName(string tableName); } } diff --git a/src/Orchard/Data/Migration/Schema/SchemaBuilder.cs b/src/Orchard/Data/Migration/Schema/SchemaBuilder.cs index 66dc64287..de5291a61 100644 --- a/src/Orchard/Data/Migration/Schema/SchemaBuilder.cs +++ b/src/Orchard/Data/Migration/Schema/SchemaBuilder.cs @@ -28,6 +28,13 @@ namespace Orchard.Data.Migration.Schema { public Func FormatPrefix { get { return _formatPrefix; } } + + /// + /// Translate Table name into database table name - including prefixes + /// + public virtual string TableDbName(string srcTable) { + return _interpreter.PrefixTableName(String.Concat(FormatPrefix(FeaturePrefix), srcTable)); + } public SchemaBuilder CreateTable(string name, Action table) { var createTable = new CreateTableCommand(String.Concat(_formatPrefix(_featurePrefix), name)); From 5b468b0ce064c63801d6e43580dc3c076772e924 Mon Sep 17 00:00:00 2001 From: qt1 Date: Mon, 1 Jun 2015 03:33:14 +0300 Subject: [PATCH 20/24] remove fix for automatic addition of is null (maybe a different PR) --- .../DefaultDataMigrationInterpreter.cs | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/Orchard/Data/Migration/Interpreters/DefaultDataMigrationInterpreter.cs b/src/Orchard/Data/Migration/Interpreters/DefaultDataMigrationInterpreter.cs index 566ef04a8..bb0da3d20 100644 --- a/src/Orchard/Data/Migration/Interpreters/DefaultDataMigrationInterpreter.cs +++ b/src/Orchard/Data/Migration/Interpreters/DefaultDataMigrationInterpreter.cs @@ -285,8 +285,6 @@ namespace Orchard.Data.Migration.Interpreters { } private void Visit(StringBuilder builder, CreateColumnCommand command) { - bool emitNull = true; - if (ExecuteCustomInterpreter(command)) { return; } @@ -299,14 +297,8 @@ namespace Orchard.Data.Migration.Interpreters { } // append identity if handled -<<<<<<< HEAD if (command.IsIdentity && _dialectLazy.Value.SupportsIdentityColumns) { builder.Append(Space).Append(_dialectLazy.Value.IdentityColumnString); -======= - if (command.IsIdentity && _dialect.SupportsIdentityColumns) { - builder.Append(Space).Append(_dialect.IdentityColumnString); - emitNull = !_dialect.IdentityColumnString.ToLower().Contains("null"); // already defined by identity string ->>>>>>> orchard4ibn/IBN-Labs/SchemaBuilder.TableDbName } // [default value] @@ -315,21 +307,11 @@ namespace Orchard.Data.Migration.Interpreters { } // nullable -<<<<<<< HEAD builder.Append(command.IsNotNull ? " not null" : !command.IsPrimaryKey && !command.IsUnique ? _dialectLazy.Value.NullColumnString : string.Empty); -======= - if (emitNull) { - builder.Append(command.IsNotNull - ? " not null" - : !command.IsPrimaryKey && !command.IsUnique - ? _dialect.NullColumnString - : string.Empty); - } ->>>>>>> orchard4ibn/IBN-Labs/SchemaBuilder.TableDbName // append unique if handled, otherwise at the end of the satement if (command.IsUnique && _dialectLazy.Value.SupportsUnique) { From c3379489d779db1dc68fa5034c3496730f304b73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Ros?= Date: Thu, 4 Jun 2015 12:51:58 -0700 Subject: [PATCH 21/24] #5348: Splitting ItemDisplayText in two --- src/Orchard/Mvc/Html/ContentItemExtensions.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Orchard/Mvc/Html/ContentItemExtensions.cs b/src/Orchard/Mvc/Html/ContentItemExtensions.cs index a6fc28281..ceafb8f0a 100644 --- a/src/Orchard/Mvc/Html/ContentItemExtensions.cs +++ b/src/Orchard/Mvc/Html/ContentItemExtensions.cs @@ -7,7 +7,12 @@ using Orchard.Utility.Extensions; namespace Orchard.Mvc.Html { public static class ContentItemExtensions { - public static MvcHtmlString ItemDisplayText(this HtmlHelper html, IContent content, bool encode = true) { + + public static MvcHtmlString ItemDisplayText(this HtmlHelper html, IContent content) { + return ItemDisplayText(content, true); + } + + public static MvcHtmlString ItemDisplayText(this HtmlHelper html, IContent content, bool encode) { var metadata = content.ContentItem.ContentManager.GetItemMetadata(content); if (metadata.DisplayText == null) return null; From 30411b6be59b91f8eb34a787fb40f9b88980130a Mon Sep 17 00:00:00 2001 From: Lombiq Date: Sat, 6 Jun 2015 00:32:29 +0200 Subject: [PATCH 22/24] #5348: Splitting ItemDisplayText in two (fixing the fix) --- src/Orchard/Mvc/Html/ContentItemExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Orchard/Mvc/Html/ContentItemExtensions.cs b/src/Orchard/Mvc/Html/ContentItemExtensions.cs index ceafb8f0a..8524091c7 100644 --- a/src/Orchard/Mvc/Html/ContentItemExtensions.cs +++ b/src/Orchard/Mvc/Html/ContentItemExtensions.cs @@ -9,7 +9,7 @@ namespace Orchard.Mvc.Html { public static class ContentItemExtensions { public static MvcHtmlString ItemDisplayText(this HtmlHelper html, IContent content) { - return ItemDisplayText(content, true); + return ItemDisplayText(html, content, true); } public static MvcHtmlString ItemDisplayText(this HtmlHelper html, IContent content, bool encode) { From 0c7b52e1be2011de4d81f55b40dd33310e88e669 Mon Sep 17 00:00:00 2001 From: Lombiq Date: Sat, 6 Jun 2015 00:34:55 +0200 Subject: [PATCH 23/24] #5355: Fixing that the selected terms in a TaxonomyField were cleared out when updating an editor group the field isn't displayed in --- .../Orchard.Taxonomies/Drivers/TaxonomyFieldDriver.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.Taxonomies/Drivers/TaxonomyFieldDriver.cs b/src/Orchard.Web/Modules/Orchard.Taxonomies/Drivers/TaxonomyFieldDriver.cs index 1faeb554b..81fa93e10 100644 --- a/src/Orchard.Web/Modules/Orchard.Taxonomies/Drivers/TaxonomyFieldDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Taxonomies/Drivers/TaxonomyFieldDriver.cs @@ -83,9 +83,11 @@ namespace Orchard.Taxonomies.Drivers { } protected override DriverResult Editor(ContentPart part, TaxonomyField field, IUpdateModel updater, dynamic shapeHelper) { - var viewModel = new TaxonomyFieldViewModel { Terms = new List() }; + // Initializing viewmodel using the terms that are already selected to prevent loosing them when updating an editor group this field isn't displayed in. + var viewModel = new TaxonomyFieldViewModel { Terms = field.Terms.Select(t => t.CreateTermEntry()).ToList() }; + foreach (var item in viewModel.Terms) item.IsChecked = true; - if(updater.TryUpdateModel(viewModel, GetPrefix(field, part), null, null)) { + if (updater.TryUpdateModel(viewModel, GetPrefix(field, part), null, null)) { var checkedTerms = viewModel.Terms .Where(t => (t.IsChecked || t.Id == viewModel.SingleTermId)) .Select(t => GetOrCreateTerm(t, viewModel.TaxonomyId, field)) From e810d885a0d7b7a2fda7b86b643237313b6e3437 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Sun, 7 Jun 2015 00:25:58 +0200 Subject: [PATCH 24/24] #5270: Fixed Shape type not found error. --- .../Drivers/ProjectionElementDriver.cs | 3 ++ .../Orchard.Layouts/Orchard.Layouts.csproj | 31 +++++++++++++++++++ .../Views/Elements/Projection.Design.cshtml | 11 +++++++ 3 files changed, 45 insertions(+) create mode 100644 src/Orchard.Web/Modules/Orchard.Layouts/Views/Elements/Projection.Design.cshtml diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Drivers/ProjectionElementDriver.cs b/src/Orchard.Web/Modules/Orchard.Layouts/Drivers/ProjectionElementDriver.cs index 9d12690ef..f3f01a8f2 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Drivers/ProjectionElementDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Drivers/ProjectionElementDriver.cs @@ -103,6 +103,9 @@ namespace Orchard.Layouts.Drivers { // Execute the query. var contentItems = _projectionManager.GetContentItems(query.Id, pager.GetStartIndex() + element.Skip, pager.PageSize).ToList(); + context.ElementShape.ContentItems = contentItems; + context.ElementShape.BuildShapes = (Func>) (displayType => contentItems.Select(x => _contentManager.BuildDisplay(x, displayType))); + // TODO: Figure out if we need this for a Projection Element, and if so, how. //// Sanity check so that content items with ProjectionPart can't be added here, or it will result in an infinite loop. //contentItems = contentItems.Where(x => !x.Has()).ToList(); diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Orchard.Layouts.csproj b/src/Orchard.Web/Modules/Orchard.Layouts/Orchard.Layouts.csproj index b428dc728..0ccb86dd7 100644 --- a/src/Orchard.Web/Modules/Orchard.Layouts/Orchard.Layouts.csproj +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Orchard.Layouts.csproj @@ -24,6 +24,7 @@ + true @@ -616,6 +617,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) diff --git a/src/Orchard.Web/Modules/Orchard.Layouts/Views/Elements/Projection.Design.cshtml b/src/Orchard.Web/Modules/Orchard.Layouts/Views/Elements/Projection.Design.cshtml new file mode 100644 index 000000000..7919b2d76 --- /dev/null +++ b/src/Orchard.Web/Modules/Orchard.Layouts/Views/Elements/Projection.Design.cshtml @@ -0,0 +1,11 @@ +@{ + var contentShapes = ((Func>)Model.BuildShapes)("Summary").ToList(); + var list = New.List(); + list.AddRange(contentShapes); +} +@if (contentShapes.Any()) { + @Display(list) +} +else { +

@T("The query returned no results.")

+} \ No newline at end of file