PublishedContent - reorg. existing IPropertyValueConverter impl.
This commit is contained in:
@@ -13,6 +13,7 @@ using Umbraco.Core.Persistence.SqlSyntax;
|
||||
using Umbraco.Core.Persistence.UnitOfWork;
|
||||
using Umbraco.Core.Profiling;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.PropertyEditors.ValueConverters;
|
||||
using Umbraco.Core.Publishing;
|
||||
using Umbraco.Core.Macros;
|
||||
using Umbraco.Core.Services;
|
||||
@@ -261,17 +262,10 @@ namespace Umbraco.Core
|
||||
PropertyEditorValueConvertersResolver.Current = new PropertyEditorValueConvertersResolver(
|
||||
PluginManager.Current.ResolvePropertyEditorValueConverters());
|
||||
|
||||
// initialize the new property value converters
|
||||
// fixme - discuss property converters explicit registration vs. discovery
|
||||
// initialize the new property value converters by discovering IPropertyValueConverter
|
||||
PropertyValueConvertersResolver.Current = new PropertyValueConvertersResolver(
|
||||
PluginManager.Current.ResolveTypes<IPropertyValueConverter>());
|
||||
|
||||
// add the internal ones
|
||||
// fixme - property converters should be public, not internal, and auto-discovered
|
||||
PropertyValueConvertersResolver.Current.AddType<YesNoValueConverter>();
|
||||
PropertyValueConvertersResolver.Current.AddType<DatePickerValueConverter>();
|
||||
PropertyValueConvertersResolver.Current.AddType<TinyMceValueConverter>();
|
||||
|
||||
// this is how we'd switch over to DefaultShortStringHelper _and_ still use
|
||||
// UmbracoSettings UrlReplaceCharacters...
|
||||
//ShortStringHelperResolver.Current = new ShortStringHelperResolver(
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Umbraco.Core.PropertyEditors
|
||||
/// <summary>
|
||||
/// Provides a default overridable implementation for <see cref="IPropertyValueConverter"/> that does nothing.
|
||||
/// </summary>
|
||||
class PropertyValueConverterBase : IPropertyValueConverter
|
||||
public class PropertyValueConverterBase : IPropertyValueConverter
|
||||
{
|
||||
public virtual bool IsConverter(PublishedPropertyType propertyType)
|
||||
{
|
||||
|
||||
@@ -4,11 +4,11 @@ using System.Linq;
|
||||
using System.Xml;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
|
||||
namespace Umbraco.Core.PropertyEditors
|
||||
namespace Umbraco.Core.PropertyEditors.ValueConverters
|
||||
{
|
||||
[PropertyValueType(typeof(DateTime))]
|
||||
[PropertyValueCache(PropertyCacheValue.All, PropertyCacheLevel.Content)]
|
||||
internal class DatePickerValueConverter : PropertyValueConverterBase
|
||||
public class DatePickerValueConverter : PropertyValueConverterBase
|
||||
{
|
||||
private static readonly Guid[] DataTypeGuids = new[]
|
||||
{
|
||||
@@ -2,7 +2,7 @@ using System;
|
||||
using System.Web;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
|
||||
namespace Umbraco.Core.PropertyEditors
|
||||
namespace Umbraco.Core.PropertyEditors.ValueConverters
|
||||
{
|
||||
/// <summary>
|
||||
/// Value converter for the RTE so that it always returns IHtmlString so that Html.Raw doesn't have to be used.
|
||||
@@ -10,7 +10,7 @@ namespace Umbraco.Core.PropertyEditors
|
||||
// PropertyCacheLevel.Content is ok here because that version of RTE converter does not parse {locallink} nor executes macros
|
||||
[PropertyValueType(typeof(IHtmlString))]
|
||||
[PropertyValueCache(PropertyCacheValue.All, PropertyCacheLevel.Content)]
|
||||
internal class TinyMceValueConverter : PropertyValueConverterBase
|
||||
public class TinyMceValueConverter : PropertyValueConverterBase
|
||||
{
|
||||
public override bool IsConverter(PublishedPropertyType propertyType)
|
||||
{
|
||||
@@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
|
||||
namespace Umbraco.Core.PropertyEditors
|
||||
namespace Umbraco.Core.PropertyEditors.ValueConverters
|
||||
{
|
||||
[PropertyValueType(typeof(bool))]
|
||||
[PropertyValueCache(PropertyCacheValue.All, PropertyCacheLevel.Content)]
|
||||
class YesNoValueConverter : PropertyValueConverterBase
|
||||
public class YesNoValueConverter : PropertyValueConverterBase
|
||||
{
|
||||
public override bool IsConverter(PublishedPropertyType propertyType)
|
||||
{
|
||||
@@ -193,7 +193,7 @@
|
||||
<Compile Include="PropertyEditors\PropertyValueTypeAttribute.cs" />
|
||||
<Compile Include="PropertyEditors\PropertyCacheLevel.cs" />
|
||||
<Compile Include="PropertyEditors\PropertyValueConverterBase.cs" />
|
||||
<Compile Include="PropertyEditors\TinyMceValueConverter.cs" />
|
||||
<Compile Include="PropertyEditors\ValueConverters\TinyMceValueConverter.cs" />
|
||||
<Compile Include="PropertyEditors\PropertyValueConvertersResolver.cs" />
|
||||
<Compile Include="PropertyEditors\IPropertyValueConverter.cs" />
|
||||
<Compile Include="Models\PublishedContent\PublishedContentOrderedSet.cs" />
|
||||
@@ -668,7 +668,7 @@
|
||||
<Compile Include="NameValueCollectionExtensions.cs" />
|
||||
<Compile Include="ObjectResolution\WeightedPluginAttribute.cs" />
|
||||
<Compile Include="Persistence\PetaPoco.cs" />
|
||||
<Compile Include="PropertyEditors\DatePickerValueConverter.cs" />
|
||||
<Compile Include="PropertyEditors\ValueConverters\DatePickerValueConverter.cs" />
|
||||
<Compile Include="PropertyEditors\IPropertyEditorValueConverter.cs" />
|
||||
<Compile Include="Dynamics\ParseException.cs" />
|
||||
<Compile Include="Dynamics\PropertyResult.cs" />
|
||||
@@ -703,7 +703,7 @@
|
||||
<Compile Include="ObjectResolution\Resolution.cs" />
|
||||
<Compile Include="ObjectResolution\ResolverBase.cs" />
|
||||
<Compile Include="ObjectResolution\SingleObjectResolverBase.cs" />
|
||||
<Compile Include="PropertyEditors\YesNoValueConverter.cs" />
|
||||
<Compile Include="PropertyEditors\ValueConverters\YesNoValueConverter.cs" />
|
||||
<Compile Include="Publishing\BasePublishingStrategy.cs" />
|
||||
<Compile Include="Publishing\IPublishingStrategy.cs" />
|
||||
<Compile Include="Publishing\PublishingStrategy.cs" />
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.PropertyEditors.ValueConverters;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
|
||||
namespace Umbraco.Tests.PropertyEditors
|
||||
|
||||
@@ -6,6 +6,7 @@ using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.PropertyEditors.ValueConverters;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.PublishedCache;
|
||||
|
||||
@@ -6,9 +6,10 @@ using Umbraco.Core;
|
||||
using Umbraco.Core.Macros;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Core.PropertyEditors.ValueConverters;
|
||||
using Umbraco.Web.Templates;
|
||||
|
||||
namespace Umbraco.Web.PropertyEditors
|
||||
namespace Umbraco.Web.PropertyEditors.ValueConverters
|
||||
{
|
||||
/// <summary>
|
||||
/// A value converter for TinyMCE that will ensure any macro content is rendered properly even when
|
||||
@@ -21,7 +22,7 @@ namespace Umbraco.Web.PropertyEditors
|
||||
// actually required (since Request is default) but leave it here to be absolutely explicit.
|
||||
[PropertyValueType(typeof(IHtmlString))]
|
||||
[PropertyValueCache(PropertyCacheValue.All, PropertyCacheLevel.Request)]
|
||||
internal class RteMacroRenderingValueConverter : TinyMceValueConverter
|
||||
public class RteMacroRenderingValueConverter : TinyMceValueConverter
|
||||
{
|
||||
// NOT thread-safe over a request because it modifies the
|
||||
// global UmbracoContext.Current.InPreviewMode status. So it
|
||||
@@ -456,7 +456,7 @@
|
||||
<Compile Include="Mvc\SurfaceControllerFactory.cs" />
|
||||
<Compile Include="Mvc\PluginControllerMetadata.cs" />
|
||||
<Compile Include="Mvc\UmbracoPageResult.cs" />
|
||||
<Compile Include="PropertyEditors\RteMacroRenderingValueConverter.cs" />
|
||||
<Compile Include="PropertyEditors\ValueConverters\RteMacroRenderingValueConverter.cs" />
|
||||
<Compile Include="RenderFieldCaseType.cs" />
|
||||
<Compile Include="RenderFieldEncodingType.cs" />
|
||||
<Compile Include="RouteCollectionExtensions.cs" />
|
||||
|
||||
@@ -14,6 +14,7 @@ using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.ObjectResolution;
|
||||
using Umbraco.Core.Profiling;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.PropertyEditors.ValueConverters;
|
||||
using Umbraco.Core.Sync;
|
||||
using Umbraco.Web.Dictionary;
|
||||
using Umbraco.Web.Media;
|
||||
@@ -21,6 +22,7 @@ using Umbraco.Web.Media.ThumbnailProviders;
|
||||
using Umbraco.Web.Models;
|
||||
using Umbraco.Web.Mvc;
|
||||
using Umbraco.Web.PropertyEditors;
|
||||
using Umbraco.Web.PropertyEditors.ValueConverters;
|
||||
using Umbraco.Web.PublishedCache;
|
||||
using Umbraco.Web.Routing;
|
||||
using Umbraco.Web.WebApi;
|
||||
@@ -280,10 +282,12 @@ namespace Umbraco.Web
|
||||
UmbracoApiControllerResolver.Current = new UmbracoApiControllerResolver(
|
||||
PluginManager.Current.ResolveUmbracoApiControllers());
|
||||
|
||||
// CoreBootManager configures TinyMceValueConverter
|
||||
// we want to replace it with RteMacroRenderingValueConverter, which will convert macros, etc
|
||||
// both TinyMceValueConverter (in Core) and RteMacroRenderingValueConverter (in Web) will be
|
||||
// discovered when CoreBootManager configures the converters. We HAVE to remove one of them
|
||||
// here because there cannot be two converters for one property editor - and we want the full
|
||||
// RteMacroRenderingValueConverter that converts macros, etc. So remove TinyMceValueConverter.
|
||||
// (why it exists in in the first place, I'm not sure to understand)
|
||||
PropertyValueConvertersResolver.Current.RemoveType<TinyMceValueConverter>();
|
||||
PropertyValueConvertersResolver.Current.AddType<RteMacroRenderingValueConverter>();
|
||||
|
||||
PublishedCachesResolver.Current = new PublishedCachesResolver(new PublishedCaches(
|
||||
new PublishedCache.XmlPublishedCache.PublishedContentCache(),
|
||||
|
||||
Reference in New Issue
Block a user