Merge remote-tracking branch 'origin/1.10.x' into dev

# Conflicts:
#	src/Orchard.Web/Core/Contents/Views/Content.SummaryAdmin.cshtml
#	src/Orchard.Web/Core/Contents/Views/Parts.Contents.Clone.SummaryAdmin.cshtml
#	src/Orchard.Web/Core/Contents/Views/Parts.Contents.Publish.SummaryAdmin.cshtml
#	src/Orchard.Web/Modules/Orchard.AntiSpam/Views/Parts/SpamFilter.Metadata.Actions.cshtml
#	src/Orchard.Web/Modules/Orchard.Blogs/Views/Content-BlogPost.SummaryAdmin.cshtml
#	src/Orchard.Web/Modules/Orchard.Comments/Views/Admin/Index.cshtml
#	src/Orchard.Web/Modules/Orchard.Comments/Views/Parts.Comment.SummaryAdmin.cshtml
#	src/Orchard.Web/Modules/Orchard.Comments/Views/Parts.CommentForm.cshtml
#	src/Orchard.Web/Modules/Orchard.Localization/Orchard.Localization.csproj
#	src/Orchard.Web/Modules/Orchard.Roles/Views/Admin/Index.cshtml
#	src/Orchard.Web/Modules/Orchard.Tags/Views/Admin/Index.cshtml
#	src/Orchard.Web/Modules/Orchard.Widgets/Views/WidgetPlacement.Zones.cshtml
This commit is contained in:
Lombiq
2019-08-19 16:47:31 +02:00
committed by Benedek Farkas
36 changed files with 124 additions and 131 deletions

View File

