Compare commits

..

13 Commits

Author SHA1 Message Date
Benedek Farkas
bf32b70740 Fixing auto-merge 2024-04-19 11:48:55 +02:00
Benedek Farkas
cc7d224a66 Merge branch 'dev' into issue/6193/htmlfilter 2024-04-19 11:45:32 +02:00
Sipke Schoorstra
cf4335e5ba #6193: IHtmlFilter and TokenFilter improvements and bugfixes (#6938)
* IHtmlFilter and TokenFilter improvements and bugfixes.

This changeset unifies the two separate TokenFilter implementations (one for BodyPart, TextField, etc and another one for certain elements such as Html).
It also fixes a bug with the TokenFilter when executing for HtmlWidget, where the wrong content item is being recorded by the handler (the original implementation).
Thirdly, it removes awkward code repetition by moving filter execution into a dedicated HtmlFilterRunner service.

* Renaming IHtmlFilterRunner to IHtmlFilterProcessor (and its references)

* Applying IHtmlFilterProcessor to HtmlMenuItems too + code styling in BodyPartDriver

* Fixing FeedControllerTests.CorePartValuesAreExtracted

* Code styling

---------

Co-authored-by: Jean-Thierry Kéchichian <jean-thierry.kechichian@wanadoo.fr>
Co-authored-by: Sipke Schoorstra <sipke@ideliverable.com>
Co-authored-by: Benedek Farkas <benedek.farkas@lombiq.com>
2024-04-19 11:20:32 +02:00
Benedek Farkas
9b0d78b4f6 #8786: Updating Microsoft.IdentityModel.* packages from 5.2.4 to 5.7.0 (#8787)
* Updating Microsoft.IdentityModel.* packages from 5.2.4 to 5.7.0

* Updating OpenId packages from 4.0.0 to 4.2.2 to mach the version of Microsoft.Owin

* Fixing assembly binding redirects in Orchard.Web/Web.config

* OpenId: Updating Microsoft.IdentityModel.Tokens.* packages to version 5.7.0.0 to match Microsoft.IdentityModel.Tokens

* OpenId: Updating Microsoft.IdentityModel.Protocols packages to 5.7.0.0 too

