Ported updates to DynamicDocument to allow dynamic access to RTE content and still have it

render all embedded macro content without resorting to use some other mechanism.
Fixes the .Field method of the UmbracoHelper.
This commit is contained in:
Shannon Deminick
2012-09-08 11:30:19 +07:00
parent 59fa733156
commit d83887e314
6 changed files with 33 additions and 8 deletions

View File

@@ -168,6 +168,10 @@
<!-- This moves the asp.net viewstate data to the end of the html document instead of having it in the beginning-->
<viewstateMoverModule enable="false" />
<!--
Now that we have Log4Net logging enabled, this section is only used for what gets logged to the umbracoLog table
which currently logs items used in the audit trail and roll back scenarios.
-->
<logging>
<enableLogging>true</enableLogging>
<enableAsyncLogging>true</enableAsyncLogging>

View File

@@ -130,6 +130,10 @@
<viewstateMoverModule enable="false" />
<!--
Now that we have Log4Net logging enabled, this section is only used for what gets logged to the umbracoLog table
which currently logs items used in the audit trail and roll back scenarios.
-->
<logging>
<enableLogging>true</enableLogging>
<enableAsyncLogging>true</enableAsyncLogging>

View File

@@ -27,4 +27,5 @@ using System.Security;
// if we remove this class then we won't need to do this.
[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]
[assembly: InternalsVisibleTo("Umbraco.Tests")]
[assembly: InternalsVisibleTo("Umbraco.Tests")]
[assembly: InternalsVisibleTo("umbraco.MacroEngines")]

View File

@@ -22,11 +22,7 @@ namespace Umbraco.Web.PropertyEditors
/// <returns></returns>
public override Attempt<object> ConvertPropertyValue(object value)
{
//TODO: we need to make a few new classes, like a new MacroParser, etc... and move a bunch of the logic
// out of 'Item' that does all of this but it will be tricky because of the way that it creates a 'Macro' class
// we may have to do some server Execute trickyness.
// Then, we need to add this to the resolver and remove the base class and make it abstract.
//we're going to send the string through the macro parser and create the output string.
var sb = new StringBuilder();
var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
MacroTagParser.ParseMacros(

View File

@@ -202,7 +202,6 @@ namespace Umbraco.Web
ItemRenderer.Instance.Init(item);
ItemRenderer.Instance.Load(item);
ItemRenderer.Instance.Render(item, htmlWriter);
_umbracoContext.HttpContext.Server.Execute(containerPage, output, false);
return new HtmlString(output.ToString());
}
}

View File

@@ -3,14 +3,35 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using Umbraco.Core;
using Umbraco.Core.Macros;
using Umbraco.Web;
namespace umbraco.MacroEngines.RazorDataTypeModels
{
/// <summary>
/// This ensures that the RTE renders with HtmlString encoding and also ensures that the macro contents in it
/// render properly too.
/// </summary>
[RazorDataTypeModel("5e9b75ae-face-41c8-b47e-5f4b0fd82f83", 90)]
public class HtmlStringDataTypeModel : IRazorDataTypeModel
{
public bool Init(int CurrentNodeId, string PropertyData, out object instance)
{
instance = new HtmlString(PropertyData);
//we're going to send the string through the macro parser and create the output string.
var sb = new StringBuilder();
var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
MacroTagParser.ParseMacros(
PropertyData,
//callback for when text block is found
textBlock => sb.Append(textBlock),
//callback for when macro syntax is found
(macroAlias, macroAttributes) => sb.Append(umbracoHelper.RenderMacro(
macroAlias,
//needs to be explicitly casted to Dictionary<string, object>
macroAttributes.ConvertTo(x => (string)x, x => (object)x)).ToString()));
instance = new HtmlString(sb.ToString());
return true;
}
}