@@ -1,11 +1,9 @@
using System;
using System.Linq;
using System.Collections.Generic;
using Autofac;
using NUnit.Framework;
using Orchard.DisplayManagement.Implementation;
using Orchard.Mvc;
using Orchard.Tests.Stubs;
using Orchard.UI.Admin;
using Orchard.UI.Resources;
namespace Orchard.Tests.UI.Resources {
@@ -21,7 +19,7 @@ namespace Orchard.Tests.UI.Resources {
public Action<ResourceManifest> DefineManifest { get; set; }
public TestManifestProvider() {
}
public void BuildManifests(ResourceManifestBuilder builder) {
var manifest = builder.Add();
@@ -45,6 +43,8 @@ namespace Orchard.Tests.UI.Resources {
[SetUp]
public void Init() {
var builder = new ContainerBuilder();
builder.RegisterType<StubWorkContextAccessor>().As<IWorkContextAccessor>();
builder.RegisterType<StubHttpContextAccessor>().As<IHttpContextAccessor>();
builder.RegisterType<ResourceManager>().As<IResourceManager>();
builder.RegisterType<ResourceFileHashProvider>().As<IResourceFileHashProvider>();
builder.RegisterType<TestManifestProvider>().As<IResourceManifestProvider>().SingleInstance();

View File

@@ -1,6 +1,5 @@
@using Orchard.ContentManagement;
@using Orchard.Core.Contents;
@using Orchard.Utility.Extensions;
@{
ContentItem contentItem = Model.ContentItem;
}

View File

@@ -4,6 +4,9 @@
ContentPart contentPart = Model.ContentPart;
}
@if (Authorizer.Authorize(Permissions.CreateContent, contentPart)) {
<a href="@Url.Action("Clone", "Admin", new { Id = Model.ContentItem.Id, Area = "Contents" })" itemprop="UnsafeUrl">@T("Clone")</a>
@T(" | ")
<ul class="action-links action-links-item">
<li class="action-link">
<a href="@Url.Action("Clone", "Admin", new { Id = Model.ContentItem.Id, ReturnUrl = Request.RawUrl, Area = "Contents" })" itemprop="UnsafeUrl">@T("Clone")</a>
</li>
</ul>
}

View File

@@ -1,11 +1,9 @@
@using Orchard.ContentManagement;
@using Orchard.Core.Contents;
@using Orchard.Utility.Extensions;
@{
Script.Require("ShapesBase");
ContentItem contentItem = Model.ContentItem;
var returnUrl = ViewContext.RequestContext.HttpContext.Request.ToUrlString();
var hasPublished = contentItem.HasPublished();
var hasDraft = contentItem.HasDraft();
var isPublished = contentItem.IsPublished();
@@ -15,9 +13,6 @@
}
<ul class="action-links action-links-item">
<li class="action-label">
@T("Item:")
</li>
@if (hasPublished) {
<li class="action-link">
@Html.ItemDisplayLink(T("View").Text, contentItem)
@@ -31,19 +26,19 @@
</li>
}
<li class="action-link">
@Html.ActionLink(T("Clone").Text, "Clone", "Admin", new { Id = contentItem.Id, ReturnUrl = Request.ToUrlString(), Area = "Contents" }, new { itemprop = "UnsafeUrl" })
@Html.ActionLink(T("Clone").Text, "Clone", "Admin", new { Id = contentItem.Id, ReturnUrl = Request.RawUrl, Area = "Contents" }, new { itemprop = "UnsafeUrl" })
</li>
}
if (hasPublished && authorizedToPublish) {
<li class="action-link">
@Html.ActionLink(T("Unpublish").Text, "Unpublish", "Admin", new { area = "Contents", id = contentItem.Id, returnUrl = Request.ToUrlString() }, new { itemprop = "UnsafeUrl" })
@Html.Link(T("Unpublish").Text, Url.Action("Unpublish", "Admin", new {area = "Contents", id = contentItem.Id, returnUrl = Request.RawUrl}), new {itemprop = "UnsafeUrl"})
</li>
}
if (authorizedToDelete) {
<li class="action-link">
@Html.Link(T("Delete").Text, Url.ItemRemoveUrl(contentItem, new { returnUrl }), new { itemprop = "RemoveUrl UnsafeUrl" })
@Html.Link(T("Delete").Text, Url.ItemRemoveUrl(contentItem, new { returnUrl = Request.RawUrl }), new { itemprop = "RemoveUrl UnsafeUrl" })
</li>
}
}
@@ -66,13 +61,13 @@
@if (hasDraft && authorizedToPublish) {
<li class="action-link">
@Html.ActionLink(T("Publish").Text, "Publish", "Admin", new { area = "Contents", id = contentItem.Id, returnUrl = Request.ToUrlString() }, new { itemprop = "UnsafeUrl" })
@Html.ActionLink(T("Publish").Text, "Publish", "Admin", new { area = "Contents", id = contentItem.Id, returnUrl = Request.RawUrl }, new { itemprop = "UnsafeUrl" })
</li>
}
@if (!isPublished && hasPublished && authorizedToDelete) {
<li class="action-link">
@Html.ActionLink(T("Discard").Text, "DiscardDraft", "Admin", new { area = "Contents", id = contentItem.Id, returnUrl = Request.ToUrlString() }, new { itemprop = "RemoveUrl UnsafeUrl" })
@Html.ActionLink(T("Discard").Text, "DiscardDraft", "Admin", new { area = "Contents", id = contentItem.Id, returnUrl = Request.RawUrl }, new { itemprop = "RemoveUrl UnsafeUrl" })
</li>
}
</ul>

View File

@@ -37,18 +37,18 @@
</select>
</fieldset>
<fieldset class="bulk-actions">
<label for="sortResults">@T("Sort by:")</label>
<label for="sortResults">@T("Sort by:")</label>
<select id="sortResults" name="@Html.NameOf(m => m.Options.Order)">
@Html.SelectOption(Model.Options.Order, SpamOrder.Creation, T("Creation date").ToString())
</select>
<input type="hidden" name="Page" value="1" />
<label for="pageSize">@T("Show:")</label>
<select id="pageSize" name="PageSize">
@Html.SelectOption((int)Model.Pager.PageSize, 0, T("All").ToString())
@foreach (int size in pageSizes.OrderBy(p => p)) {
@Html.SelectOption((int)Model.Pager.PageSize, size, size.ToString())
<input type="hidden" name="Page" value="1" />
<label for="pageSize">@T("Show:")</label>
<select id="pageSize" name="PageSize">
@Html.SelectOption((int)Model.Pager.PageSize, 0, T("All").ToString())
@foreach (int size in pageSizes.OrderBy(p => p)) {
@Html.SelectOption((int)Model.Pager.PageSize, size, size.ToString())
}
</select>
</select>
<button type="submit" name="submit.Filter" value="@T("Filter")">@T("Filter")</button>
</fieldset>
<fieldset class="contentItems bulk-items">
@@ -56,6 +56,6 @@
@Display(entry.Shape)
spamIndex++;
}
@Display(Model.Pager)
@Display(Model.Pager)
</fieldset>
}

View File

@@ -1,12 +1,16 @@
@using Orchard.AntiSpam.Models
@using Orchard.Utility.Extensions
@{
SpamFilterPart part = Model.ContentPart;
}
@if (Model.ContentPart.Status == SpamStatus.Spam) {
@Html.Link(@T("Not Spam").Text, Url.Action("ReportHam", "Admin", new {area = "Orchard.AntiSpam", part.Id, returnUrl = Request.ToUrlString()}), new {itemprop = "UnsafeUrl"})
}
else {
@Html.Link(@T("Spam").Text, Url.Action("ReportSpam", "Admin", new {area = "Orchard.AntiSpam", part.Id, returnUrl = Request.ToUrlString()}), new {itemprop = "UnsafeUrl"})
}
<ul class="action-links">
<li class="action-link">
@if (Model.ContentPart.Status == SpamStatus.Spam) {
@Html.Link(@T("Not Spam").Text, Url.Action("ReportHam", "Admin", new {area = "Orchard.AntiSpam", part.Id, returnUrl = Request.RawUrl }), new {itemprop = "UnsafeUrl"})
}
else {
@Html.Link(@T("Spam").Text, Url.Action("ReportSpam", "Admin", new {area = "Orchard.AntiSpam", part.Id, returnUrl = Request.RawUrl }), new {itemprop = "UnsafeUrl"})
}
</li>
</ul>

View File

@@ -110,7 +110,7 @@ namespace Orchard.AuditTrail.Controllers {
foreach (var contentItem in contentItems) {
var contentItemTitle = _contentManager.GetItemMetadata(contentItem).DisplayText;
if (!_authorizer.Authorize(Core.Contents.Permissions.EditContent, contentItem)) {
_notifier.Error(T("You need the EditContent permission to restore <strong>{0}</strong>.", contentItemTitle));
_notifier.Error(T("You need to have permission to edit <strong>{0}</strong> to be able to restore it.", contentItemTitle));
continue;
}
@@ -125,7 +125,7 @@ namespace Orchard.AuditTrail.Controllers {
foreach (var contentItem in contentItems) {
var contentItemTitle = _contentManager.GetItemMetadata(contentItem).DisplayText;
if (!_authorizer.Authorize(Core.Contents.Permissions.DeleteContent, contentItem)) {
_notifier.Error(T("You need the DeleteContent permission to permanently delete <strong>{0}</strong>.", contentItemTitle));
_notifier.Error(T("You need to have permission to delete <strong>{0}</strong> to be able to permanently delete it.", contentItemTitle));
continue;
}

View File

@@ -14,7 +14,7 @@
@Html.SelectOption(ContentsBulkAction.None, ContentsBulkAction.None, T("Choose action...").ToString())
@Html.SelectOption(ContentsBulkAction.None, ContentsBulkAction.Remove, T("Delete").ToString())
</select>
@Html.Hidden("returnUrl", ViewContext.RequestContext.HttpContext.Request.ToUrlString())
@Html.Hidden("returnUrl", ViewContext.RequestContext.HttpContext.Request.RawUrl)
<button type="submit" name="submit.BulkEdit" value="yes">@T("Apply")</button>
</fieldset>
<fieldset class="contentItems bulk-items">

View File

@@ -4,7 +4,7 @@
@{
Script.Require("ShapesBase");
ContentItem contentItem = Model.ContentItem;
var returnUrl = ViewContext.RequestContext.HttpContext.Request.ToUrlString();
var returnUrl = ViewContext.RequestContext.HttpContext.Request.RawUrl;
}
<div class="summary" itemscope="itemscope" itemid="@contentItem.Id" itemtype="http://orchardproject.net/data/ContentItem">
@@ -29,7 +29,7 @@
if (contentItem.HasDraft()) {
if (Authorizer.Authorize(Orchard.Blogs.Permissions.PublishBlogPost, contentItem)) {
<li class="action-link">
@Html.Link(T("Publish Draft").Text, Url.Action("Publish", "Admin", new { area = "Contents", id = contentItem.Id, returnUrl = Request.ToUrlString() }), new { itemprop = "UnsafeUrl" })
@Html.Link(T("Publish Draft").Text, Url.Action("Publish", "Admin", new { area = "Contents", id = contentItem.Id, returnUrl = Request.RawUrl }), new { itemprop = "UnsafeUrl" })
</li>
}
@@ -42,7 +42,7 @@
if (Authorizer.Authorize(Orchard.Blogs.Permissions.PublishBlogPost, contentItem)) {
<li class="action-link">
@Html.Link(T("Unpublish").Text, Url.Action("Unpublish", "Admin", new { area = "Contents", id = contentItem.Id, returnUrl = Request.ToUrlString() }), new { itemprop = "UnsafeUrl" })
@Html.Link(T("Unpublish").Text, Url.Action("Unpublish", "Admin", new { area = "Contents", id = contentItem.Id, returnUrl = Request.RawUrl}), new { itemprop = "UnsafeUrl" })
</li>
}
}
@@ -57,7 +57,7 @@
if (Authorizer.Authorize(Orchard.Blogs.Permissions.PublishBlogPost, contentItem)) {
<li class="action-link">
@Html.Link(T("Publish").Text, Url.Action("Publish", "Admin", new { area = "Contents", id = contentItem.Id, returnUrl = Request.ToUrlString() }), new { itemprop = "UnsafeUrl" })
@Html.Link(T("Publish").Text, Url.Action("Publish", "Admin", new { area = "Contents", id = contentItem.Id, returnUrl = Request.RawUrl }), new { itemprop = "UnsafeUrl" })
</li>
}
}

View File

@@ -1,5 +1,5 @@
@using Orchard.Core.Contents.ViewModels;
@using Orchard.Utility.Extensions;
@if (Model.ContentItems.Items.Count > 0) {
using (Html.BeginFormAntiForgeryPost(Url.Action("List", "Admin", new { area = "Contents", id = "" }))) {
<fieldset class="bulk-actions">
@@ -11,7 +11,7 @@
@Html.SelectOption(ContentsBulkAction.None, ContentsBulkAction.Unpublish, T("Unpublish").ToString())
@Html.SelectOption(ContentsBulkAction.None, ContentsBulkAction.Remove, T("Delete").ToString())
</select>
@Html.Hidden("returnUrl", ViewContext.RequestContext.HttpContext.Request.ToUrlString())
@Html.Hidden("returnUrl", ViewContext.RequestContext.HttpContext.Request.RawUrl)
<button type="submit" name="submit.BulkEdit" value="yes">@T("Apply")</button>
</fieldset>
<fieldset class="contentItems bulk-items">

View File

@@ -34,7 +34,7 @@ namespace Orchard.Comments {
Area = "Orchard.Comments",
Controller = "Admin",
id = item.Id,
returnUrl = Html.ViewContext.HttpContext.Request.ToUrlString()
returnUrl = Html.ViewContext.HttpContext.Request.RawUrl
});
}

View File

@@ -89,19 +89,19 @@
<ul class="action-links">
@if (commentEntry.Comment.Status != CommentStatus.Approved) {
<li class="action-link">
<a href="@Url.Action("Approve", new {commentEntry.Comment.Id, returnUrl = Request.ToUrlString()})" itemprop="ApproveUrl UnsafeUrl">@T("Approve")</a>
<a href="@Url.Action("Approve", new {commentEntry.Comment.Id, returnUrl = Request.RawUrl})" itemprop="ApproveUrl UnsafeUrl">@T("Approve")</a>
</li>
}
else {
<li class="action-link">
<a href="@Url.Action("Unapprove", new {commentEntry.Comment.Id, returnUrl = Request.ToUrlString()})" itemprop="UnapproveUrl UnsafeUrl">@T("Unapprove")</a>
<a href="@Url.Action("Unapprove", new {commentEntry.Comment.Id, returnUrl = Request.RawUrl})" itemprop="UnapproveUrl UnsafeUrl">@T("Unapprove")</a>
</li>
}
<li class="action-link">
<a href="@Url.Action("Edit", new {commentEntry.Comment.Id})" title="@T("Edit")">@T("Edit")</a>
</li>
<li class="action-link">
<a href="@Url.Action("Delete", new {commentEntry.Comment.Id, returnUrl = ViewContext.RequestContext.HttpContext.Request.ToUrlString()})" itemprop="RemoveUrl UnsafeUrl">@T("Delete")</a>
<a href="@Url.Action("Delete", new {commentEntry.Comment.Id, returnUrl = ViewContext.RequestContext.HttpContext.Request.RawUrl})" itemprop="RemoveUrl UnsafeUrl">@T("Delete")</a>
</li>
</ul>
</td>

View File

@@ -1,6 +1,5 @@
@using Orchard.Comments.Models;
@using Orchard.Comments.Models
@using Orchard.ContentManagement
@using Orchard.Utility.Extensions
@{
CommentPart comment = Model.ContentPart;
@@ -11,12 +10,12 @@
<ul class="action-links">
@if (comment.Status != CommentStatus.Pending) {
<li class="action-link">
@Html.Link(@T("Approve").Text, Url.Action("Approve", "Admin", new { area = "Orchard.Comments", comment.Id, returnUrl = Request.ToUrlString() }), new { itemprop = "UnsafeUrl" })
@Html.Link(@T("Approve").Text, Url.Action("Approve", "Admin", new {area = "Orchard.Comments", comment.Id, returnUrl = Request.RawUrl }), new {itemprop = "UnsafeUrl"})
</li>
}
else {
<li class="action-link">
@Html.Link(@T("Unapprove").Text, Url.Action("Unapprove", "Admin", new { area = "Orchard.Comments", comment.Id, returnUrl = Request.ToUrlString() }), new { itemprop = "UnsafeUrl" })
@Html.Link(@T("Unapprove").Text, Url.Action("Unapprove", "Admin", new {area = "Orchard.Comments", comment.Id, returnUrl = Request.RawUrl }), new {itemprop = "UnsafeUrl"})
</li>
}
</ul>

View File

@@ -33,7 +33,7 @@ else if (isAuthorized) {
<div class="comment-reply-form-settings" data-contentitem-id="@commentsPart.ContentItem.Id" data-active-comment-id="@activeCommentId"></div>
}
@Html.ValidationSummary()
using (Html.BeginFormAntiForgeryPost(Url.Action("Create", "Comment", new { Area = "Orchard.Comments", ReturnUrl = Context.Request.ToUrlString() }), FormMethod.Post, new { @class = "comment-form", data_contentitem_id = commentsPart.ContentItem.Id })) {
using (Html.BeginFormAntiForgeryPost(Url.Action("Create", "Comment", new { Area = "Orchard.Comments", ReturnUrl = Context.Request.RawUrl }), FormMethod.Post, new { @class = "comment-form", data_contentitem_id = commentsPart.ContentItem.Id })) {
if (TempData.ContainsKey("Comments.InvalidCommentEditorShape")) {
@Display(TempData["Comments.InvalidCommentEditorShape"]);
}
@@ -41,6 +41,5 @@ else if (isAuthorized) {
@Display(Model.EditorShape)
}
<button class="primaryAction" type="submit">@T("Submit Comment")</button>
}
}
}

View File

@@ -4,8 +4,8 @@ using Orchard.Security.Permissions;
namespace Orchard.ContentTypes {
public class Permissions : IPermissionProvider {
public static readonly Permission ViewContentTypes = new Permission { Name = "ViewContentTypes", Description = "View content types." };
public static readonly Permission EditContentTypes = new Permission { Name = "EditContentTypes", Description = "Edit content types." };
public static readonly Permission ViewContentTypes = new Permission { Name = "ViewContentTypes", Description = "View content types" };
public static readonly Permission EditContentTypes = new Permission { Name = "EditContentTypes", Description = "Edit content types" };
public virtual Feature Feature { get; set; }

View File

@@ -4,7 +4,7 @@
Style.Require("ContentTypesAdmin");
Script.Require("jQuery");
Layout.Title = T("Edit Content Type - {0}", Html.Raw(Model.DisplayName)).Text;
var returnUrl = ViewContext.RequestContext.HttpContext.Request.ToUrlString();
var returnUrl = ViewContext.RequestContext.HttpContext.Request.RawUrl;
}
<div class="manage">

View File

@@ -1,7 +1,7 @@
@using Orchard.Utility.Extensions
@model Orchard.ContentTypes.ViewModels.EditPartFieldViewModel
@{
var returnUrl = ViewContext.RequestContext.HttpContext.Request.ToUrlString();
var returnUrl = ViewContext.RequestContext.HttpContext.Request.RawUrl;
}
<fieldset class="manage-field">
<h3>@Model.DisplayName <span>(@Model.FieldDefinition.Name.CamelFriendly())</span></h3>

View File

@@ -15,7 +15,7 @@
@Html.SelectOption(ContentsBulkAction.None, ContentsBulkAction.Unpublish, T("Unpublish").ToString())
@Html.SelectOption(ContentsBulkAction.None, ContentsBulkAction.Remove, T("Delete").ToString())
</select>
@Html.Hidden("returnUrl", ViewContext.RequestContext.HttpContext.Request.ToUrlString())
@Html.Hidden("returnUrl", ViewContext.RequestContext.HttpContext.Request.RawUrl)
<button type="submit" name="submit.BulkEdit" value="yes">@T("Apply")</button>
</fieldset>
<fieldset class="contentItems bulk-items">

View File

@@ -3,7 +3,7 @@
@using Orchard.Utility.Extensions;
@{
ContentItem contentItem = Model.ContentItem;
var returnUrl = ViewContext.RequestContext.HttpContext.Request.ToUrlString();
var returnUrl = ViewContext.RequestContext.HttpContext.Request.RawUrl;
}
<div class="summary-condensed" itemscope="itemscope" itemid="@contentItem.Id" itemtype="http://orchardproject.net/data/ContentItem">
<div class="properties">

View File

@@ -1,18 +0,0 @@
using System.Web;
using Orchard.UI.Admin;
namespace Orchard.Localization {
public static class ContextHelpers {
internal static bool IsRequestFrontEnd(HttpContextBase context) {
return !IsRequestAdmin(context);
}
internal static bool IsRequestAdmin(HttpContextBase context) {
if (AdminFilter.IsApplied(context.Request.RequestContext))
return true;
return false;
}
}
}

View File

@@ -105,7 +105,6 @@
<Compile Include="Controllers\AdminCultureSelectorController.cs" />
<Compile Include="Extensions\MetaDataExtensions.cs" />
<Compile Include="Handlers\LocalizationCultureNeutralityHandler.cs" />
<Compile Include="Helpers\ContextHelpers.cs" />
<Compile Include="Models\TransliterationSpecificationRecord.cs" />
<Compile Include="Providers\ContentLocalizationTokens.cs" />
<Compile Include="Selectors\ContentCultureSelector.cs" />

View File

@@ -3,9 +3,10 @@ using System.Web;
using System.Web.Mvc;
using Orchard.Alias;
using Orchard.ContentManagement;
using Orchard.Environment.Configuration;
using Orchard.Environment.Extensions;
using Orchard.Localization.Services;
using Orchard.Environment.Configuration;
using Orchard.UI.Admin;
namespace Orchard.Localization.Selectors {
[OrchardFeature("Orchard.Localization.CultureSelector")]
@@ -27,7 +28,7 @@ namespace Orchard.Localization.Selectors {
}
public CultureSelectorResult GetCulture(HttpContextBase context) {
if (context == null || ContextHelpers.IsRequestAdmin(context)) return null;
if (context == null || AdminFilter.IsApplied(context)) return null;
// Attempt to determine culture by previous route if by POST
string path;

View File

@@ -6,6 +6,7 @@ using Orchard.Localization.Providers;
using Orchard.Localization.Services;
using Orchard.Mvc;
using Orchard.Services;
using Orchard.UI.Admin;
namespace Orchard.Localization.Selectors {
[OrchardFeature("Orchard.Localization.CultureSelector")]
@@ -31,10 +32,10 @@ namespace Orchard.Localization.Selectors {
if (httpContext == null) return;
var cookieName = ContextHelpers.IsRequestAdmin(httpContext) ? AdminCookieName : FrontEndCookieName;
var cookieName = AdminFilter.IsApplied(httpContext) ? AdminCookieName : FrontEndCookieName;
var cookie = new HttpCookie(cookieName, culture) {
Expires = _clock.UtcNow.AddYears(DefaultExpireTimeYear),
Expires = _clock.UtcNow.AddYears(DefaultExpireTimeYear),
};
cookie.Domain = !httpContext.Request.IsLocal ? httpContext.Request.Url.Host : null;
@@ -51,7 +52,7 @@ namespace Orchard.Localization.Selectors {
public CultureSelectorResult GetCulture(HttpContextBase context) {
if (context == null) return null;
var cookieName = ContextHelpers.IsRequestAdmin(context) ? AdminCookieName : FrontEndCookieName;
var cookieName = AdminFilter.IsApplied(context) ? AdminCookieName : FrontEndCookieName;
var cookie = context.Request.Cookies.Get(cookieName);

View File

@@ -2,12 +2,13 @@ using System.Globalization;
using System.Web;
using Orchard.Environment.Extensions;
using Orchard.Localization.Services;
using Orchard.UI.Admin;
namespace Orchard.Localization.Selectors {
[OrchardFeature("Orchard.Localization.CultureSelector")]
public class RouteCultureSelector : ICultureSelector {
public CultureSelectorResult GetCulture(HttpContextBase context) {
if (context == null || ContextHelpers.IsRequestAdmin(context)) return null;
if (context == null || AdminFilter.IsApplied(context)) return null;
// Attempt to determine culture by route.
// This normally happens when you are using non standard pages that are not content items
@@ -17,9 +18,9 @@ namespace Orchard.Localization.Selectors {
if (routeCulture != null && !string.IsNullOrWhiteSpace(routeCulture.ToString())) {
try {
var culture = CultureInfo.GetCultureInfo(routeCulture.ToString());
return new CultureSelectorResult {Priority = -3, CultureName = culture.Name};
return new CultureSelectorResult { Priority = -3, CultureName = culture.Name };
}
catch {}
catch { }
}
return null;

View File

@@ -8,7 +8,7 @@
string name = field.Name;
var mediaParts = field.MediaParts;
var returnUrl = ViewContext.RequestContext.HttpContext.Request.ToUrlString();
var returnUrl = ViewContext.RequestContext.HttpContext.Request.RawUrl;
}
<span class="name">@displayName:</span>
<p class="media-library-picker-field media-library-picker-field-@name.HtmlClassify()">

View File

@@ -28,7 +28,7 @@
T("Uninstall").Text,
"UninstallModule",
"PackagingServices",
new { ModuleId = module.Descriptor.Id, ReturnUrl = Request.ToUrlString(), Area = "Orchard.Packaging" },
new { ModuleId = module.Descriptor.Id, ReturnUrl = Request.RawUrl, Area = "Orchard.Packaging" },
new { itemprop = "RemoveUrl UnsafeUrl" })
@if (!String.IsNullOrEmpty(module.Descriptor.Description)) {

View File

@@ -26,7 +26,7 @@
}
<fieldset class="update-actions">
<a class="button" href="@Url.Action("ReloadUpdates", new { returnUrl = ViewContext.RequestContext.HttpContext.Request.ToUrlString()})" title="@T("Most recent check for updates: {0}", Model.LastUpdateCheckUtc == null ? T("Unknown") : Display.DateTimeRelative(DateTimeUtc: Model.LastUpdateCheckUtc.Value))">@T("Check for Updates")</a>
<a class="button" href="@Url.Action("ReloadUpdates", new { returnUrl = ViewContext.RequestContext.HttpContext.Request.RawUrl})" title="@T("Most recent check for updates: {0}", Model.LastUpdateCheckUtc == null ? T("Unknown") : Display.DateTimeRelative(DateTimeUtc: Model.LastUpdateCheckUtc.Value))">@T("Check for Updates")</a>
</fieldset>
@if (Model.Entries.Count() <= 0) {

View File

@@ -26,7 +26,7 @@
}
<fieldset class="update-actions">
<a class="button" href="@Url.Action("ReloadUpdates", new { returnUrl = ViewContext.RequestContext.HttpContext.Request.ToUrlString()})" title="@T("Most recent check for updates: {0}", Model.LastUpdateCheckUtc == null ? T("Unknown") : Display.DateTimeRelative(DateTimeUtc: Model.LastUpdateCheckUtc.Value))" >@T("Check for Updates")</a>
<a class="button" href="@Url.Action("ReloadUpdates", new { returnUrl = ViewContext.RequestContext.HttpContext.Request.RawUrl})" title="@T("Most recent check for updates: {0}", Model.LastUpdateCheckUtc == null ? T("Unknown") : Display.DateTimeRelative(DateTimeUtc: Model.LastUpdateCheckUtc.Value))" >@T("Check for Updates")</a>
</fieldset>
@if (Model.Entries.Count() <= 0) {

View File

@@ -42,7 +42,7 @@
</li>
@if (row.Name != "Administrator") {
<li class="action-link">
<a href="@Url.Action("Delete", new {row.Id, returnUrl = ViewContext.RequestContext.HttpContext.Request.ToUrlString()})" itemprop="RemoveUrl UnsafeUrl">@T("Delete")</a>
<a href="@Url.Action("Delete", new {row.Id, returnUrl = ViewContext.RequestContext.HttpContext.Request.RawUrl})" itemprop="RemoveUrl UnsafeUrl">@T("Delete")</a>
</li>
}
</ul>

View File

@@ -48,7 +48,7 @@
@Html.ActionLink(T("Edit").ToString(), "Edit", new { id = tagEntry.Tag.Id })
</li>
<li class="action-link">
<a href="@Url.Action("Remove", new {tagEntry.Tag.Id, returnUrl = ViewContext.RequestContext.HttpContext.Request.ToUrlString()})" itemprop="RemoveUrl UnsafeUrl">@T("Delete")</a>
<a href="@Url.Action("Remove", new {tagEntry.Tag.Id, returnUrl = ViewContext.RequestContext.HttpContext.Request.RawUrl})" itemprop="RemoveUrl UnsafeUrl">@T("Delete")</a>
</li>
</ul>
</td>

View File

@@ -68,7 +68,7 @@
T("Uninstall").Text,
"UninstallTheme",
"PackagingServices",
new { ThemeId = theme.Descriptor.Id, ReturnUrl = Request.ToUrlString(), Area = "Orchard.Packaging" },
new { ThemeId = theme.Descriptor.Id, ReturnUrl = Request.RawUrl, Area = "Orchard.Packaging" },
new { itemprop = "RemoveUrl UnsafeUrl" })
}
</div>

View File

@@ -15,7 +15,7 @@ namespace Orchard.Tokens.Providers {
public RequestTokens(IWorkContextAccessor workContextAccessor, IContentManager contentManager) {
_workContextAccessor = workContextAccessor;
_contentManager = contentManager;
_textChainableTokens = new string[] { "QueryString", "Form" };
_textChainableTokens = new string[] { "QueryString", "Form", "Header" };
T = NullLocalizer.Instance;
}
@@ -27,6 +27,8 @@ namespace Orchard.Tokens.Providers {
.Token("Form:*", T("Form:<element>"), T("The Form value for the specified element. To chain text, surround the <element> with parentheses, e.g. 'Form:(param1)'."))
.Token("Route:*", T("Route:<key>"), T("The Route value for the specified key."))
.Token("Content", T("Content"), T("The request routed Content Item."), "Content")
.Token("Header:*", T("Header:<element>"), T("The request routed Content Item."), "The Header value for the specified element. To chain text, surround the <element> with parentheses, e.g. 'Header:(param1)'.")
;
}
@@ -44,20 +46,29 @@ namespace Orchard.Tokens.Providers {
*/
context.For("Request", _workContextAccessor.GetContext().HttpContext.Request)
.Token(
FilterTokenParam,
token => token.StartsWith("QueryString:", StringComparison.OrdinalIgnoreCase) ? FilterTokenParam(token) : null,
(token, request) => {
return request.QueryString.Get(token);
}
)
.Chain(token => token.StartsWith("QueryString:", StringComparison.OrdinalIgnoreCase) ? FilterChainParam(token) : null,
"Text", (token, request) => request.QueryString.Get(token))
.Token(
FilterTokenParam,
token => token.StartsWith("Form:", StringComparison.OrdinalIgnoreCase) ? FilterTokenParam(token) : null,
(token, request) => request.Form.Get(token)
)
.Chain(token => token.StartsWith("Form:", StringComparison.OrdinalIgnoreCase) ? FilterChainParam(token) : null
, "Text", (token, request) => request.Form.Get(token))
.Token(
token => token.StartsWith("Header:", StringComparison.OrdinalIgnoreCase) ? FilterTokenParam(token) : null,
(token, request) => request.Headers[token]
)
.Chain(token => token.StartsWith("Header:", StringComparison.OrdinalIgnoreCase) ? FilterChainParam(token) : null,
"Text", (token, request) => request.Headers[token])
.Token(
token => token.StartsWith("Route:", StringComparison.OrdinalIgnoreCase) ? token.Substring("Route:".Length) : null,
(token, request) => GetRouteValue(token, request)
)
.Chain(FilterChainParam, "Text", (token, request) => request.QueryString.Get(token))
)
.Token("Content",
(request) => DisplayText(GetRoutedContentItem(request))
)

View File

@@ -32,21 +32,21 @@
if (widget.HasDraft()) {
if (Authorizer.Authorize(Permissions.PublishContent, widget)) {
<li class="action-link">
@Html.Link(T("Publish Draft").Text, Url.Action("Publish", "Admin", new { area = "Contents", id = widget.ContentItem.Id, returnUrl = Request.ToUrlString() }), new { itemprop = "UnsafeUrl" })
@Html.Link(T("Publish Draft").Text, Url.Action("Publish", "Admin", new { area = "Contents", id = widget.ContentItem.Id, returnUrl = Request.RawUrl }), new { itemprop = "UnsafeUrl" })
</li>
}
}
if (Authorizer.Authorize(Permissions.PublishContent, widget)) {
<li class="action-link">
@Html.Link(T("Unpublish").Text, Url.Action("Unpublish", "Admin", new { area = "Contents", id = widget.ContentItem.Id, returnUrl = Request.ToUrlString() }), new { itemprop = "UnsafeUrl" })
@Html.Link(T("Unpublish").Text, Url.Action("Unpublish", "Admin", new { area = "Contents", id = widget.ContentItem.Id, returnUrl = Request.RawUrl }), new { itemprop = "UnsafeUrl" })
</li>
}
}
else {
if (Authorizer.Authorize(Permissions.PublishContent, widget)) {
<li class="action-link">
@Html.Link(T("Publish").Text, Url.Action("Publish", "Admin", new { area = "Contents", id = widget.ContentItem.Id, returnUrl = Request.ToUrlString() }), new { itemprop = "UnsafeUrl" })
@Html.Link(T("Publish").Text, Url.Action("Publish", "Admin", new { area = "Contents", id = widget.ContentItem.Id, returnUrl = Request.RawUrl }), new { itemprop = "UnsafeUrl" })
</li>
}
}

View File

@@ -45,7 +45,7 @@ namespace Orchard.Environment {
if (!httpContext.IsBackgroundContext()) {
// Don't redirect posts...
if (httpContext.Request.RequestType == "GET") {
httpContext.Response.Redirect(HttpContext.Current.Request.ToUrlString(), true /*endResponse*/);
httpContext.Response.Redirect(HttpContext.Current.Request.RawUrl, true /*endResponse*/);
}
else {
httpContext.Response.ContentType = "text/html";

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Orchard.Localization;
@@ -34,7 +35,11 @@ namespace Orchard.UI.Admin {
}
public static bool IsApplied(RequestContext context) {
return context.HttpContext.Items.Contains(typeof(AdminFilter));
return IsApplied(context.HttpContext);
}
public static bool IsApplied(HttpContextBase context) {
return context.Items.Contains(typeof(AdminFilter));
}
private static bool IsAdmin(AuthorizationContext filterContext) {

View File

@@ -2,7 +2,6 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
@@ -10,7 +9,6 @@ using System.Web;
using System.Web.Hosting;
using System.Web.Mvc;
using Autofac.Features.Metadata;
using Orchard.Environment;
using Orchard.Environment.Extensions.Models;
using Orchard.Mvc;
using Orchard.Settings;
@@ -24,8 +22,8 @@ namespace Orchard.UI.Resources {
};
private readonly Dictionary<string, IList<ResourceRequiredContext>> _builtResources = new Dictionary<string, IList<ResourceRequiredContext>>(StringComparer.OrdinalIgnoreCase);
private readonly IEnumerable<Meta<IResourceManifestProvider>> _providers;
private readonly Work<WorkContext> _workContext;
private readonly Work<IHttpContextAccessor> _httpContextAccessor;
private readonly Lazy<IWorkContextAccessor> _wcaLazy;
private readonly Lazy<IHttpContextAccessor> _hcaLazy;
private ResourceManifest _dynamicManifest;
private List<String> _headScripts;
private List<String> _footScripts;
@@ -33,6 +31,17 @@ namespace Orchard.UI.Resources {
private const string NotIE = "!IE";
public ResourceManager(
IEnumerable<Meta<IResourceManifestProvider>> resourceProviders,
Lazy<IWorkContextAccessor> wcaLazy,
Lazy<IHttpContextAccessor> hcaLazy) {
_providers = resourceProviders;
_wcaLazy = wcaLazy;
_hcaLazy = hcaLazy;
}
private static string ToAppRelativePath(string resourcePath) {
if (!String.IsNullOrEmpty(resourcePath) && !Uri.IsWellFormedUriString(resourcePath, UriKind.Absolute) && !resourcePath.StartsWith("//")) {
resourcePath = VirtualPathUtility.ToAppRelative(resourcePath);
@@ -83,14 +92,14 @@ namespace Orchard.UI.Resources {
}
var tagBuilder = GetTagBuilder(resource, url);
if (attributes != null) {
// todo: try null value
tagBuilder.MergeAttributes(attributes, true);
}
writer.WriteLine(tagBuilder.ToString(resource.TagRenderMode));
if (!string.IsNullOrEmpty(condition)) {
if (condition == NotIE) {
writer.WriteLine("<!--<![endif]-->");
@@ -101,15 +110,6 @@ namespace Orchard.UI.Resources {
}
}
public ResourceManager(IEnumerable<Meta<IResourceManifestProvider>> resourceProviders,
Work<WorkContext> workContext,
Work<IHttpContextAccessor> httpContextAccessor
) {
_providers = resourceProviders;
_workContext = workContext;
_httpContextAccessor = httpContextAccessor;
}
public IEnumerable<IResourceManifest> ResourceProviders {
get {
if (_manifests == null) {
@@ -352,7 +352,7 @@ namespace Orchard.UI.Resources {
}
var index = meta.Name ?? meta.HttpEquiv;
if (String.IsNullOrEmpty(index)) {
return;
}
@@ -366,8 +366,8 @@ namespace Orchard.UI.Resources {
private string GetResourceKey(string releasePath, string debugPath) {
bool debugMode;
var site = _workContext.Value.CurrentSite;
switch (site.ResourceDebugMode) {
switch (_wcaLazy.Value.GetContext().CurrentSite.ResourceDebugMode) {
case ResourceDebugMode.Enabled:
debugMode = true;
break;
@@ -375,17 +375,11 @@ namespace Orchard.UI.Resources {
debugMode = false;
break;
default:
Debug.Assert(site.ResourceDebugMode == ResourceDebugMode.FromAppSetting, "Unknown ResourceDebugMode value.");
var context = _httpContextAccessor.Value.Current();
debugMode = context != null && context.IsDebuggingEnabled;
debugMode = _hcaLazy.Value.Current()?.IsDebuggingEnabled ?? false;
break;
}
if (debugMode && !string.IsNullOrWhiteSpace(debugPath)) {
return debugPath;
}
else {
return releasePath;
}
return debugMode && !string.IsNullOrWhiteSpace(debugPath) ? debugPath : releasePath;
}
}
}