* The return of System.Net.Http assembly binding redirects
2024-04-18 21:35:39 +02:00
Benedek Farkas
38d35efd4d Merge branch '1.10.x' into dev
# Conflicts:
#	src/Orchard.Web/Modules/Orchard.Projections/Migrations.cs
2024-04-17 17:46:14 +02:00
Benedek Farkas
3a6810ec67 8225: Adding a checkbox to StringFilterForm to control whether an empty value should cause the filter to be skipped (#8781)
* Adding a checkbox to StringFilterForm to control whether an empty value should cause the filter to be skipped

* Removing StringOperator.ContainsAnyIfProvided as its now obsolete due to the IgnoreFilterIfValueIsEmpty checkbox setting

* Code styling in StringFilterForm

* Adding missing T-string

* Adding migration step to upgrade from using the ContainsAnyIfProvided operator in StringFilterForm
2024-04-17 11:52:51 +02:00
Benedek Farkas
3f1bf7fcbe Merge branch '1.10.x' into 'dev' through the 'issue/8773' integration branch 2024-04-17 10:53:06 +02:00
Benedek Farkas
d95f81259e Code styling 2024-04-09 14:58:00 +02:00
Benedek Farkas
a751764b27 Fixing FeedControllerTests.CorePartValuesAreExtracted 2024-04-09 12:22:54 +02:00
Benedek Farkas
1f571866ff Merge branch 'dev' into issue/6193/htmlfilter 2024-04-09 11:33:52 +02:00
Benedek Farkas
84266ca34a Applying IHtmlFilterProcessor to HtmlMenuItems too + code styling in BodyPartDriver 2024-04-09 11:32:11 +02:00
Benedek Farkas
14d84f6db3 Renaming IHtmlFilterRunner to IHtmlFilterProcessor (and its references) 2024-04-09 11:05:45 +02:00
Sipke Schoorstra
34af2365cf IHtmlFilter and TokenFilter improvements and bugfixes.
This changeset unifies the two separate TokenFilter implementations (one for BodyPart, TextField, etc and another one for certain elements such as Html).
It also fixes a bug with the TokenFilter when executing for HtmlWidget, where the wrong content item is being recorded by the handler (the original implementation).
Thirdly, it removes awkward code repetition by moving filter execution into a dedicated HtmlFilterRunner service.
2016-05-31 22:12:15 +02:00
42 changed files with 349 additions and 358 deletions

View File

@@ -20,6 +20,7 @@ using Orchard.Core.Feeds.StandardBuilders;
using Orchard.Tests.Modules;
using Orchard.Tests.Stubs;
using Orchard.Core.Title.Models;
using Orchard.Services;
namespace Orchard.Core.Tests.Feeds.Controllers {
[TestFixture]
@@ -177,6 +178,7 @@ namespace Orchard.Core.Tests.Feeds.Controllers {
builder.RegisterInstance(mockContentManager.Object).As<IContentManager>();
builder.RegisterType<RssFeedBuilder>().As<IFeedBuilderProvider>();
builder.RegisterType<CorePartsFeedItemBuilder>().As<IFeedItemBuilder>();
builder.RegisterType<HtmlFilterProcessor>().As<IHtmlFilterProcessor>();
builder.RegisterInstance(query).As<IFeedQueryProvider>();
var container = builder.Build();

View File

@@ -1,12 +1,9 @@
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web;
using Orchard.Mvc.Html;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.ContentManagement.Drivers;
using Orchard.Core.Common.Models;
using Orchard.Core.Common.Settings;
using Orchard.Core.Common.ViewModels;
using Orchard.Services;
using System.Web.Mvc;
@@ -15,13 +12,13 @@ using Orchard.ContentManagement.Handlers;
namespace Orchard.Core.Common.Drivers {
public class BodyPartDriver : ContentPartDriver<BodyPart> {
private readonly IEnumerable<IHtmlFilter> _htmlFilters;
private readonly IHtmlFilterProcessor _htmlFilterProcessor;
private readonly RequestContext _requestContext;
private const string TemplateName = "Parts.Common.Body";
public BodyPartDriver(IOrchardServices services, IEnumerable<IHtmlFilter> htmlFilters, RequestContext requestContext) {
_htmlFilters = htmlFilters;
public BodyPartDriver(IOrchardServices services, IHtmlFilterProcessor htmlFilterProcessor, RequestContext requestContext) {
_htmlFilterProcessor = htmlFilterProcessor;
Services = services;
_requestContext = requestContext;
}
@@ -33,32 +30,27 @@ namespace Orchard.Core.Common.Drivers {
}
protected override DriverResult Display(BodyPart part, string displayType, dynamic shapeHelper) {
string GetProcessedBodyText() => _htmlFilterProcessor.ProcessFilters(part.Text, part.GetFlavor(), part);
return Combined(
ContentShape("Parts_Common_Body",
() => {
var bodyText = _htmlFilters.Aggregate(part.Text, (text, filter) => filter.ProcessContent(text, GetFlavor(part)));
return shapeHelper.Parts_Common_Body(Html: new HtmlString(bodyText));
}),
ContentShape("Parts_Common_Body_Summary",
() => {
var bodyText = _htmlFilters.Aggregate(part.Text, (text, filter) => filter.ProcessContent(text, GetFlavor(part)));
return shapeHelper.Parts_Common_Body_Summary(Html: new HtmlString(bodyText));
})
);
ContentShape("Parts_Common_Body", () =>
shapeHelper.Parts_Common_Body(Html: new HtmlString(GetProcessedBodyText()))),
ContentShape("Parts_Common_Body_Summary", () =>
shapeHelper.Parts_Common_Body_Summary(Html: new HtmlString(GetProcessedBodyText()))));
}
protected override DriverResult Editor(BodyPart part, dynamic shapeHelper) {
var model = BuildEditorViewModel(part,_requestContext);
return ContentShape("Parts_Common_Body_Edit",
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
return ContentShape("Parts_Common_Body_Edit", () =>
shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
}
protected override DriverResult Editor(BodyPart part, IUpdateModel updater, dynamic shapeHelper) {
var model = BuildEditorViewModel(part, _requestContext);
updater.TryUpdateModel(model, Prefix, null, null);
return ContentShape("Parts_Common_Body_Edit",
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
return ContentShape("Parts_Common_Body_Edit", () =>
shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
}
protected override void Importing(BodyPart part, ContentManagement.Handlers.ImportContentContext context) {
@@ -83,18 +75,11 @@ namespace Orchard.Core.Common.Drivers {
private static BodyEditorViewModel BuildEditorViewModel(BodyPart part,RequestContext requestContext) {
return new BodyEditorViewModel {
BodyPart = part,
EditorFlavor = GetFlavor(part),
EditorFlavor = part.GetFlavor(),
AddMediaPath = new PathBuilder(part,requestContext).AddContentType().AddContainerSlug().ToString()
};
}
private static string GetFlavor(BodyPart part) {
var typePartSettings = part.Settings.GetModel<BodyTypePartSettings>();
return (typePartSettings != null && !string.IsNullOrWhiteSpace(typePartSettings.Flavor))
? typePartSettings.Flavor
: part.PartDefinition.Settings.GetModel<BodyPartSettings>().FlavorDefault;
}
class PathBuilder {
private readonly IContent _content;
private string _path;

View File

@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
@@ -14,10 +12,10 @@ using Orchard.Utility.Extensions;
namespace Orchard.Core.Common.Drivers {
public class TextFieldDriver : ContentFieldDriver<TextField> {
private readonly IEnumerable<IHtmlFilter> _htmlFilters;
private readonly IHtmlFilterProcessor _htmlFilterProcessor;
public TextFieldDriver(IOrchardServices services, IEnumerable<IHtmlFilter> htmlFilters) {
_htmlFilters = htmlFilters;
public TextFieldDriver(IOrchardServices services, IHtmlFilterProcessor htmlFilterProcessor) {
_htmlFilterProcessor = htmlFilterProcessor;
Services = services;
T = NullLocalizer.Instance;
}
@@ -37,8 +35,7 @@ namespace Orchard.Core.Common.Drivers {
return ContentShape("Fields_Common_Text", GetDifferentiator(field, part),
() => {
var settings = field.PartFieldDefinition.Settings.GetModel<TextFieldSettings>();
object fieldValue = new HtmlString(_htmlFilters.Aggregate(field.Value, (text, filter) => filter.ProcessContent(text, settings.Flavor)));
var fieldValue = new HtmlString(_htmlFilterProcessor.ProcessFilters(field.Value, settings.Flavor, part));
return shapeHelper.Fields_Common_Text(Name: field.Name, Value: fieldValue);
});
}
@@ -75,12 +72,12 @@ namespace Orchard.Core.Common.Drivers {
if (settings.MaxLength > 0) {
var value = new HtmlString(_htmlFilters.Aggregate(field.Value, (text, filter) => filter.ProcessContent(text, settings.Flavor)))
var value = new HtmlString(_htmlFilterProcessor.ProcessFilters(field.Value, settings.Flavor, part))
.ToString().RemoveTags();
if (value.Length > settings.MaxLength) {
updater.AddModelError("Text", T("The maximum allowed length for the field {0} is {1}", T(field.DisplayName), settings.MaxLength));
}
}
}
}

View File

@@ -1,4 +1,5 @@
using Orchard.ContentManagement;
using Orchard.Core.Common.Settings;
namespace Orchard.Core.Common.Models {
public class BodyPart : ContentPart<BodyPartRecord> {
@@ -11,5 +12,12 @@ namespace Orchard.Core.Common.Models {
get { return Retrieve(x => x.Format); }
set { Store(x => x.Format, value); }
}
public string GetFlavor() {
var typePartSettings = Settings.GetModel<BodyTypePartSettings>();
return string.IsNullOrWhiteSpace(typePartSettings?.Flavor)
? PartDefinition.Settings.GetModel<BodyPartSettings>().FlavorDefault
: typePartSettings.Flavor;
}
}
}

View File

@@ -5,27 +5,26 @@ using System.Web;
using Orchard.Services;
namespace Orchard.Core.Common.Services {
public class BbcodeFilter : IHtmlFilter {
public string ProcessContent(string text, string flavor) {
return BbcodeReplace(text);
public class BbcodeFilter : HtmlFilter {
public override string ProcessContent(string text, HtmlFilterContext context) {
return BbcodeReplace(text, context);
}
// Can be moved somewhere else once we have IoC enabled body text filters.
private static string BbcodeReplace(string text) {
if (string.IsNullOrEmpty(text))
return string.Empty;
private static string BbcodeReplace(string text, HtmlFilterContext context) {
if (String.IsNullOrEmpty(text))
return String.Empty;
// optimize code path if nothing to do
// Optimize code path if nothing to do.
if (!text.Contains("[url]") && !text.Contains("[img]") && !text.Contains("[url=")) {
return text;
}
var sb = new StringBuilder(text);
var index = -1;
var allIndexes = new List<int>();
// process all [url]
// Process all [url].
while (-1 != (index = text.IndexOf("[url]", index + 1, StringComparison.Ordinal))) {
allIndexes.Add(index);
}
@@ -63,7 +62,7 @@ namespace Orchard.Core.Common.Services {
var url = text.Substring(start + 5, urlEnd - start - 5);
var title = text.Substring(urlEnd + 1, end - urlEnd - 1);
// substitue [url] by <a>
// Substitute [url] by <a>.
sb.Remove(start, end - start + 6);
sb.Insert(start, String.Format("<a href=\"{0}\">{1}</a>", url, title));
}
@@ -85,7 +84,7 @@ namespace Orchard.Core.Common.Services {
var url = text.Substring(start + 5, end - start - 5);
// substitue [url] by <a>
// Substitue [url] by <a>.
sb.Remove(start, end - start + 6);
if (!string.IsNullOrEmpty(url)) {

View File

@@ -4,10 +4,10 @@ using Orchard.Services;
using Orchard.Utility.Extensions;
namespace Orchard.Core.Common.Services {
public class TextFieldFilter : IHtmlFilter {
public string ProcessContent(string text, string flavor) {
public class TextFieldFilter : HtmlFilter {
public override string ProcessContent(string text, HtmlFilterContext context) {
// Flavor is null for a normal input/text field
return flavor == null || string.Equals(flavor, "textarea", StringComparison.OrdinalIgnoreCase) ? ReplaceNewLines(text) : text;
return context.Flavor == null || String.Equals(context.Flavor, "textarea", StringComparison.OrdinalIgnoreCase) ? ReplaceNewLines(text) : text;
}
private static string ReplaceNewLines(string text) {

View File

@@ -13,15 +13,15 @@ namespace Orchard.Core.Feeds.StandardBuilders {
public class CorePartsFeedItemBuilder : IFeedItemBuilder {
private readonly IContentManager _contentManager;
private readonly RouteCollection _routes;
private readonly IEnumerable<IHtmlFilter> _htmlFilters;
private readonly IHtmlFilterProcessor _htmlFilterProcessor;
public CorePartsFeedItemBuilder(
IContentManager contentManager,
RouteCollection routes,
IEnumerable<IHtmlFilter> htmlFilters) {
IHtmlFilterProcessor htmlFilterProcessor) {
_contentManager = contentManager;
_routes = routes;
_htmlFilters = htmlFilters;
_htmlFilterProcessor = htmlFilterProcessor;
}
public void Populate(FeedContext context) {
@@ -29,8 +29,8 @@ namespace Orchard.Core.Feeds.StandardBuilders {
var inspector = new ItemInspector(
feedItem.Item,
_contentManager.GetItemMetadata(feedItem.Item),
_htmlFilters);
_contentManager.GetItemMetadata(feedItem.Item),
_htmlFilterProcessor);
// author is intentionally left empty as it could result in unwanted spam

View File

@@ -12,17 +12,17 @@ namespace Orchard.Core.Feeds.StandardBuilders {
public class ItemInspector {
private readonly IContent _item;
private readonly ContentItemMetadata _metadata;
private readonly IEnumerable<IHtmlFilter> _htmlFilters;
private readonly IHtmlFilterProcessor _htmlFilterProcessor;
private readonly ICommonPart _common;
private readonly ITitleAspect _titleAspect;
private readonly BodyPart _body;
public ItemInspector(IContent item, ContentItemMetadata metadata) : this(item, metadata, Enumerable.Empty<IHtmlFilter>()) {}
public ItemInspector(IContent item, ContentItemMetadata metadata) : this(item, metadata, null) {}
public ItemInspector(IContent item, ContentItemMetadata metadata, IEnumerable<IHtmlFilter> htmlFilters) {
public ItemInspector(IContent item, ContentItemMetadata metadata, IHtmlFilterProcessor htmlFilterProcessor) {
_item = item;
_metadata = metadata;
_htmlFilters = htmlFilters;
_htmlFilterProcessor = htmlFilterProcessor;
_common = item.Get<ICommonPart>();
_titleAspect = item.Get<ITitleAspect>();
_body = item.Get<BodyPart>();
@@ -49,8 +49,8 @@ namespace Orchard.Core.Feeds.StandardBuilders {
public string Description {
get {
if (_body != null && !string.IsNullOrEmpty(_body.Text)) {
return _htmlFilters.Aggregate(_body.Text, (text, filter) => filter.ProcessContent(text, GetFlavor(_body)));
if (_htmlFilterProcessor != null && _body != null && !string.IsNullOrEmpty(_body.Text)) {
return _htmlFilterProcessor.ProcessFilters(_body.Text, GetFlavor(_body), _body);
}
return Title;
}

View File

@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Web.Mvc;
using System.Xml.Linq;
using Orchard.ContentManagement;
@@ -8,16 +7,16 @@ using Orchard.Core.Feeds.Models;
using Orchard.Core.Feeds.StandardBuilders;
using Orchard.Mvc.Extensions;
using Orchard.Services;
using Orchard.Utility.Extensions;
namespace Orchard.Core.Feeds.StandardQueries {
namespace Orchard.Core.Feeds.StandardQueries
{
public class ContainerFeedQuery : IFeedQueryProvider, IFeedQuery {
private readonly IContentManager _contentManager;
private readonly IEnumerable<IHtmlFilter> _htmlFilters;
private readonly IHtmlFilterProcessor _htmlFilterProcessor;
public ContainerFeedQuery(IContentManager contentManager, IEnumerable<IHtmlFilter> htmlFilters) {
public ContainerFeedQuery(IContentManager contentManager, IHtmlFilterProcessor htmlFilterProcessor) {
_contentManager = contentManager;
_htmlFilters = htmlFilters;
_htmlFilterProcessor = htmlFilterProcessor;
}
public FeedQueryMatch Match(FeedContext context) {
@@ -55,7 +54,7 @@ namespace Orchard.Core.Feeds.StandardQueries {
return;
}
var inspector = new ItemInspector(container, _contentManager.GetItemMetadata(container), _htmlFilters);
var inspector = new ItemInspector(container, _contentManager.GetItemMetadata(container), _htmlFilterProcessor);
if (context.Format == "rss") {
var link = new XElement("link");
context.Response.Element.SetElementValue("title", inspector.Title);

View File

@@ -1 +1,10 @@
<span class="raw">@Html.Raw(Model.Content.BodyPart.Text)</span>
@using Orchard.Core.Common.Models
@using Orchard.Services
@{
var htmlFilterProcessor = WorkContext.Resolve<IHtmlFilterProcessor>();
var bodyPart = Model.Content.BodyPart as BodyPart;
var bodyText = htmlFilterProcessor.ProcessFilters(bodyPart.Text, bodyPart.GetFlavor(), bodyPart);
}
<span class="raw">@Html.Raw(bodyText)</span>

View File

@@ -1,15 +1,16 @@
using System;
using Orchard.Services;
namespace Markdown.Services {
public class MarkdownFilter : IHtmlFilter {
public string ProcessContent(string text, string flavor) {
return String.Equals(flavor, "markdown", StringComparison.OrdinalIgnoreCase) ? MarkdownReplace(text) : text;
namespace Markdown.Services
{
public class MarkdownFilter : HtmlFilter {
public override string ProcessContent(string text, HtmlFilterContext context) {
return String.Equals(context.Flavor, "markdown", StringComparison.OrdinalIgnoreCase) ? MarkdownReplace(text) : text;
}
private static string MarkdownReplace(string text) {
if (string.IsNullOrEmpty(text))
return string.Empty;
if (String.IsNullOrEmpty(text))
return String.Empty;
return Markdig.Markdown.ToHtml(text);
}

View File

@@ -79,14 +79,14 @@
<Reference Include="Microsoft.Data.Services.Client, Version=5.8.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Data.Services.Client.5.8.4\lib\net40\Microsoft.Data.Services.Client.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.JsonWebTokens, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.IdentityModel.JsonWebTokens.5.2.4\lib\net451\Microsoft.IdentityModel.JsonWebTokens.dll</HintPath>
<Reference Include="Microsoft.IdentityModel.JsonWebTokens, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.IdentityModel.JsonWebTokens.5.7.0\lib\net461\Microsoft.IdentityModel.JsonWebTokens.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Logging, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Logging.5.2.4\lib\net451\Microsoft.IdentityModel.Logging.dll</HintPath>
<Reference Include="Microsoft.IdentityModel.Logging, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Logging.5.7.0\lib\net461\Microsoft.IdentityModel.Logging.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Tokens, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Tokens.5.2.4\lib\net451\Microsoft.IdentityModel.Tokens.dll</HintPath>
<Reference Include="Microsoft.IdentityModel.Tokens, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Tokens.5.7.0\lib\net461\Microsoft.IdentityModel.Tokens.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Practices.TransientFaultHandling.Core, Version=5.1.1209.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\TransientFaultHandling.Core.5.1.1209.1\lib\NET4\Microsoft.Practices.TransientFaultHandling.Core.dll</HintPath>
@@ -130,8 +130,8 @@
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.IdentityModel.Tokens.Jwt, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\System.IdentityModel.Tokens.Jwt.5.2.4\lib\net451\System.IdentityModel.Tokens.Jwt.dll</HintPath>
<Reference Include="System.IdentityModel.Tokens.Jwt, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\System.IdentityModel.Tokens.Jwt.5.7.0\lib\net461\System.IdentityModel.Tokens.Jwt.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />

View File

@@ -12,7 +12,7 @@ using Orchard.MediaLibrary.Models;
using Orchard.Services;
namespace Orchard.Azure.MediaServices.Services.Rendering {
public class CloudVideoFilter : IHtmlFilter {
public class CloudVideoFilter : HtmlFilter {
private readonly IShapeFactory _shapeFactory;
private readonly IContentManager _contentManager;
private readonly IShapeDisplay _shapeDisplay;
@@ -23,8 +23,8 @@ namespace Orchard.Azure.MediaServices.Services.Rendering {
_shapeDisplay = shapeDisplay;
}
public string ProcessContent(string text, string flavor) {
return String.Equals(flavor, "html", StringComparison.OrdinalIgnoreCase) ? ReplaceVideoPlaceholder(text) : text;
public override string ProcessContent(string text, HtmlFilterContext context) {
return String.Equals(context.Flavor, "html", StringComparison.OrdinalIgnoreCase) ? ReplaceVideoPlaceholder(text) : text;
}
private string ReplaceVideoPlaceholder(string text) {

View File

@@ -12,9 +12,9 @@
<package id="Microsoft.Data.Edm" version="5.8.4" targetFramework="net48" />
<package id="Microsoft.Data.OData" version="5.8.4" targetFramework="net48" />
<package id="Microsoft.Data.Services.Client" version="5.8.4" targetFramework="net48" />
<package id="Microsoft.IdentityModel.JsonWebTokens" version="5.2.4" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Logging" version="5.2.4" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Tokens" version="5.2.4" targetFramework="net48" />
<package id="Microsoft.IdentityModel.JsonWebTokens" version="5.7.0" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Logging" version="5.7.0" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Tokens" version="5.7.0" targetFramework="net48" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net48" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="3.1.0" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net48" />
@@ -22,7 +22,7 @@
<package id="Orchard.WindowsAzure.Diagnostics" version="2.7.0.0" targetFramework="net48" />
<package id="Remotion.Linq" version="2.2.0" targetFramework="net48" />
<package id="Remotion.Linq.EagerFetching" version="2.2.0" targetFramework="net48" />
<package id="System.IdentityModel.Tokens.Jwt" version="5.2.4" targetFramework="net48" />
<package id="System.IdentityModel.Tokens.Jwt" version="5.7.0" targetFramework="net48" />
<package id="System.Spatial" version="5.8.4" targetFramework="net48" />
<package id="TransientFaultHandling.Core" version="5.1.1209.1" targetFramework="net48" />
<package id="windowsazure.mediaservices" version="3.4.0.0" targetFramework="net48" />

View File

@@ -45,10 +45,6 @@
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0" />

View File

@@ -2,15 +2,15 @@
using Orchard.Layouts.Framework.Display;
using Orchard.Layouts.Framework.Drivers;
using Orchard.Layouts.Helpers;
using Orchard.Layouts.Services;
using Orchard.Layouts.ViewModels;
using Orchard.Services;
namespace Orchard.Layouts.Drivers {
public class HeadingElementDriver : ElementDriver<Heading> {
private readonly IElementFilterProcessor _processor;
private readonly IHtmlFilterProcessor _htmlFilterProcessor;
public HeadingElementDriver(IElementFilterProcessor processor) {
_processor = processor;
public HeadingElementDriver(IHtmlFilterProcessor htmlFilterProcessor) {
_htmlFilterProcessor = htmlFilterProcessor;
}
protected override EditorResult OnBuildEditor(Heading element, ElementEditorContext context) {
@@ -30,7 +30,7 @@ namespace Orchard.Layouts.Drivers {
}
protected override void OnDisplaying(Heading element, ElementDisplayingContext context) {
context.ElementShape.ProcessedContent = _processor.ProcessContent(element.Content, "html", context.GetTokenData());
context.ElementShape.ProcessedContent = _htmlFilterProcessor.ProcessFilters(element.Content, new HtmlFilterContext { Flavor = "html", Data = context.GetTokenData() });
context.ElementShape.Level = element.Level;
}
}

View File

@@ -2,15 +2,16 @@
using Orchard.Layouts.Framework.Display;
using Orchard.Layouts.Framework.Drivers;
using Orchard.Layouts.Helpers;
using Orchard.Layouts.Services;
using Orchard.Layouts.ViewModels;
using Orchard.Services;
namespace Orchard.Layouts.Drivers {
namespace Orchard.Layouts.Drivers
{
public class HtmlElementDriver : ElementDriver<Html> {
private readonly IElementFilterProcessor _processor;
private readonly IHtmlFilterProcessor _htmlFilterProcessor;
public HtmlElementDriver(IElementFilterProcessor processor) {
_processor = processor;
public HtmlElementDriver(IHtmlFilterProcessor htmlFilterProcessor) {
_htmlFilterProcessor = htmlFilterProcessor;
}
protected override EditorResult OnBuildEditor(Html element, ElementEditorContext context) {
@@ -29,7 +30,7 @@ namespace Orchard.Layouts.Drivers {
}
protected override void OnDisplaying(Html element, ElementDisplayingContext context) {
context.ElementShape.ProcessedContent = _processor.ProcessContent(element.Content, "html", context.GetTokenData());
context.ElementShape.ProcessedContent = _htmlFilterProcessor.ProcessFilters(element.Content, new HtmlFilterContext { Flavor = "html", Data = context.GetTokenData() });
}
}
}

View File

@@ -2,16 +2,17 @@
using Orchard.Layouts.Framework.Display;
using Orchard.Layouts.Framework.Drivers;
using Orchard.Layouts.Helpers;
using Orchard.Layouts.Services;
using Orchard.Layouts.ViewModels;
using Orchard.Services;
using MarkdownElement = Orchard.Layouts.Elements.Markdown;
namespace Orchard.Layouts.Drivers {
namespace Orchard.Layouts.Drivers
{
[OrchardFeature("Orchard.Layouts.Markdown")]
public class MarkdownElementDriver : ElementDriver<MarkdownElement> {
private readonly IElementFilterProcessor _processor;
public MarkdownElementDriver(IElementFilterProcessor processor) {
_processor = processor;
private readonly IHtmlFilterProcessor _htmlFilterProcessor;
public MarkdownElementDriver(IHtmlFilterProcessor htmlFilterProcessor) {
_htmlFilterProcessor = htmlFilterProcessor;
}
protected override EditorResult OnBuildEditor(MarkdownElement element, ElementEditorContext context) {
@@ -29,7 +30,7 @@ namespace Orchard.Layouts.Drivers {
}
protected override void OnDisplaying(MarkdownElement element, ElementDisplayingContext context) {
context.ElementShape.ProcessedContent = _processor.ProcessContent(element.Content, "markdown", context.GetTokenData());
context.ElementShape.ProcessedContent = _htmlFilterProcessor.ProcessFilters(element.Content, new HtmlFilterContext { Flavor = "markdown", Data = context.GetTokenData() });
}
}
}

View File

@@ -2,15 +2,15 @@
using Orchard.Layouts.Framework.Display;
using Orchard.Layouts.Framework.Drivers;
using Orchard.Layouts.Helpers;
using Orchard.Layouts.Services;
using Orchard.Layouts.ViewModels;
using Orchard.Services;
namespace Orchard.Layouts.Drivers {
public class ParagraphElementDriver : ElementDriver<Paragraph> {
private readonly IElementFilterProcessor _processor;
private readonly IHtmlFilterProcessor _htmlFilterProcessor;
public ParagraphElementDriver(IElementFilterProcessor processor) {
_processor = processor;
public ParagraphElementDriver(IHtmlFilterProcessor htmlFilterProcessor) {
_htmlFilterProcessor = htmlFilterProcessor;
}
protected override EditorResult OnBuildEditor(Paragraph element, ElementEditorContext context) {
@@ -28,7 +28,7 @@ namespace Orchard.Layouts.Drivers {
}
protected override void OnDisplaying(Paragraph element, ElementDisplayingContext context) {
context.ElementShape.ProcessedContent = _processor.ProcessContent(element.Content, "html", context.GetTokenData());
context.ElementShape.ProcessedContent = _htmlFilterProcessor.ProcessFilters(element.Content, new HtmlFilterContext { Flavor = "html", Data = context.GetTokenData() });
}
}
}

View File

@@ -2,15 +2,16 @@
using Orchard.Layouts.Framework.Display;
using Orchard.Layouts.Framework.Drivers;
using Orchard.Layouts.Helpers;
using Orchard.Layouts.Services;
using Orchard.Layouts.ViewModels;
using Orchard.Services;
namespace Orchard.Layouts.Drivers {
namespace Orchard.Layouts.Drivers
{
public class TextElementDriver : ElementDriver<Text> {
private readonly IElementFilterProcessor _processor;
private readonly IHtmlFilterProcessor _htmlFilterProcessor;
public TextElementDriver(IElementFilterProcessor processor) {
_processor = processor;
public TextElementDriver(IHtmlFilterProcessor htmlFilterProcessor) {
_htmlFilterProcessor = htmlFilterProcessor;
}
protected override EditorResult OnBuildEditor(Text element, ElementEditorContext context) {
@@ -28,7 +29,7 @@ namespace Orchard.Layouts.Drivers {
}
protected override void OnDisplaying(Text element, ElementDisplayingContext context) {
context.ElementShape.ProcessedContent = _processor.ProcessContent(element.Content, "textarea", context.GetTokenData());
context.ElementShape.ProcessedContent = _htmlFilterProcessor.ProcessFilters(element.Content, new HtmlFilterContext { Flavor = "textarea", Data = context.GetTokenData() });
}
}
}

View File

@@ -1,34 +0,0 @@
using System;
using Orchard.Environment.Extensions;
using Orchard.Layouts.Services;
using Orchard.Tokens;
using System.Collections.Generic;
namespace Orchard.Layouts.Filters {
[OrchardFeature("Orchard.Layouts.Tokens")]
public class TokensFilter : IElementFilter {
private readonly ITokenizer _tokenizer;
public TokensFilter(ITokenizer tokenizer) {
_tokenizer = tokenizer;
}
public string ProcessContent(string text, string flavor) {
return ProcessContent(text, flavor, new Dictionary<string, object>());
}
public string ProcessContent(string text, string flavor, IDictionary<string, object> context) {
if (String.IsNullOrEmpty(text))
return "";
if (!text.Contains("#{")) {
return text;
}
text = _tokenizer.Replace(text, context, new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
return text;
}
}
}

View File

@@ -29,7 +29,7 @@ Features:
Dependencies: Orchard.Layouts, Orchard.Projections
Orchard.Layouts.Tokens:
Name: Element Tokens
Description: Provides an element token provider that enables elements to be rendered using a token and enables tokens to be used inside of various elements such as Html, Text and Paragraph.
Description: Provides an element token provider that enables elements to be rendered using a token.
Category: Layout
Dependencies: Orchard.Layouts, Orchard.Tokens
Orchard.Layouts.UI:

View File

@@ -319,7 +319,6 @@
<Compile Include="Elements\Break.cs" />
<Compile Include="Elements\UIElement.cs" />
<Compile Include="Elements\PlaceableContentItem.cs" />
<Compile Include="Filters\TokensFilter.cs" />
<Compile Include="Framework\Display\ElementDisplayedContext.cs" />
<Compile Include="Framework\Display\ElementDisplayingContext.cs" />
<Compile Include="Framework\Drivers\ImportContentContextWrapper.cs" />
@@ -375,9 +374,6 @@
<Compile Include="Services\ElementEventContext.cs" />
<Compile Include="Services\ElementEventHandlerBase.cs" />
<Compile Include="Models\ElementSessionState.cs" />
<Compile Include="Services\ElementFilterProcessor.cs" />
<Compile Include="Services\IElementFilterProcessor.cs" />
<Compile Include="Services\IElementFilter.cs" />
<Compile Include="Services\ICurrentControllerAccessor.cs" />
<Compile Include="Services\IElementEventHandler.cs" />
<Compile Include="Services\ILayoutEditorFactory.cs" />

View File

@@ -1,19 +0,0 @@
using System.Collections.Generic;
using Orchard.Services;
namespace Orchard.Layouts.Services {
public class ElementFilterProcessor : IElementFilterProcessor {
private readonly IEnumerable<IHtmlFilter> _filters;
public ElementFilterProcessor(IEnumerable<IHtmlFilter> filters) {
_filters = filters;
}
public string ProcessContent(string text, string flavor, IDictionary<string, object> context) {
foreach (var htmlFilter in _filters) {
var elementFilter = htmlFilter as IElementFilter;
text = elementFilter != null ? elementFilter.ProcessContent(text, flavor, context) : htmlFilter.ProcessContent(text, flavor);
}
return text;
}
}
}

View File

@@ -1,8 +0,0 @@
using System.Collections.Generic;
using Orchard.Services;
namespace Orchard.Layouts.Services {
public interface IElementFilter : IHtmlFilter {
string ProcessContent(string text, string flavor, IDictionary<string, object> context);
}
}

View File

@@ -1,8 +0,0 @@
using System.Collections.Generic;
using Orchard.Services;
namespace Orchard.Layouts.Services {
public interface IElementFilterProcessor : IDependency {
string ProcessContent(string text, string flavor, IDictionary<string, object> context);
}
}

View File

@@ -84,23 +84,32 @@
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory.Platform, Version=3.19.8.16603, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.3.19.8\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.Platform.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.JsonWebTokens, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.IdentityModel.JsonWebTokens.5.2.4\lib\net451\Microsoft.IdentityModel.JsonWebTokens.dll</HintPath>
<Reference Include="Microsoft.IdentityModel.JsonWebTokens, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.IdentityModel.JsonWebTokens.5.7.0\lib\net461\Microsoft.IdentityModel.JsonWebTokens.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Logging, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Logging.5.2.4\lib\net451\Microsoft.IdentityModel.Logging.dll</HintPath>
<Reference Include="Microsoft.IdentityModel.Logging, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Logging.5.7.0\lib\net461\Microsoft.IdentityModel.Logging.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Protocol.Extensions, Version=1.0.40306.1554, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Protocol.Extensions.1.0.4.403061554\lib\net45\Microsoft.IdentityModel.Protocol.Extensions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Protocols, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Protocols.5.2.4\lib\net451\Microsoft.IdentityModel.Protocols.dll</HintPath>
<Reference Include="Microsoft.IdentityModel.Protocols, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Protocols.5.7.0\lib\net461\Microsoft.IdentityModel.Protocols.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Protocols.OpenIdConnect.5.2.4\lib\net451\Microsoft.IdentityModel.Protocols.OpenIdConnect.dll</HintPath>
<Reference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Protocols.OpenIdConnect.5.7.0\lib\net461\Microsoft.IdentityModel.Protocols.OpenIdConnect.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Tokens, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Tokens.5.2.4\lib\net451\Microsoft.IdentityModel.Tokens.dll</HintPath>
<Reference Include="Microsoft.IdentityModel.Protocols.WsFederation, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Protocols.WsFederation.5.7.0\lib\net461\Microsoft.IdentityModel.Protocols.WsFederation.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Tokens, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Tokens.5.7.0\lib\net461\Microsoft.IdentityModel.Tokens.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Tokens.Saml, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Tokens.Saml.5.7.0\lib\net461\Microsoft.IdentityModel.Tokens.Saml.dll</HintPath>
</Reference>
<Reference Include="Microsoft.IdentityModel.Xml, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Xml.5.7.0\lib\net461\Microsoft.IdentityModel.Xml.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin, Version=4.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Owin.4.2.2\lib\net45\Microsoft.Owin.dll</HintPath>
@@ -111,29 +120,29 @@
<Reference Include="Microsoft.Owin.Security, Version=4.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Owin.Security.4.2.2\lib\net45\Microsoft.Owin.Security.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin.Security.ActiveDirectory, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Owin.Security.ActiveDirectory.4.0.0\lib\net451\Microsoft.Owin.Security.ActiveDirectory.dll</HintPath>
<Reference Include="Microsoft.Owin.Security.ActiveDirectory, Version=4.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Owin.Security.ActiveDirectory.4.2.2\lib\net45\Microsoft.Owin.Security.ActiveDirectory.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin.Security.Cookies, Version=4.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Owin.Security.Cookies.4.2.2\lib\net45\Microsoft.Owin.Security.Cookies.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin.Security.Facebook, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Owin.Security.Facebook.4.0.0\lib\net451\Microsoft.Owin.Security.Facebook.dll</HintPath>
<Reference Include="Microsoft.Owin.Security.Facebook, Version=4.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Owin.Security.Facebook.4.2.2\lib\net45\Microsoft.Owin.Security.Facebook.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin.Security.Google, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Owin.Security.Google.4.0.0\lib\net451\Microsoft.Owin.Security.Google.dll</HintPath>
<Reference Include="Microsoft.Owin.Security.Google, Version=4.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Owin.Security.Google.4.2.2\lib\net45\Microsoft.Owin.Security.Google.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin.Security.Jwt, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Owin.Security.Jwt.4.0.0\lib\net451\Microsoft.Owin.Security.Jwt.dll</HintPath>
<Reference Include="Microsoft.Owin.Security.Jwt, Version=4.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Owin.Security.Jwt.4.2.2\lib\net45\Microsoft.Owin.Security.Jwt.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin.Security.OAuth, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Owin.Security.OAuth.4.0.0\lib\net451\Microsoft.Owin.Security.OAuth.dll</HintPath>
<Reference Include="Microsoft.Owin.Security.OAuth, Version=4.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Owin.Security.OAuth.4.2.2\lib\net45\Microsoft.Owin.Security.OAuth.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin.Security.OpenIdConnect, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Owin.Security.OpenIdConnect.4.0.0\lib\net451\Microsoft.Owin.Security.OpenIdConnect.dll</HintPath>
<Reference Include="Microsoft.Owin.Security.OpenIdConnect, Version=4.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Owin.Security.OpenIdConnect.4.2.2\lib\net45\Microsoft.Owin.Security.OpenIdConnect.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Owin.Security.Twitter, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Owin.Security.Twitter.4.0.0\lib\net451\Microsoft.Owin.Security.Twitter.dll</HintPath>
<Reference Include="Microsoft.Owin.Security.Twitter, Version=4.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Owin.Security.Twitter.4.2.2\lib\net45\Microsoft.Owin.Security.Twitter.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
@@ -162,8 +171,8 @@
</Reference>
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.IdentityModel" />
<Reference Include="System.IdentityModel.Tokens.Jwt, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\System.IdentityModel.Tokens.Jwt.5.2.4\lib\net451\System.IdentityModel.Tokens.Jwt.dll</HintPath>
<Reference Include="System.IdentityModel.Tokens.Jwt, Version=5.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\System.IdentityModel.Tokens.Jwt.5.7.0\lib\net461\System.IdentityModel.Tokens.Jwt.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.WebRequest" />

View File

@@ -76,7 +76,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IdentityModel.Tokens.Jwt" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Protocol.Extensions" publicKeyToken="31bf3856ad364e35" culture="neutral" />
@@ -88,15 +88,15 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Tokens" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Protocols.OpenIdConnect" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Protocols" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
@@ -114,6 +114,22 @@
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Logging" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Xml" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Protocols.WsFederation" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>

View File

@@ -12,29 +12,32 @@
<package id="Microsoft.Data.OData" version="5.8.4" targetFramework="net48" />
<package id="Microsoft.Data.Services.Client" version="5.8.4" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="3.19.8" targetFramework="net48" />
<package id="Microsoft.IdentityModel.JsonWebTokens" version="5.2.4" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Logging" version="5.2.4" targetFramework="net48" />
<package id="Microsoft.IdentityModel.JsonWebTokens" version="5.7.0" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Logging" version="5.7.0" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Protocol.Extensions" version="1.0.4.403061554" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Protocols" version="5.2.4" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Protocols.OpenIdConnect" version="5.2.4" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Tokens" version="5.2.4" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Protocols" version="5.7.0" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Protocols.OpenIdConnect" version="5.7.0" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Protocols.WsFederation" version="5.7.0" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Tokens" version="5.7.0" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Tokens.Saml" version="5.7.0" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Xml" version="5.7.0" targetFramework="net48" />
<package id="Microsoft.Owin" version="4.2.2" targetFramework="net48" />
<package id="Microsoft.Owin.Host.SystemWeb" version="4.2.2" targetFramework="net48" />
<package id="Microsoft.Owin.Security" version="4.2.2" targetFramework="net48" />
<package id="Microsoft.Owin.Security.ActiveDirectory" version="4.0.0" targetFramework="net48" />
<package id="Microsoft.Owin.Security.ActiveDirectory" version="4.2.2" targetFramework="net48" />
<package id="Microsoft.Owin.Security.Cookies" version="4.2.2" targetFramework="net48" />
<package id="Microsoft.Owin.Security.Facebook" version="4.0.0" targetFramework="net48" />
<package id="Microsoft.Owin.Security.Google" version="4.0.0" targetFramework="net48" />
<package id="Microsoft.Owin.Security.Jwt" version="4.0.0" targetFramework="net48" />
<package id="Microsoft.Owin.Security.OAuth" version="4.0.0" targetFramework="net48" />
<package id="Microsoft.Owin.Security.OpenIdConnect" version="4.0.0" targetFramework="net48" />
<package id="Microsoft.Owin.Security.Twitter" version="4.0.0" targetFramework="net48" />
<package id="Microsoft.Owin.Security.Facebook" version="4.2.2" targetFramework="net48" />
<package id="Microsoft.Owin.Security.Google" version="4.2.2" targetFramework="net48" />
<package id="Microsoft.Owin.Security.Jwt" version="4.2.2" targetFramework="net48" />
<package id="Microsoft.Owin.Security.OAuth" version="4.2.2" targetFramework="net48" />
<package id="Microsoft.Owin.Security.OpenIdConnect" version="4.2.2" targetFramework="net48" />
<package id="Microsoft.Owin.Security.Twitter" version="4.2.2" targetFramework="net48" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net48" />
<package id="NHibernate" version="5.3.10" targetFramework="net48" />
<package id="Owin" version="1.0" targetFramework="net48" />
<package id="Remotion.Linq" version="2.2.0" targetFramework="net48" />
<package id="Remotion.Linq.EagerFetching" version="2.2.0" targetFramework="net48" />
<package id="System.IdentityModel.Tokens.Jwt" version="5.2.4" targetFramework="net48" />
<package id="System.IdentityModel.Tokens.Jwt" version="5.7.0" targetFramework="net48" />
<package id="System.Spatial" version="5.8.4" targetFramework="net48" />
</packages>

View File

@@ -7,7 +7,6 @@ using Orchard.Forms.Services;
using Orchard.Localization;
namespace Orchard.Projections.FilterEditors.Forms {
public class StringFilterForm : IFormProvider {
public const string FormName = "StringFilter";
@@ -20,44 +19,44 @@ namespace Orchard.Projections.FilterEditors.Forms {
}
public void Describe(DescribeContext context) {
Func<IShapeFactory, object> form =
shape => {
object form(IShapeFactory shape) {
var f = Shape.Form(
Id: "StringFilter",
_Operator: Shape.SelectList(
Id: "operator", Name: "Operator",
Title: T("Operator"),
Size: 1,
Multiple: false
),
_Value: Shape.TextBox(
Id: "value", Name: "Value",
Title: T("Value"),
Classes: new[] { "text medium", "tokenized" },
Description: T("Enter the value the string should be.")
),
_IgnoreIfEmptyValue: Shape.Checkbox(
Id: "IgnoreFilterIfValueIsEmpty",
Name: "IgnoreFilterIfValueIsEmpty",
Title: T("Ignore filter if value is empty"),
Description: T("When enabled, the filter will not be applied if the provided value is or evaluates to empty."),
Value: "true"
));
var f = Shape.Form(
Id: "StringFilter",
_Operator: Shape.SelectList(
Id: "operator", Name: "Operator",
Title: T("Operator"),
Size: 1,
Multiple: false
),
_Value: Shape.TextBox(
Id: "value", Name: "Value",
Title: T("Value"),
Classes: new[] { "text medium", "tokenized" },
Description: T("Enter the value the string should be.")
)
);
f._Operator.Add(new SelectListItem { Value = Convert.ToString(StringOperator.Equals), Text = T("Is equal to").Text });
f._Operator.Add(new SelectListItem { Value = Convert.ToString(StringOperator.NotEquals), Text = T("Is not equal to").Text });
f._Operator.Add(new SelectListItem { Value = Convert.ToString(StringOperator.Contains), Text = T("Contains").Text });
f._Operator.Add(new SelectListItem { Value = Convert.ToString(StringOperator.ContainsAny), Text = T("Contains any word").Text });
f._Operator.Add(new SelectListItem { Value = Convert.ToString(StringOperator.ContainsAll), Text = T("Contains all words").Text });
f._Operator.Add(new SelectListItem { Value = Convert.ToString(StringOperator.Starts), Text = T("Starts with").Text });
f._Operator.Add(new SelectListItem { Value = Convert.ToString(StringOperator.NotStarts), Text = T("Does not start with").Text });
f._Operator.Add(new SelectListItem { Value = Convert.ToString(StringOperator.Ends), Text = T("Ends with").Text });
f._Operator.Add(new SelectListItem { Value = Convert.ToString(StringOperator.NotEnds), Text = T("Does not end with").Text });
f._Operator.Add(new SelectListItem { Value = Convert.ToString(StringOperator.NotContains), Text = T("Does not contain").Text });
f._Operator.Add(new SelectListItem { Value = Convert.ToString(StringOperator.Equals), Text = T("Is equal to").Text });
f._Operator.Add(new SelectListItem { Value = Convert.ToString(StringOperator.NotEquals), Text = T("Is not equal to").Text });
f._Operator.Add(new SelectListItem { Value = Convert.ToString(StringOperator.Contains), Text = T("Contains").Text });
f._Operator.Add(new SelectListItem { Value = Convert.ToString(StringOperator.ContainsAny), Text = T("Contains any word").Text });
f._Operator.Add(new SelectListItem { Value = Convert.ToString(StringOperator.ContainsAll), Text = T("Contains all words").Text });
f._Operator.Add(new SelectListItem { Value = Convert.ToString(StringOperator.Starts), Text = T("Starts with").Text });
f._Operator.Add(new SelectListItem { Value = Convert.ToString(StringOperator.NotStarts), Text = T("Does not start with").Text });
f._Operator.Add(new SelectListItem { Value = Convert.ToString(StringOperator.Ends), Text = T("Ends with").Text });
f._Operator.Add(new SelectListItem { Value = Convert.ToString(StringOperator.NotEnds), Text = T("Does not end with").Text });
f._Operator.Add(new SelectListItem { Value = Convert.ToString(StringOperator.NotContains), Text = T("Does not contain").Text });
f._Operator.Add(new SelectListItem {
Value = Convert.ToString(StringOperator.ContainsAnyIfProvided),
Text = T("Contains any word (if any is provided)").Text
});
return f;
}
return f;
};
context.Form(FormName, form);
context.Form(FormName, (Func<IShapeFactory, object>)form);
}
@@ -65,6 +64,11 @@ namespace Orchard.Projections.FilterEditors.Forms {
var op = (StringOperator)Enum.Parse(typeof(StringOperator), Convert.ToString(formState.Operator));
object value = Convert.ToString(formState.Value);
if (bool.TryParse(formState.IgnoreFilterIfValueIsEmpty?.ToString() ?? "", out bool ignoreIfEmpty)
&& ignoreIfEmpty
&& string.IsNullOrWhiteSpace(value as string))
return (ex) => { };
switch (op) {
case StringOperator.Equals:
return x => x.Eq(property, value);
@@ -92,14 +96,6 @@ namespace Orchard.Projections.FilterEditors.Forms {
return y => y.Not(x => x.Like(property, Convert.ToString(value), HqlMatchMode.End));
case StringOperator.NotContains:
return y => y.Not(x => x.Like(property, Convert.ToString(value), HqlMatchMode.Anywhere));
case StringOperator.ContainsAnyIfProvided:
if (string.IsNullOrWhiteSpace((string)value))
return x => x.IsNotEmpty("Id"); // basically, return every possible ContentItem
var values3 = Convert.ToString(value)
.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
var predicates3 = values3.Skip(1)
.Select<string, Action<IHqlExpressionFactory>>(x => y => y.Like(property, x, HqlMatchMode.Anywhere)).ToArray();
return x => x.Disjunction(y => y.Like(property, values3[0], HqlMatchMode.Anywhere), predicates3);
default:
throw new ArgumentOutOfRangeException();
}
@@ -130,11 +126,6 @@ namespace Orchard.Projections.FilterEditors.Forms {
return T("{0} does not end with '{1}'", fieldName, value);
case StringOperator.NotContains:
return T("{0} does not contain '{1}'", fieldName, value);
case StringOperator.ContainsAnyIfProvided:
return T("{0} contains any of '{1}' (or '{1}' is empty)",
fieldName,
new LocalizedString(string.Join("', '",
value.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))));
default:
throw new ArgumentOutOfRangeException();
}
@@ -151,7 +142,6 @@ namespace Orchard.Projections.FilterEditors.Forms {
NotStarts,
Ends,
NotEnds,
NotContains,
ContainsAnyIfProvided
NotContains
}
}
}

View File

@@ -15,6 +15,7 @@ namespace Orchard.Projections {
private readonly IRepository<MemberBindingRecord> _memberBindingRepository;
private readonly IRepository<LayoutRecord> _layoutRepository;
private readonly IRepository<PropertyRecord> _propertyRecordRepository;
private readonly IRepository<FilterRecord> _filterRepository;
/// <summary>
/// When upgrading from "1.10.x" branch code committed after 1.10.3 to "dev" branch code or 1.11, merge
@@ -28,10 +29,12 @@ namespace Orchard.Projections {
public Migrations(
IRepository<MemberBindingRecord> memberBindingRepository,
IRepository<LayoutRecord> layoutRepository,
IRepository<PropertyRecord> propertyRecordRepository) {
IRepository<PropertyRecord> propertyRecordRepository,
IRepository<FilterRecord> filterRepository) {
_memberBindingRepository = memberBindingRepository;
_layoutRepository = layoutRepository;
_propertyRecordRepository = propertyRecordRepository;
_filterRepository = filterRepository;
T = NullLocalizer.Instance;
}
@@ -402,6 +405,18 @@ namespace Orchard.Projections {
}
public int UpdateFrom6() {
// This change was originally UpdateFrom6 on 1.10.x and UpdateFrom6 on dev: Casting a somewhat wide net, but
// filters can't be queried by the form they are using and different types of filters can (and do) use
// StringFilterForm. However, the "Operator" parameter's value being "ContainsAnyIfProvided" is very
// specific.
var formStateToReplace = "<Operator>ContainsAnyIfProvided</Operator>";
var filterRecordsToUpdate = _filterRepository.Table.Where(f => f.State.Contains(formStateToReplace)).ToList();
foreach (var filter in filterRecordsToUpdate) {
filter.State = filter.State.Replace(
formStateToReplace,
"<Operator>ContainsAny</Operator><IgnoreFilterIfValueIsEmpty>true</IgnoreFilterIfValueIsEmpty>");
}
if (IsUpgradingFromOrchard_1_10_x_Version_6) {
MigratePropertyRecordToRewriteOutputCondition();
}

View File

@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using System.Xml.Linq;
@@ -11,22 +10,22 @@ using Orchard.Mvc.Extensions;
using Orchard.Projections.Models;
using Orchard.Projections.Services;
using Orchard.Services;
using Orchard.Utility.Extensions;
namespace Orchard.Projections.StandardQueries {
namespace Orchard.Projections.StandardQueries
{
public class QueryFeedQuery : IFeedQueryProvider, IFeedQuery {
private readonly IContentManager _contentManager;
private readonly IProjectionManager _projectionManager;
private readonly IEnumerable<IHtmlFilter> _htmlFilters;
private readonly IHtmlFilterProcessor _htmlFilterProcessor;
public QueryFeedQuery(
IContentManager contentManager,
IProjectionManager projectionManager,
IEnumerable<IHtmlFilter> htmlFilters)
IHtmlFilterProcessor htmlFilterProcessor)
{
_contentManager = contentManager;
_projectionManager = projectionManager;
_htmlFilters = htmlFilters;
_htmlFilterProcessor = htmlFilterProcessor;
}
public FeedQueryMatch Match(FeedContext context) {
@@ -55,7 +54,7 @@ namespace Orchard.Projections.StandardQueries {
return;
}
var inspector = new ItemInspector(container, _contentManager.GetItemMetadata(container), _htmlFilters);
var inspector = new ItemInspector(container, _contentManager.GetItemMetadata(container), _htmlFilterProcessor);
if (context.Format == "rss") {
var link = new XElement("link");
context.Response.Element.SetElementValue("title", inspector.Title);

View File

@@ -1,34 +1,21 @@
using System;
using System.Collections.Generic;
using System.Web.Mvc;
using System.Xml.Linq;
using Orchard.ContentManagement;
using Orchard.Core.Common.Models;
using Orchard.Core.Feeds.Models;
using Orchard.Core.Feeds.StandardBuilders;
using Orchard.Mvc.Extensions;
using Orchard.Services;
using Orchard.Utility.Extensions;
using Orchard.Core.Feeds;
using Orchard.Tags.Services;
using Orchard.Localization;
using System.Web.Routing;
using System.Xml.Linq;
using Orchard.Core.Feeds;
using Orchard.Core.Feeds.Models;
using Orchard.Environment.Extensions;
using Orchard.Localization;
using Orchard.Mvc.Extensions;
using Orchard.Tags.Services;
namespace Orchard.Tags.Feeds {
[OrchardFeature("Orchard.Tags.Feeds")]
public class TagFeedQuery : IFeedQueryProvider, IFeedQuery {
private readonly IContentManager _contentManager;
private readonly IEnumerable<IHtmlFilter> _htmlFilters;
private readonly ITagService _tagService;
public TagFeedQuery(
IContentManager contentManager,
IEnumerable<IHtmlFilter> htmlFilters,
ITagService tagService) {
_contentManager = contentManager;
public TagFeedQuery(ITagService tagService) {
_tagService = tagService;
_htmlFilters = htmlFilters;
T = NullLocalizer.Instance;
}
@@ -42,11 +29,11 @@ namespace Orchard.Tags.Feeds {
var tagName = (string)tagIdValue.ConvertTo(typeof(string));
var tag = _tagService.GetTagByName(tagName);
if (tag == null) {
return null;
}
return new FeedQueryMatch { FeedQuery = this, Priority = -5 };
}
@@ -57,10 +44,10 @@ namespace Orchard.Tags.Feeds {
var limitValue = context.ValueProvider.GetValue("limit");
var limit = 20;
if (limitValue != null) {
if (limitValue != null) {
Int32.TryParse(Convert.ToString(limitValue), out limit);
}
limit = Math.Min(limit, 100);
var tagName = (string)tagIdValue.ConvertTo(typeof(string));

View File

@@ -1,49 +1,33 @@
using System;
using System.Collections.Generic;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.Environment.Extensions;
using Orchard.Services;
namespace Orchard.Tokens.Filters {
[OrchardFeature("Orchard.Tokens.HtmlFilter")]
public class TokensFilter : ContentHandler, IHtmlFilter {
public class TokensFilter : HtmlFilter {
private readonly ITokenizer _tokenizer;
private ContentItem _displayed;
public TokensFilter(ITokenizer tokenizer) {
_tokenizer = tokenizer;
}
protected override void BuildDisplayShape(BuildDisplayContext context) {
_displayed = context.ContentItem;
public override string ProcessContent(string text, HtmlFilterContext context) {
return TokensReplace(text, context);
}
public string ProcessContent(string text, string flavor) {
return TokensReplace(text);
}
private string TokensReplace(string text) {
private string TokensReplace(string text, HtmlFilterContext context) {
if (String.IsNullOrEmpty(text))
return String.Empty;
// Optimize code path if nothing to do.
if (!text.Contains("#{")) {
if (!text.Contains("#{"))
return text;
}
var data = new Dictionary<string, object>();
if (_displayed != null)
data["Content"] = _displayed;
text = _tokenizer.Replace(text, data);
_displayed = null;
return text;
return _tokenizer.Replace(text, context.Data,
String.Equals(context.Flavor, "html", StringComparison.OrdinalIgnoreCase)
? new ReplaceOptions { Encoding = ReplaceOptions.HtmlEncode }
: new ReplaceOptions { Encoding = ReplaceOptions.NoEncode });
}
}
}

View File

@@ -20,3 +20,4 @@ Features:
Description: Evaluates tokens in a body.
Category: Content
Dependencies: Orchard.Tokens
Priority: -1

View File

@@ -247,7 +247,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.IdentityModel.Tokens.Jwt" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Protocol.Extensions" publicKeyToken="31bf3856ad364e35" culture="neutral" />
@@ -255,15 +255,15 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Protocols.OpenIdConnect" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Tokens" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.IdentityModel.Protocols" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>

View File

@@ -432,7 +432,11 @@
<Compile Include="Services\Clock.cs" />
<Compile Include="Services\ClientHostAddressAccessor.cs" />
<Compile Include="Services\DefaultJsonConverter.cs" />
<Compile Include="Services\HtmlFilterContext.cs" />
<Compile Include="Services\HtmlFilterProcessor.cs" />
<Compile Include="Services\IClientHostAddressAccessor.cs" />
<Compile Include="Services\HtmlFilter.cs" />
<Compile Include="Services\IHtmlFilterProcessor.cs" />
<Compile Include="Services\IJsonConverter.cs" />
<Compile Include="Settings\CurrentSiteWorkContext.cs" />
<Compile Include="Settings\ResourceDebugMode.cs" />

View File

@@ -0,0 +1,5 @@
namespace Orchard.Services {
public abstract class HtmlFilter : Component, IHtmlFilter {
public abstract string ProcessContent(string text, HtmlFilterContext context);
}
}

View File

@@ -0,0 +1,8 @@
using System.Collections.Generic;
namespace Orchard.Services {
public class HtmlFilterContext {
public string Flavor { get; set; }
public IDictionary<string, object> Data { get; set; } = new Dictionary<string, object>();
}
}

View File

@@ -0,0 +1,16 @@
using System.Collections.Generic;
using System.Linq;
namespace Orchard.Services {
public class HtmlFilterProcessor : IHtmlFilterProcessor {
private readonly IEnumerable<IHtmlFilter> _filters;
public HtmlFilterProcessor(IEnumerable<IHtmlFilter> filters) {
_filters = filters;
}
public string ProcessFilters(string text, HtmlFilterContext context) {
return _filters.Aggregate(text, (current, htmlFilter) => htmlFilter.ProcessContent(current, context));
}
}
}

View File

@@ -1,5 +1,5 @@
namespace Orchard.Services {
public interface IHtmlFilter : IDependency {
string ProcessContent(string text, string flavor);
string ProcessContent(string text, HtmlFilterContext context);
}
}
}

View File

@@ -0,0 +1,28 @@
using System.Collections.Generic;
using Orchard.ContentManagement;
namespace Orchard.Services {
public interface IHtmlFilterProcessor : IDependency {
string ProcessFilters(string text, HtmlFilterContext context);
}
public static class HtmlFilterProcessorExtensions {
public static string ProcessFilters(
this IHtmlFilterProcessor processor,
string text,
string flavor,
IDictionary<string, object> data) =>
processor.ProcessFilters(text, new HtmlFilterContext { Flavor = flavor, Data = data });
public static string ProcessFilters(this IHtmlFilterProcessor processor, string text, string flavor) =>
processor.ProcessFilters(text, new HtmlFilterContext { Flavor = flavor });
public static string ProcessFilters(this IHtmlFilterProcessor processor, string text, string flavor, IContent content) =>
processor.ProcessFilters(
text,
new HtmlFilterContext {
Flavor = flavor,
Data = new Dictionary<string, object> { { "Content", content.ContentItem } }
});
}
}